Subversion Repositories Kolibri OS

Rev

Rev 40 | Rev 115 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 40 Rev 92
Line 24... Line 24...
24
 
24
 
25
  altmouseb     db 0
25
  altmouseb     db 0
Line 26... Line 26...
26
  ctrl_alt_del  db 0
26
  ctrl_alt_del  db 0
-
 
27
 
-
 
28
  kb_lights     db 0
-
 
29
 
-
 
30
align 4
-
 
31
        hotkey_scancodes        rd      256     ; we have 256 scancodes
-
 
32
        hotkey_list             rd      256*4   ; max 256 defined hotkeys
-
 
33
        hotkey_buffer           rd      120*2   ; buffer for 120 hotkeys
-
 
34
endg
-
 
35
 
-
 
36
iglobal
-
 
37
hotkey_tests    dd      hotkey_test0
-
 
38
                dd      hotkey_test1
-
 
39
                dd      hotkey_test2
-
 
40
                dd      hotkey_test3
27
 
41
                dd      hotkey_test4
Line -... Line 42...
-
 
42
hotkey_tests_num = 5
-
 
43
endg
-
 
44
 
-
 
45
hotkey_test0:
-
 
46
        test    al, al
-
 
47
        setz    al
-
 
48
        ret
-
 
49
hotkey_test1:
-
 
50
        test    al, al
-
 
51
        setnp   al
-
 
52
        ret
-
 
53
hotkey_test2:
-
 
54
        cmp     al, 3
-
 
55
        setz    al
-
 
56
        ret
-
 
57
hotkey_test3:
-
 
58
        cmp     al, 1
-
 
59
        setz    al
-
 
60
        ret
-
 
61
hotkey_test4:
-
 
62
        cmp     al, 2
-
 
63
        setz    al
-
 
64
        ret
-
 
65
 
-
 
66
hotkey_do_test:
-
 
67
        push    eax
-
 
68
        mov     edx, [kb_state]
-
 
69
        shr     edx, cl
-
 
70
        add     cl, cl
-
 
71
        mov     eax, [eax+4]
-
 
72
        shr     eax, cl
-
 
73
        and     eax, 15
-
 
74
        cmp     al, hotkey_tests_num
-
 
75
        jae     .fail
-
 
76
        xchg    eax, edx
-
 
77
        and     al, 3
-
 
78
        call    [hotkey_tests + edx*4]
-
 
79
        cmp     al, 1
-
 
80
        pop     eax
-
 
81
        ret
-
 
82
.fail:
-
 
83
        stc
28
  kb_lights     db 0
84
        pop     eax
29
endg
85
        ret
30
 
86
 
31
align 4
87
align 4
32
irq1:
88
irq1:
Line 42... Line 98...
42
       mov   [keyboard_mode],al
98
       mov   [keyboard_mode],al
Line 43... Line 99...
43
 
99
 
44
       in    al,0x60
100
       in    al,0x60
Line -... Line 101...
-
 
101
       mov   [keyboard_data],al
-
 
102
 
-
 
103
; ch = scancode
-
 
104
; cl = ext_code
-
 
105
; bh = 0 - normal key
-
 
106
; bh = 1 - modifier (Shift/Ctrl/Alt)
45
       mov   [keyboard_data],al
107
; bh = 2 - extended code
46
 
108
 
47
       mov   ch,al
109
       mov   ch,al
48
       cmp   al,0xE0
110
       cmp   al,0xE0
49
       je    @f
111
       je    @f
-
 
112
       cmp   al,0xE1
-
 
113
       jne   .normal_code
50
       cmp   al,0xE1
114
   @@:
51
       jne   .normal_code
115
        mov     bh, 2
52
   @@: mov   [ext_code],al
116
        mov     [ext_code], al
53
       jmp   .no_key.end
117
        jmp     .writekey
54
   .normal_code:
118
   .normal_code:
55
       mov   cl,[ext_code]
119
        mov     cl, 0
-
 
120
        xchg    cl, [ext_code]
56
       mov   [ext_code],0
121
       and   al,0x7F
57
       and   al,0x7F
122
        mov     bh, 1
58
   @@: cmp   al,0x2A
123
   @@: cmp   al,0x2A
59
       jne   @f
124
       jne   @f
60
       cmp   cl,0xE0
125
       cmp   cl,0xE0
61
       je    .no_key.end
126
       je    .writekey
62
       mov   eax,VKEY_LSHIFT
127
       mov   eax,VKEY_LSHIFT
63
       jmp   .no_key
128
       jmp   .modifier
64
   @@: cmp   al,0x36
129
   @@: cmp   al,0x36
65
       jne   @f
130
       jne   @f
66
       cmp   cl,0xE0
131
       cmp   cl,0xE0
67
       je    .no_key.end
132
       je    .writekey
