key.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/key.h>
  4. #include "wonx.h"
  5. #include "WonxDisplay.h"
  6. int key_press_check(void)
  7. {
  8. XDisplay x_display;
  9. int ret;
  10. printf("call : key_press_check() : "); fflush(stdout);
  11. if (wonx_display == NULL) Wonx_Create();
  12. x_display = WonxDisplay_GetXDisplay(wonx_display);
  13. XDisplay_Sync(x_display);
  14. ret = XDisplay_GetKeyPress(x_display);
  15. WonxDisplay_Sync(wonx_display);
  16. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  17. return (ret);
  18. }
  19. int key_hit_check(void)
  20. {
  21. XDisplay x_display;
  22. int ret;
  23. printf("call : key_hit_check() : "); fflush(stdout);
  24. if (wonx_display == NULL) Wonx_Create();
  25. x_display = WonxDisplay_GetXDisplay(wonx_display);
  26. XDisplay_Sync(x_display);
  27. ret = XDisplay_GetKeyPress(x_display);
  28. WonxDisplay_Sync(wonx_display);
  29. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  30. return (ret);
  31. }
  32. int key_wait(void)
  33. {
  34. XDisplay x_display;
  35. int ret;
  36. printf("call : key_wait() : "); fflush(stdout);
  37. if (wonx_display == NULL) Wonx_Create();
  38. x_display = WonxDisplay_GetXDisplay(wonx_display);
  39. ret = 0;
  40. do {
  41. XDisplay_Sync(x_display);
  42. ret = XDisplay_GetKeyPress(x_display);
  43. } while (ret == 0);
  44. WonxDisplay_Sync(wonx_display);
  45. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  46. return (ret);
  47. }
  48. void key_set_repeat(int rate, int delay)
  49. {
  50. printf("call : key_set_repeat() : rate = %d, delay = %d, ", rate, delay);
  51. fflush(stdout);
  52. if (wonx_display == NULL) Wonx_Create();
  53. WonxDisplay_Sync(wonx_display);
  54. printf("return value = none\n"); fflush(stdout);
  55. return;
  56. }
  57. int key_get_repeat(void)
  58. {
  59. int ret;
  60. printf("call : key_get_repeat() : "); fflush(stdout);
  61. if (wonx_display == NULL) Wonx_Create();
  62. ret = 0;
  63. WonxDisplay_Sync(wonx_display);
  64. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  65. return (ret);
  66. }
  67. int key_hit_check_with_repeat(void)
  68. {
  69. XDisplay x_display;
  70. int ret;
  71. printf("call : key_hit_check_with_repeat() : "); fflush(stdout);
  72. if (wonx_display == NULL) Wonx_Create();
  73. x_display = WonxDisplay_GetXDisplay(wonx_display);
  74. XDisplay_Sync(x_display);
  75. ret = XDisplay_GetKeyPress(x_display);
  76. WonxDisplay_Sync(wonx_display);
  77. printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
  78. return (ret);
  79. }