keyboard.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* ========================================================================
  2. * [PROJECT] SIR
  3. * [MODULE] Keyboard module
  4. * [TITLE] keyboard module source file
  5. * [FILE] keyboard.h
  6. * [VSN] 1.0
  7. * [CREATED] 28 july 2003
  8. * [LASTCHNGD] 18 august 2003
  9. * [COPYRIGHT] Copyright (C) STREAMIT BV 2010
  10. * [PURPOSE] Keyboard routines
  11. * ======================================================================== */
  12. /*-------------------------------------------------------------------------*/
  13. /* global defines */
  14. /*-------------------------------------------------------------------------*/
  15. #define KB_COL_0 3
  16. #define KB_COL_1 4
  17. #define KB_COL_2 3
  18. #define KB_COL_3 2
  19. #define KB_ROW_0 0
  20. #define KB_ROW_1 1
  21. #define KB_ROW_2 2
  22. #define KB_ROW_3 3
  23. #define KB_ROW_MASK 0xF0
  24. #define KB_OK 0x00
  25. #define KB_ERROR 0x01
  26. /* state machine defines -------------------------------------------------- */
  27. #define KB_IDLE 0x00
  28. #define KB_KEY 0x01
  29. #define KB_VALID 0x02
  30. #define KB_RELEASE 0x03
  31. #define KB_COUNTER_OK 0x03 // # a key must be seen before declared 'valid'
  32. #define KB_LONG_HOLD_TIME 500 // 500 x 4.4 msec = 2200 msec
  33. #define KB_BUFFER_SIZE 1
  34. /*
  35. * below are the keys after they where remapped to 8-bit values
  36. * These definitions are used by the application
  37. */
  38. #define KEY_SPEC 0
  39. #define KEY_01 1
  40. #define KEY_02 2
  41. #define KEY_03 3
  42. #define KEY_04 4
  43. #define KEY_05 5
  44. #define KEY_ALT 6
  45. #define KEY_ESC 7
  46. #define KEY_UP 8
  47. #define KEY_OK 9
  48. #define KEY_LEFT 10
  49. #define KEY_DOWN 11
  50. #define KEY_RIGHT 12
  51. #define KEY_POWER 13
  52. #define KEY_SETUP 14
  53. #define KEY_LCD 15 // virtual key, generated when '1' is pressed and hold for > 2 secs
  54. #define KEY_07 18 // only on RC and only used for selftest
  55. #define KEY_NROF_KEYS 16
  56. // next 2 'keys' are simulated when inserting or removing a MMC
  57. #define KEY_MMC_IN 16
  58. #define KEY_MMC_OUT 17
  59. // remove these, not available on SIR100
  60. #define KEY_00 0xFC
  61. #define IS_IR_KEY(key) (((key>=KEY_01) && (key<=KEY_09)) || (key==KEY_00))
  62. /* definition of virtual special keys ------------------------------------- */
  63. #define KEY_UNDEFINED 0x88
  64. #define KEY_TIMEOUT 0xAA
  65. #define KEY_NO_KEY 0xFFFF // yes, indeed no u_char....
  66. #define KEY_REPEAT_TIME 100 // 100 * 4.48 = about half a second
  67. #define KEY_REPEAT 1
  68. #define KEY_NO_REPEAT 2
  69. /*-------------------------------------------------------------------------*/
  70. /* export global routines (interface) */
  71. /*-------------------------------------------------------------------------*/
  72. void KbInit(void);
  73. void KbScan(void);
  74. int CheckKey(void);
  75. int KbWaitForKeyEvent(u_long);
  76. u_char KbGetKey(void);
  77. void KbSetKeyRepeating(u_char, u_char);
  78. void KbInjectKey(u_char VirtualKey);
  79. /* ���� End Of File �������� �������������������������������������������� */