68
       mov   eax,VKEY_RSHIFT
133
       mov   eax,VKEY_RSHIFT
69
       jmp   .no_key
134
       jmp   .modifier
70
   @@: cmp   al,0x38
-
 
71
       jne   @f
-
 
72
       cmp   cl,0xE0
135
   @@: cmp   al,0x38
73
       je    .alt.r
136
       jne   @f
74
       mov   eax,VKEY_LALT
137
        mov     eax, VKEY_LALT
75
       jmp   .no_key
138
        test    cl, cl
76
   .alt.r:
139
        jz      .modifier
77
       mov   eax,VKEY_RALT
140
        mov     al, VKEY_RALT
78
       jmp   .no_key
141
        jmp     .modifier
79
   @@: cmp   al,0x1D
-
 
80
       jne   @f
-
 
81
       cmp   cl,0
142
   @@: cmp   al,0x1D
82
       jne   .ctrl.r
143
       jne   @f
83
       mov   eax,VKEY_LCONTROL
144
        mov     eax, VKEY_LCONTROL
-
 
145
        test    cl, cl
84
       jmp   .no_key
146
        jz      .modifier
85
   .ctrl.r:
147
        mov     al, VKEY_RCONTROL
86
       cmp   cl,0xE1
148
        cmp     cl, 0xE0
87
       jne   .ctrl.r.2
-
 
88
       mov   [ext_code],cl
-
 
89
       jmp   .no_key.end
-
 
90
   .ctrl.r.2:
149
        jz      .modifier
91
       mov   eax,VKEY_RCONTROL
150
        mov     [ext_code], cl
92
       jmp   .no_key
151
        jmp     .writekey
93
   @@: cmp   al,0x3A
152
   @@: cmp   al,0x3A
94
       jne   @f
153
       jne   @f
95
       mov   bl,4
154
       mov   bl,4
96
       mov   eax,VKEY_CAPSLOCK
155
       mov   eax,VKEY_CAPSLOCK
97
       jmp   .no_key.xor
156
       jmp   .no_key.xor
98
   @@: cmp   al,0x45
157
   @@: cmp   al,0x45
99
       jne   @f
158
       jne   @f
100
       cmp   cl,0
159
        test    cl, cl
101
       jne   .no_key.end
160
        jnz     .writekey
102
       mov   bl,2
161
       mov   bl,2
103
       mov   eax,VKEY_NUMLOCK
162
       mov   eax,VKEY_NUMLOCK
104
       jmp   .no_key.xor
163
       jmp   .no_key.xor
105
   @@: cmp   al,0x46
164
   @@: cmp   al,0x46
106
       jne   @f
165
       jne   @f
107
       mov   bl,1
166
       mov   bl,1
108
       mov   eax,VKEY_SCRLOCK
167
       mov   eax,VKEY_SCRLOCK
109
       jmp   .no_key.xor
168
       jmp   .no_key.xor
110
   @@:
169
   @@:
111
       test  ch,0x80
170
       test  ch,ch
112
       jnz   .no_key.end
171
       js    .writekey
113
       movzx eax,ch              ; plain key
172
       movzx eax,ch              ; plain key
114
       mov   bl,[keymap+eax]
173
       mov   bl,[keymap+eax]
115
       mov   edx,[kb_state]
174
       mov   edx,[kb_state]
116
       test  dl,VKEY_CONTROL     ; ctrl alt del
175
       test  dl,VKEY_CONTROL     ; ctrl alt del
117
       jz    .noctrlaltdel
176
       jz    .noctrlaltdel
118
       test  dl,VKEY_ALT
177
       test  dl,VKEY_ALT
119
       jz    .noctrlaltdel
178
       jz    .noctrlaltdel
120
       cmp   bl,134+48
179
       cmp   ch,53h
121
       jne   .noctrlaltdel
-
 
122
       mov   [ctrl_alt_del],1
180
       jne   .noctrlaltdel
123
       jmp   .no_key.end
181
       mov   [ctrl_alt_del],1
124
   .noctrlaltdel:
182
   .noctrlaltdel:
125
       test  dl,VKEY_CONTROL     ; ctrl on ?
183
       test  dl,VKEY_CONTROL     ; ctrl on ?
126
       jz    @f
184
       jz    @f
Line 162... Line 220...
162
       mov   word[0x2E0000+4096*12],3; mouse data count
220
       mov   word[0x2E0000+4096*12],3; mouse data count
163
       mov   dl,[altmouseb]
221
       mov   dl,[altmouseb]
164
       mov   [0x2E0000+4096*12+0x10],edx
222
       mov   [0x2E0000+4096*12+0x10],edx
165
       mov   bl,0
223
       mov   bl,0
166
   @@:
224
   @@:
167
       cmp   [keyboard_mode],0 ; return from keymap
-
 
