Subversion Repositories Kolibri OS

Rev

Rev 2 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ha 1
;// mike.dld [
2
 
3
VKEY_LSHIFT   = 0000000000000001b
4
VKEY_RSHIFT   = 0000000000000010b
5
VKEY_LCONTROL = 0000000000000100b
6
VKEY_RCONTROL = 0000000000001000b
7
VKEY_LALT     = 0000000000010000b
8
VKEY_RALT     = 0000000000100000b
9
VKEY_CAPSLOCK = 0000000001000000b
10
VKEY_NUMLOCK  = 0000000010000000b
11
VKEY_SCRLOCK  = 0000000100000000b
12
 
13
VKEY_SHIFT    = 0000000000000011b
14
VKEY_CONTROL  = 0000000000001100b
15
VKEY_ALT      = 0000000000110000b
16
 
17
uglobal
18
  align 4
19
  kb_state      dd 0
20
  ext_code      db 0
21
 
22
  keyboard_mode db 0
23
  keyboard_data db 0
24
 
25
  altmouseb     db 0
26
  ctrl_alt_del  db 0
27
 
28
  kb_lights     db 0
29
endg
30
 
31
align 4
32
irq1:
33
 
34
       call  restore_caller
35
 
36
       movzx eax,word[0x3004] ; top window process
37
       movzx eax,word[0xC400+eax*2]
38
       shl   eax,8
39
       mov   al,[0x800B4+eax]
40
       mov   [keyboard_mode],al
41
 
42
       in    al,0x60
43
       mov   [keyboard_data],al
44
 
45
       mov   ch,al
46
       cmp   al,0xE0
47
       je    @f
48
       cmp   al,0xE1
49
       jne   .normal_code
50
   @@: mov   [ext_code],al
51
       jmp   .no_key.end
52
   .normal_code:
53
       mov   cl,[ext_code]
54
       mov   [ext_code],0
55
       and   al,0x7F
56
   @@: cmp   al,0x2A
57
       jne   @f
58
       cmp   cl,0xE0
59
       je    .no_key.end
60
       mov   eax,VKEY_LSHIFT
61
       jmp   .no_key
62
   @@: cmp   al,0x36
63
       jne   @f
64
       cmp   cl,0xE0
65
       je    .no_key.end
66
       mov   eax,VKEY_RSHIFT
67
       jmp   .no_key
68
   @@: cmp   al,0x38
69
       jne   @f
70
       cmp   cl,0xE0
71
       je    .alt.r
72
       mov   eax,VKEY_LALT
73
       jmp   .no_key
74
   .alt.r:
75
       mov   eax,VKEY_RALT
76
       jmp   .no_key
77
   @@: cmp   al,0x1D
78
       jne   @f
79
       cmp   cl,0
80
       jne   .ctrl.r
81
       mov   eax,VKEY_LCONTROL
82
       jmp   .no_key
83
   .ctrl.r:
84
       cmp   cl,0xE1
85
       jne   .ctrl.r.2
86
       mov   [ext_code],cl
87
       jmp   .no_key.end
88
   .ctrl.r.2:
89
       mov   eax,VKEY_RCONTROL
90
       jmp   .no_key
91
   @@: cmp   al,0x3A
92
       jne   @f
93
       mov   bl,4
94
       mov   eax,VKEY_CAPSLOCK
95
       jmp   .no_key.xor
96
   @@: cmp   al,0x45
97
       jne   @f
98
       cmp   cl,0
99
       jne   .no_key.end
100
       mov   bl,2
101
       mov   eax,VKEY_NUMLOCK
102
       jmp   .no_key.xor
103
   @@: cmp   al,0x46
104
       jne   @f
105
       mov   bl,1
106
       mov   eax,VKEY_SCRLOCK
107
       jmp   .no_key.xor
108
   @@:
109
       test  ch,0x80
110
       jnz   .no_key.end
111
       movzx eax,ch              ; plain key
