Subversion Repositories Kolibri OS

Rev

Rev 6791 | Rev 7096 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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