Subversion Repositories Kolibri OS

Rev

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