Subversion Repositories Kolibri OS

Rev

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