libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmKeyboard.h 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. #ifndef cmKeyboard_h
  4. #define cmKeyboard_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( { file_desc:"Query and get keypresses directly from the console." kw:[system devices] }
  9. enum
  10. {
  11. kInvalidKId,
  12. kAsciiKId,
  13. kLeftArrowKId,
  14. kRightArrowKId,
  15. kUpArrowKId,
  16. kDownArrowKId,
  17. kHomeKId,
  18. kEndKId,
  19. kPgUpKId,
  20. kPgDownKId,
  21. kInsertKId,
  22. kDeleteKId,
  23. };
  24. typedef struct
  25. {
  26. unsigned code;
  27. char ch;
  28. bool ctlFl;
  29. bool altFl;
  30. } cmKbRecd;
  31. // Set 'p' to NULL if the value of the key is not required.
  32. void cmKeyPress( cmKbRecd* p );
  33. // Return non-zero if a key is waiting to be read otherwise return 0.
  34. // Use getchar() to pick up the key.
  35. //
  36. // Example:
  37. // while( 1 )
  38. // {
  39. // if( cmIsKeyWaiting() == 0 )
  40. // usleep(20000);
  41. // else
  42. // {
  43. // char c = getchar();
  44. // switch(c)
  45. // {
  46. // ....
  47. // }
  48. // }
  49. //
  50. // }
  51. //
  52. // TODO: Note that this function turns off line-buffering on stdin.
  53. // It should be changed to a three function sequence.
  54. // bool org_state = cmSetStdinLineBuffering(false);
  55. // ....
  56. // cmIsKeyWaiting()
  57. // ....
  58. // cmSetStdinLineBuffering(org_state)
  59. int cmIsKeyWaiting();
  60. //)
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. #endif