Subversion Repositories Kolibri OS

Rev

Rev 425 | Rev 582 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
425 victor 1
$Revision: 431 $
431 serge 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;                                                              ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
5
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
6
;; Distributed under terms of the GNU General Public License    ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
1 ha 9
;// mike.dld [
10
 
11
VKEY_LSHIFT   = 0000000000000001b
12
VKEY_RSHIFT   = 0000000000000010b
13
VKEY_LCONTROL = 0000000000000100b
14
VKEY_RCONTROL = 0000000000001000b
15
VKEY_LALT     = 0000000000010000b
16
VKEY_RALT     = 0000000000100000b
17
VKEY_CAPSLOCK = 0000000001000000b
18
VKEY_NUMLOCK  = 0000000010000000b
19
VKEY_SCRLOCK  = 0000000100000000b
20
 
21
VKEY_SHIFT    = 0000000000000011b
22
VKEY_CONTROL  = 0000000000001100b
23
VKEY_ALT      = 0000000000110000b
24
 
25
uglobal
26
  align 4
27
  kb_state      dd 0
28
  ext_code      db 0
29
 
30
  keyboard_mode db 0
31
  keyboard_data db 0
32
 
33
  altmouseb     db 0
34
  ctrl_alt_del  db 0
35
 
36
  kb_lights     db 0
92 diamond 37
 
38
align 4
39
        hotkey_scancodes        rd      256     ; we have 256 scancodes
40
        hotkey_list             rd      256*4   ; max 256 defined hotkeys
41
        hotkey_buffer           rd      120*2   ; buffer for 120 hotkeys
1 ha 42
endg
43
 
92 diamond 44
iglobal
45
hotkey_tests    dd      hotkey_test0
46
                dd      hotkey_test1
47
                dd      hotkey_test2
48
                dd      hotkey_test3
49
                dd      hotkey_test4
50
hotkey_tests_num = 5
51
endg
52
 
53
hotkey_test0:
54
        test    al, al
55
        setz    al
56
        ret
57
hotkey_test1:
58
        test    al, al
59
        setnp   al
60
        ret
61
hotkey_test2:
62
        cmp     al, 3
63
        setz    al
64
        ret
65
hotkey_test3:
66
        cmp     al, 1
67
        setz    al
68
        ret
69
hotkey_test4:
70
        cmp     al, 2
71
        setz    al
72
        ret
73
 
74
hotkey_do_test:
75
        push    eax
76
        mov     edx, [kb_state]
77
        shr     edx, cl
78
        add     cl, cl
79
        mov     eax, [eax+4]
80
        shr     eax, cl
81
        and     eax, 15
82
        cmp     al, hotkey_tests_num
83
        jae     .fail
84
        xchg    eax, edx
85
        and     al, 3
86
        call    [hotkey_tests + edx*4]
87
        cmp     al, 1
88
        pop     eax
89
        ret
90
.fail:
91
        stc
92
        pop     eax
93
        ret
94
 
1 ha 95
align 4
96
irq1:
164 serge 97
;       save_ring3_context
98
;       mov   ax, os_data
99
;       mov   ds, ax
100
;       mov   es, ax
1 ha 101
 
379 serge 102
       movzx eax,word[TASK_COUNT] ; top window process
380 serge 103
       movzx eax,word[WIN_POS+eax*2]
1 ha 104
       shl   eax,8
380 serge 105
       mov   al,[SLOT_BASE+eax+APPDATA.keyboard_mode]
1 ha 106
       mov   [keyboard_mode],al
107
 
108
       in    al,0x60
109
       mov   [keyboard_data],al
110
 
92 diamond 111
; ch = scancode
112
; cl = ext_code
113
; bh = 0 - normal key
114
; bh = 1 - modifier (Shift/Ctrl/Alt)
115
; bh = 2 - extended code
116
 
1 ha 117
       mov   ch,al
118
       cmp   al,0xE0
119
       je    @f
120
       cmp   al,0xE1
121
       jne   .normal_code
92 diamond 122
   @@:
123
        mov     bh, 2
124
        mov     [ext_code], al
125
        jmp     .writekey
1 ha 126
   .normal_code:
92 diamond 127
        mov     cl, 0
128
        xchg    cl, [ext_code]
1 ha 129
       and   al,0x7F
92 diamond 130
        mov     bh, 1
1 ha 131
   @@: cmp   al,0x2A
132
       jne   @f
133
       cmp   cl,0xE0
92 diamond 134
       je    .writekey
1 ha 135
       mov   eax,VKEY_LSHIFT
92 diamond 136
       jmp   .modifier
1 ha 137
   @@: cmp   al,0x36
138
       jne   @f
139
       cmp   cl,0xE0
92 diamond 140
       je    .writekey
1 ha 141
       mov   eax,VKEY_RSHIFT
92 diamond 142
       jmp   .modifier
1 ha 143
   @@: cmp   al,0x38
144
       jne   @f
92 diamond 145
        mov     eax, VKEY_LALT
146
        test    cl, cl
147
        jz      .modifier
148
        mov     al, VKEY_RALT
149
        jmp     .modifier
1 ha 150
   @@: cmp   al,0x1D
151
       jne   @f
92 diamond 152
        mov     eax, VKEY_LCONTROL
