Subversion Repositories Kolibri OS

Rev

Rev 7248 | Rev 7265 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef INCLUDE_KEYBOARD_H
  2. #define INCLUDE_KEYBOARD_H
  3.  
  4. //ASCII KEYS
  5. #define ASCII_KEY_BS    008
  6. #define ASCII_KEY_TAB   009
  7. #define ASCII_KEY_ENTER 013
  8. #define ASCII_KEY_ESC   027
  9. #define ASCII_KEY_DEL   182
  10. #define ASCII_KEY_INS   185
  11. #define ASCII_KEY_SPACE 032
  12.  
  13. #define ASCII_KEY_LEFT  176
  14. #define ASCII_KEY_RIGHT 179
  15. #define ASCII_KEY_DOWN  177
  16. #define ASCII_KEY_UP    178
  17. #define ASCII_KEY_HOME  180
  18. #define ASCII_KEY_END   181
  19. #define ASCII_KEY_PGDN  183
  20. #define ASCII_KEY_PGUP  184
  21.  
  22. //SCAN CODE KEYS
  23. #define SCAN_CODE_BS    014
  24. #define SCAN_CODE_TAB   015
  25. #define SCAN_CODE_ENTER 028
  26. #define SCAN_CODE_ESC   001
  27. #define SCAN_CODE_DEL   083
  28. #define SCAN_CODE_INS   082
  29. #define SCAN_CODE_SPACE 057
  30.  
  31. #define SCAN_CODE_LEFT  075
  32. #define SCAN_CODE_RIGHT 077
  33. #define SCAN_CODE_DOWN  080
  34. #define SCAN_CODE_UP    072
  35. #define SCAN_CODE_HOME  071
  36. #define SCAN_CODE_END   079
  37. #define SCAN_CODE_PGDN  081
  38. #define SCAN_CODE_PGUP  073
  39.  
  40. #define SCAN_CODE_MINUS 012
  41. #define SCAN_CODE_PLUS  013
  42.  
  43. #define SCAN_CODE_F1    059
  44.  
  45. #define SCAN_CODE_KEY_B 048
  46. #define SCAN_CODE_KEY_C 046
  47. #define SCAN_CODE_KEY_E 018
  48. #define SCAN_CODE_KEY_F 033
  49. #define SCAN_CODE_KEY_I 023
  50. #define SCAN_CODE_KEY_L 038
  51. #define SCAN_CODE_KEY_M 050
  52. #define SCAN_CODE_KEY_O 024
  53. #define SCAN_CODE_KEY_P 025
  54. #define SCAN_CODE_KEY_R 019
  55. #define SCAN_CODE_KEY_S 031
  56. #define SCAN_CODE_KEY_V 047
  57. #define SCAN_CODE_KEY_X 045
  58. #define SCAN_CODE_KEY_Y 021
  59. #define SCAN_CODE_KEY_Z 044
  60.  
  61.  
  62. #define KEY_LSHIFT     00000000001b
  63. #define KEY_RSHIFT     00000000010b
  64. #define KEY_LCTRL      00000000100b
  65. #define KEY_RCTRL      00000001000b
  66. #define KEY_LALT       00000010000b
  67. #define KEY_RALT       00000100000b
  68. #define KEY_CAPSLOCK   00001000000b
  69. #define KEY_NUMLOCK    00010000000b
  70. #define KEY_SCROLLLOCK 00100000000b
  71. #define KEY_LWIN       01000000000b
  72. #define KEY_RWIN       10000000000b
  73.  
  74. inline fastcall word GetKey()  //+Gluk fix
  75. {
  76.                 $push edx
  77. GETKEY:
  78.                 $mov  eax,2
  79.                 $int  0x40
  80.                 $cmp eax,1
  81.                 $jne GETKEYI
  82.                 $mov ah,dh
  83.                 $jmp GETKEYII //jz?
  84. GETKEYI:
  85.                 $mov dh,ah
  86.                 $jmp GETKEY
  87. GETKEYII:
  88.                 $pop edx
  89.                 $shr eax,8
  90. }
  91.  
  92. :unsigned char key_ascii;
  93. :dword key_scancode, key_modifier, key_editbox;
  94. :int GetKeys()
  95. {
  96.                 $push edx
  97. GETKEY:
  98.                 $mov  eax,2
  99.                 $int  0x40
  100.                 $cmp eax,1
  101.                 $jne GETKEYI
  102.                 $mov eax,edx
  103.                 $jmp GETKEYII
  104. GETKEYI:
  105.                 $mov edx,eax
  106.                 $jmp GETKEY
  107. GETKEYII:
  108.                 $pop edx
  109.         key_editbox = EAX;
  110.         key_ascii = AH;
  111.         $shr  eax,16
  112.         key_scancode = AL;
  113.         //get alt/shift/ctrl key status
  114.         $mov eax,66
  115.         $mov ebx,3
  116.         $int 0x40
  117.         key_modifier = EAX;
  118.         EAX = key_editbox;
  119. }
  120.  
  121. #endif