Subversion Repositories Kolibri OS

Rev

Rev 7096 | Rev 7192 | 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_KEY_C 046
  44. #define SCAN_CODE_KEY_M 050
  45. #define SCAN_CODE_KEY_I 023
  46. #define SCAN_CODE_KEY_O 024
  47. #define SCAN_CODE_KEY_P 025
  48.  
  49. #define KEY_LSHIFT     00000000001b
  50. #define KEY_RSHIFT     00000000010b
  51. #define KEY_LCTRL      00000000100b
  52. #define KEY_RCTRL      00000001000b
  53. #define KEY_LALT       00000010000b
  54. #define KEY_RALT       00000100000b
  55. #define KEY_CAPSLOCK   00001000000b
  56. #define KEY_NUMLOCK    00010000000b
  57. #define KEY_SCROLLLOCK 00100000000b
  58. #define KEY_LWIN       01000000000b
  59. #define KEY_RWIN       10000000000b
  60.  
  61. inline fastcall word GetKey()  //+Gluk fix
  62. {
  63.                 $push edx
  64. GETKEY:
  65.                 $mov  eax,2
  66.                 $int  0x40
  67.                 $cmp eax,1
  68.                 $jne GETKEYI
  69.                 $mov ah,dh
  70.                 $jmp GETKEYII //jz?
  71. GETKEYI:
  72.                 $mov dh,ah
  73.                 $jmp GETKEY
  74. GETKEYII:
  75.                 $pop edx
  76.                 $shr eax,8
  77. }
  78.  
  79. :unsigned char key_ascii;
  80. :dword key_scancode, key_modifier, key_editbox;
  81. :int GetKeys()
  82. {
  83.                 $push edx
  84. GETKEY:
  85.                 $mov  eax,2
  86.                 $int  0x40
  87.                 $cmp eax,1
  88.                 $jne GETKEYI
  89.                 $mov eax,edx
  90.                 $jmp GETKEYII
  91. GETKEYI:
  92.                 $mov edx,eax
  93.                 $jmp GETKEY
  94. GETKEYII:
  95.                 $pop edx
  96.         key_editbox = EAX;
  97.         key_ascii = AH;
  98.         $shr  eax,16
  99.         key_scancode = AL;
  100.         //get alt/shift/ctrl key status
  101.         $mov eax,66
  102.         $mov ebx,3
  103.         $int 0x40
  104.         key_modifier = EAX;
  105.         EAX = key_editbox;
  106. }
  107.  
  108. #endif