153
        test    cl, cl
154
        jz      .modifier
155
        mov     al, VKEY_RCONTROL
156
        cmp     cl, 0xE0
157
        jz      .modifier
158
        mov     [ext_code], cl
159
        jmp     .writekey
1 ha 160
   @@: cmp   al,0x3A
161
       jne   @f
162
       mov   bl,4
163
       mov   eax,VKEY_CAPSLOCK
164
       jmp   .no_key.xor
165
   @@: cmp   al,0x45
166
       jne   @f
92 diamond 167
        test    cl, cl
168
        jnz     .writekey
1 ha 169
       mov   bl,2
170
       mov   eax,VKEY_NUMLOCK
171
       jmp   .no_key.xor
172
   @@: cmp   al,0x46
173
       jne   @f
174
       mov   bl,1
175
       mov   eax,VKEY_SCRLOCK
176
       jmp   .no_key.xor
177
   @@:
92 diamond 178
       test  ch,ch
179
       js    .writekey
1 ha 180
       movzx eax,ch              ; plain key
181
       mov   bl,[keymap+eax]
182
       mov   edx,[kb_state]
183
       test  dl,VKEY_CONTROL     ; ctrl alt del
184
       jz    .noctrlaltdel
185
       test  dl,VKEY_ALT
186
       jz    .noctrlaltdel
92 diamond 187
       cmp   ch,53h
1 ha 188
       jne   .noctrlaltdel
189
       mov   [ctrl_alt_del],1
190
   .noctrlaltdel:
191
       test  dl,VKEY_CONTROL     ; ctrl on ?
192
       jz    @f
193
       sub   bl,0x60
194
   @@: test  dl,VKEY_SHIFT       ; shift on ?
195
       jz    @f
196
       mov   bl,[keymap_shift+eax]
197
   @@: test  dl,VKEY_ALT         ; alt on ?
198
       jz    @f
199
       mov   bl,[keymap_alt+eax]
200
   @@:
92 diamond 201
        mov     bh, 0
202
        jmp     .writekey
203
.modifier:
204
        test    ch, ch
205
        js      .modifier.up
206
        or      [kb_state], eax
207
        jmp     .writekey
208
.modifier.up:
209
        not     eax
210
        and     [kb_state], eax
211
        jmp     .writekey
212
.no_key.xor:
213
        mov     bh, 0
214
        test    ch, ch
215
        js      .writekey
216
        xor     [kb_state], eax
217
        xor     [kb_lights], bl
218
        call    set_lights
219
 
220
.writekey:
221
; test for system hotkeys
222
        movzx   eax, ch
223
        cmp     bh, 1
224
        ja      .nohotkey
225
        jb      @f
226
        xor     eax, eax
227
@@:
228
        mov     eax, [hotkey_scancodes + eax*4]
229
.hotkey_loop:
230
        test    eax, eax
231
        jz      .nohotkey
232
        mov     cl, 0
233
        call    hotkey_do_test
234
        jc      .hotkey_cont
235
        mov     cl, 2
236
        call    hotkey_do_test
237
        jc      .hotkey_cont
238
        mov     cl, 4
239
        call    hotkey_do_test
240
        jnc     .hotkey_found
241
.hotkey_cont:
242
        mov     eax, [eax]
243
        jmp     .hotkey_loop
244
.hotkey_found:
245
        mov     eax, [eax+8]
246
; put key in buffer for process in slot eax
247
        mov     edi, hotkey_buffer
248
@@:
249
        cmp     dword [edi], 0
250
        jz      .found_free
251
        add     edi, 8
252
        cmp     edi, hotkey_buffer+120*8
253
        jb      @b
254
; no free space - replace first entry
255
        mov     edi, hotkey_buffer
256
.found_free:
257
        mov     [edi], eax
258
        movzx   eax, ch
259
        cmp     bh, 1
260
        jnz     @f
261
        xor     eax, eax
262
@@:
263
        mov     [edi+4], ax
264
        mov     eax, [kb_state]
265
        mov     [edi+6], ax
266
        jmp     .exit.irq1
267
.nohotkey:
1 ha 268
       cmp   [keyboard_mode],0 ; return from keymap
92 diamond 269
       jne   .scancode
270
        test    bh, bh
271
        jnz     .exit.irq1
272
        test    bl, bl
273
        jz      .exit.irq1
274
        jmp     .dowrite
275
.scancode:
276
        mov     bl, ch
277
.dowrite:
381 serge 278
       movzx eax,byte[KEY_COUNT]
1 ha 279
       cmp   al,120
92 diamond 280
       jae   .exit.irq1
281
       inc   eax
381 serge 282
       mov   [KEY_COUNT],al
283
       mov   [KEY_COUNT+eax],bl
1 ha 284
 
285
   .exit.irq1:
286
       mov   [check_idle_semaphore],5
287
 
164 serge 288
;       mov   al,0x20                  ; ready for next irq
289
;       out   0x20,al
1 ha 290
 
164 serge 291
;       restore_ring3_context
292
;       iret
293
        ret
1 ha 294
 
295
set_lights:
296
       mov   al,0xED
297
       call  kb_write
298
       mov   al,[kb_lights]
299
       call  kb_write
300
       ret
301
 
302
;// mike.dld ]