112
       mov   bl,[keymap+eax]
113
       mov   edx,[kb_state]
114
       test  dl,VKEY_CONTROL     ; ctrl alt del
115
       jz    .noctrlaltdel
116
       test  dl,VKEY_ALT
117
       jz    .noctrlaltdel
118
       cmp   bl,134+48
119
       jne   .noctrlaltdel
120
       mov   [ctrl_alt_del],1
121
       jmp   .no_key.end
122
   .noctrlaltdel:
123
       test  dl,VKEY_CONTROL     ; ctrl on ?
124
       jz    @f
125
       sub   bl,0x60
126
   @@: test  dl,VKEY_SHIFT       ; shift on ?
127
       jz    @f
128
       mov   bl,[keymap_shift+eax]
129
   @@: test  dl,VKEY_ALT         ; alt on ?
130
       jz    @f
131
       mov   bl,[keymap_alt+eax]
132
; alt mouse ?
133
       xor   edx,edx
134
       cmp   bl,178
135
       jnz   .no_alt.up
136
       mov   edx,5*65536
137
       jmp   .mouse.change
138
   .no_alt.up:
139
       cmp   bl,177
140
       jnz   .no_alt.down
141
       mov   edx,251*65536
142
       jmp   .mouse.change
143
   .no_alt.down:
144
       cmp   bl,176
145
       jnz   .no_alt.left
146
       mov   edx,251*256
147
       jmp   .mouse.change
148
   .no_alt.left:
149
       cmp   bl,179
150
       jnz   .no_alt.right
151
       mov   edx,5*256
152
       jmp   .mouse.change
153
   .no_alt.right:
154
       cmp   bl,' '
155
       jne   @f
156
       xor   [altmouseb],1
157
   .mouse.change:
158
       mov   byte[0xF604],1; ps2 data
159
       mov   byte[0xFB00],0; ps2 chunk count
160
       mov   word[0x2E0000+4096*12],3; mouse data count
161
       mov   dl,[altmouseb]
162
       mov   [0x2E0000+4096*12+0x10],edx
163
       mov   bl,0
164
   @@:
165
       cmp   [keyboard_mode],0 ; return from keymap
166
       jne   .no_key.end
167
       mov   [keyboard_mode_sys],0
168
       cmp   bl,0
169
       je    .no_key.end
170
       movzx eax,byte[0xF400]
171
       cmp   al,120
172
       jae   .no_key.end
173
       inc   al
174
       mov   [0xF400],al
175
       mov   [0xF400+eax],bl
176
 
177
       jmp   .no_key.end
178
 
179
   .no_key:
180
       test  ch,0x80
181
       jz    .no_key.down
182
       not   eax
183
       and   [kb_state],eax
184
       jmp   .no_key.end
185
   .no_key.xor:
186
       test  ch,0x80
187
       jnz   .no_key.end
188
       xor   [kb_state],eax
189
       xor   [kb_lights],bl
190
       call  set_lights
191
       jmp   .no_key.end
192
   .no_key.down:
193
       or    [kb_state],eax
194
   .no_key.end:
195
       cmp   [keyboard_mode],1 ; return scancode
196
       jne   .no_scancode
197
       mov   [keyboard_mode_sys],1
198
       movzx eax,byte[0xF400]
199
       cmp   al,120
200
       jae   .no_scancode
201
       inc   al
202
       mov   [0xF400],al
203
       mov   [0xF400+eax],ch
204
   .no_scancode:
205
 
206
   .exit.irq1:
207
       mov   [check_idle_semaphore],5
208
 
209
       mov   al,0x20                  ; ready for next irq
210
       out   0x20,al
211
 
212
       call  return_to_caller
213
 
214
       jmp   irq1
215
 
216
set_lights:
217
       mov   al,0xED
218
       call  kb_write
219
       mov   al,[kb_lights]
220
       call  kb_write
221
       ret
222
 
223
;// mike.dld ]