168
       jne   .no_key.end
-
 
169
       mov   [keyboard_mode_sys],0
-
 
170
       cmp   bl,0
225
        mov     bh, 0
171
       je    .no_key.end
226
        jmp     .writekey
172
       movzx eax,byte[0xF400]
227
.modifier:
173
       cmp   al,120
228
        test    ch, ch
174
       jae   .no_key.end
229
        js      .modifier.up
175
       inc   al
-
 
176
       mov   [0xF400],al
-
 
177
       mov   [0xF400+eax],bl
230
        or      [kb_state], eax
178
 
-
 
179
       jmp   .no_key.end
231
        jmp     .writekey
180
 
-
 
181
   .no_key:
232
.modifier.up:
182
       test  ch,0x80
-
 
183
       jz    .no_key.down
-
 
184
       not   eax
233
        not     eax
185
       and   [kb_state],eax
234
        and     [kb_state], eax
186
       jmp   .no_key.end
235
        jmp     .writekey
187
   .no_key.xor:
236
.no_key.xor:
-
 
237
        mov     bh, 0
188
       test  ch,0x80
238
        test    ch, ch
189
       jnz   .no_key.end
239
        js      .writekey
190
       xor   [kb_state],eax
240
        xor     [kb_state], eax
191
       xor   [kb_lights],bl
241
        xor     [kb_lights], bl
192
       call  set_lights
242
        call    set_lights
-
 
243
 
-
 
244
.writekey:
-
 
245
; test for system hotkeys
-
 
246
        movzx   eax, ch
-
 
247
        cmp     bh, 1
-
 
248
        ja      .nohotkey
-
 
249
        jb      @f
-
 
250
        xor     eax, eax
-
 
251
@@:
-
 
252
        mov     eax, [hotkey_scancodes + eax*4]
-
 
253
.hotkey_loop:
-
 
254
        test    eax, eax
-
 
255
        jz      .nohotkey
-
 
256
        mov     cl, 0
-
 
257
        call    hotkey_do_test
-
 
258
        jc      .hotkey_cont
-
 
259
        mov     cl, 2
-
 
260
        call    hotkey_do_test
-
 
261
        jc      .hotkey_cont
-
 
262
        mov     cl, 4
-
 
263
        call    hotkey_do_test
193
       jmp   .no_key.end
264
        jnc     .hotkey_found
194
   .no_key.down:
265
.hotkey_cont:
195
       or    [kb_state],eax
266
        mov     eax, [eax]
-
 
267
        jmp     .hotkey_loop
196
   .no_key.end:
268
.hotkey_found:
-
 
269
        mov     eax, [eax+8]
-
 
270
; put key in buffer for process in slot eax
-
 
271
        mov     edi, hotkey_buffer
-
 
272
@@:
-
 
273
        cmp     dword [edi], 0
-
 
274
        jz      .found_free
-
 
275
        add     edi, 8
-
 
276
        cmp     edi, hotkey_buffer+120*8
-
 
277
        jb      @b
-
 
278
; no free space - replace first entry
-
 
279
        mov     edi, hotkey_buffer
-
 
280
.found_free:
-
 
281
        mov     [edi], eax
-
 
282
        movzx   eax, ch
-
 
283
        cmp     bh, 1
-
 
284
        jnz     @f
-
 
285
        xor     eax, eax
-
 
286
@@:
-
 
287
        mov     [edi+4], ax
-
 
288
        mov     eax, [kb_state]
-
 
289
        mov     [edi+6], ax
-
 
290
        jmp     .exit.irq1
-
 
291
.nohotkey:
197
       cmp   [keyboard_mode],1 ; return scancode
292
       cmp   [keyboard_mode],0 ; return from keymap
198
       jne   .no_scancode
293
       jne   .scancode
-
 
294
        test    bh, bh
-
 
295
        jnz     .exit.irq1
-
 
296
        test    bl, bl
-
 
297
        jz      .exit.irq1
-
 
298
        jmp     .dowrite
-
 
299
.scancode:
199
       mov   [keyboard_mode_sys],1
300
        mov     bl, ch
-
 
301
.dowrite:
200
       movzx eax,byte[0xF400]
302
       movzx eax,byte[0xF400]
201
       cmp   al,120
303
       cmp   al,120
202
       jae   .no_scancode
304
       jae   .exit.irq1
203
       inc   al
305
       inc   eax
204
       mov   [0xF400],al
306
       mov   [0xF400],al
205
       mov   [0xF400+eax],ch
307
       mov   [0xF400+eax],bl
206
   .no_scancode:
-
 
Line 207... Line 308...
207
 
308
 
208
   .exit.irq1:
309
   .exit.irq1:
Line 209... Line 310...
209
       mov   [check_idle_semaphore],5
310
       mov   [check_idle_semaphore],5