Getche.cpp 762 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #if defined(_WIN32)
  11. #include <conio.h> /* getche() */
  12. #elif defined(__S3E__)
  13. #else
  14. #include "Getche.h"
  15. char getche()
  16. {
  17. struct termios oldt,
  18. newt;
  19. char ch;
  20. tcgetattr( STDIN_FILENO, &oldt );
  21. newt = oldt;
  22. newt.c_lflag &= ~( ICANON | ECHO );
  23. tcsetattr( STDIN_FILENO, TCSANOW, &newt );
  24. ch = getchar();
  25. tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
  26. return ch;
  27. }
  28. #endif
粤ICP备19079148号