Subversion Repositories Kolibri OS

Rev

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

Rev 1376 Rev 2382
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line -...
8
$Revision: 1376 $
-
 
9
 
-
 
10
 
8
$Revision: 2382 $
11
;// mike.dld [
9
 
12
 
10
 
13
VKEY_LSHIFT   = 0000000000000001b
11
VKEY_LSHIFT   = 0000000000000001b
14
VKEY_RSHIFT   = 0000000000000010b
12
VKEY_RSHIFT   = 0000000000000010b
Line 49... Line 47...
49
		dd	hotkey_test2
47
                dd      hotkey_test2
50
		dd	hotkey_test3
48
                dd      hotkey_test3
51
		dd	hotkey_test4
49
                dd      hotkey_test4
52
hotkey_tests_num = 5
50
hotkey_tests_num = 5
53
endg
51
endg
54
 
-
 
-
 
52
;---------------------------------------------------------------------
55
hotkey_test0:
53
hotkey_test0:
56
	test	al, al
54
        test    al, al
57
	setz	al
55
        setz    al
58
	ret
56
        ret
-
 
57
;---------------------------------------------------------------------
59
hotkey_test1:
58
hotkey_test1:
60
	test	al, al
59
        test    al, al
61
	setnp	al
60
        setnp   al
62
	ret
61
        ret
-
 
62
;---------------------------------------------------------------------
63
hotkey_test2:
63
hotkey_test2:
64
	cmp	al, 3
64
        cmp     al, 3
65
	setz	al
65
        setz    al
66
	ret
66
        ret
-
 
67
;---------------------------------------------------------------------
67
hotkey_test3:
68
hotkey_test3:
68
	cmp	al, 1
69
        cmp     al, 1
69
	setz	al
70
        setz    al
70
	ret
71
        ret
-
 
72
;---------------------------------------------------------------------
71
hotkey_test4:
73
hotkey_test4:
72
	cmp	al, 2
74
        cmp     al, 2
73
	setz	al
75
        setz    al
74
	ret
76
        ret
75
 
-
 
-
 
77
;---------------------------------------------------------------------
76
hotkey_do_test:
78
hotkey_do_test:
77
	push	eax
79
        push    eax
78
	mov	edx, [kb_state]
80
        mov     edx, [kb_state]
79
	shr	edx, cl
81
        shr     edx, cl
80
	add	cl, cl
82
        add     cl, cl
81
	mov	eax, [eax+4]
83
        mov     eax, [eax+4]
82
	shr	eax, cl
84
        shr     eax, cl
83
	and	eax, 15
85
        and     eax, 15
84
	cmp	al, hotkey_tests_num
86
        cmp     al, hotkey_tests_num
85
	jae	.fail
87
        jae     .fail
-
 
88
        
86
	xchg	eax, edx
89
        xchg    eax, edx
87
	and	al, 3
90
        and     al, 3
88
	call	[hotkey_tests + edx*4]
91
        call    [hotkey_tests + edx*4]
89
	cmp	al, 1
92
        cmp     al, 1
90
	pop	eax
93
        pop     eax
91
	ret
94
        ret
-
 
95
;--------------------------------------
92
.fail:
96
.fail:
93
	stc
97
        stc
94
	pop	eax
98
        pop     eax
95
	ret
99
        ret
-
 
100
;---------------------------------------------------------------------
-
 
101
align 4
-
 
102
set_keyboard_data:
-
 
103
        movzx   eax, word[TASK_COUNT]; top window process
-
 
104
        movzx   eax, word[WIN_POS+eax*2]
-
 
105
        shl     eax, 8
-
 
106
        mov     al, [SLOT_BASE+eax+APPDATA.keyboard_mode]
-
 
107
        mov     [keyboard_mode], al
-
 
108
        
-
 
109
        mov     eax, ecx
Line -... Line 110...
-
 
110
        
-
 
111
        push    ebx esi edi ebp
-
 
112
        call    send_scancode
-
 
113
        pop     ebp edi esi ebx
-
 
114
        ret
96
 
115
;---------------------------------------------------------------------
97
align 4
116
align 4
98
irq1:
-
 
99
;       save_ring3_context
-
 
100
;       mov   ax, os_data
-
 
101
;       mov   ds, ax
-
 
102
;       mov   es, ax
-
 
103
 
117
irq1:
104
       movzx eax,word[TASK_COUNT] ; top window process
118
        movzx   eax, word[TASK_COUNT]; top window process
105
       movzx eax,word[WIN_POS+eax*2]
119
        movzx   eax, word[WIN_POS+eax*2]
106
       shl   eax,8
120
        shl     eax, 8
107
       mov   al,[SLOT_BASE+eax+APPDATA.keyboard_mode]
121
        mov     al, [SLOT_BASE+eax+APPDATA.keyboard_mode]
Line 108... Line 122...
108
       mov   [keyboard_mode],al
122
        mov     [keyboard_mode], al
-
 
123
        
-
 
124
        in      al, 0x60
109
 
125
;--------------------------------------
110
       in    al,0x60
-
 
111
       mov   [keyboard_data],al
126
send_scancode:
112
 
127
        mov     [keyboard_data], al
113
; ch = scancode
128
; ch = scancode
114
; cl = ext_code
129
; cl = ext_code
115
; bh = 0 - normal key
130
; bh = 0 - normal key
116
; bh = 1 - modifier (Shift/Ctrl/Alt)
-
 
117
; bh = 2 - extended code
131
; bh = 1 - modifier (Shift/Ctrl/Alt)
118
 
132
; bh = 2 - extended code
119
       mov   ch,al
133
        mov     ch, al
-
 
134
        cmp     al, 0xE0
120
       cmp   al,0xE0
135
        je      @f
121
       je    @f
136
        
122
       cmp   al,0xE1
137
        cmp     al, 0xE1
123
       jne   .normal_code
138
        jne     .normal_code
124
   @@:
139
@@:
125
	mov	bh, 2
140
        mov     bh, 2
-
 
141
        mov     [ext_code], al
126
	mov	[ext_code], al
142
        jmp     .writekey
127
	jmp	.writekey
143
;--------------------------------------
128
   .normal_code:
144
.normal_code:
129
	mov	cl, 0
145
        mov     cl, 0
130
	xchg	cl, [ext_code]
146
        xchg    cl, [ext_code]
-
 
147
        and     al, 0x7F
131
       and   al,0x7F
148
        mov     bh, 1
132
	mov	bh, 1
149
@@:
-
 
150
        cmp     al, 0x2A
133
   @@: cmp   al,0x2A
151
        jne     @f
134
       jne   @f
152
        
-
 
153
        cmp     cl, 0xE0
135
       cmp   cl,0xE0
154
        je      .writekey
136
       je    .writekey
155
        
-
 
156
        mov     eax, VKEY_LSHIFT
-
 
157
        jmp     .modifier
137
       mov   eax,VKEY_LSHIFT
158
;--------------------------------------
138
       jmp   .modifier
159
@@:
-
 
160
        cmp     al, 0x36
139
   @@: cmp   al,0x36
161
        jne     @f
140
       jne   @f
162
        
-
 
163
        cmp     cl, 0xE0
141
       cmp   cl,0xE0
164
        je      .writekey
142
       je    .writekey
165
        
-
 
166
        mov     eax, VKEY_RSHIFT
-
 
167
        jmp     .modifier
143
       mov   eax,VKEY_RSHIFT
168
;--------------------------------------
144
       jmp   .modifier
169
@@:
-
 
170
        cmp     al, 0x38
145
   @@: cmp   al,0x38
171
        jne     @f
146
       jne   @f
172
        
147
	mov	eax, VKEY_LALT
173
        mov     eax, VKEY_LALT
-
 
174
        test    cl, cl
148
	test	cl, cl
175
        jz      .modifier
149
	jz	.modifier
176
        
-
 
177
        mov     al, VKEY_RALT
-
 
178
        jmp     .modifier
150
	mov	al, VKEY_RALT
179
;--------------------------------------
151
	jmp	.modifier
180
@@:
-
 
181
        cmp     al, 0x1D
152
   @@: cmp   al,0x1D
182
        jne     @f
153
       jne   @f
183
        
154
	mov	eax, VKEY_LCONTROL
184
        mov     eax, VKEY_LCONTROL
-
 
185
        test    cl, cl
155
	test	cl, cl
186
        jz      .modifier
156
	jz	.modifier
187
        
157
	mov	al, VKEY_RCONTROL
188
        mov     al, VKEY_RCONTROL
-
 
189
        cmp     cl, 0xE0
158
	cmp	cl, 0xE0
190
        jz      .modifier
159
	jz	.modifier
191
        
-
 
192
        mov     [ext_code], cl
-
 
193
        jmp     .writekey
160
	mov	[ext_code], cl
194
;--------------------------------------
161
	jmp	.writekey
195
@@:
-
 
196
        cmp     al, 0x3A
162
   @@: cmp   al,0x3A
197
        jne     @f
163
       jne   @f
198
        
164
       mov   bl,4
199
        mov     bl, 4
-
 
200
        mov     eax, VKEY_CAPSLOCK
-
 
201
        jmp     .no_key.xor
165
       mov   eax,VKEY_CAPSLOCK
202
;--------------------------------------
166
       jmp   .no_key.xor
203
@@:
167
   @@: cmp   al,0x45
204
        cmp     al, 0x45
168
       jne   @f
205
        jne     @f
-
 
206
        test    cl, cl
169
	test	cl, cl
207
        jnz     .writekey
170
	jnz	.writekey
208
        
171
       mov   bl,2
209
        mov     bl, 2
-
 
210
        mov     eax, VKEY_NUMLOCK
-
 
211
        jmp     .no_key.xor
172
       mov   eax,VKEY_NUMLOCK
212
;--------------------------------------
173
       jmp   .no_key.xor
213
@@:
-
 
214
        cmp     al, 0x46
174
   @@: cmp   al,0x46
215
        jne     @f
175
       jne   @f
216
        
176
       mov   bl,1
217
        mov     bl, 1
-
 
218
        mov     eax, VKEY_SCRLOCK
177
       mov   eax,VKEY_SCRLOCK
219
        jmp     .no_key.xor
-
 
220
;--------------------------------------
178
       jmp   .no_key.xor
221
@@:
179
   @@:
222
        xor     ebx, ebx
-
 
223
        test    ch, ch
180
       test  ch,ch
224
        js      .writekey
181
       js    .writekey
225
        
182
       movzx eax,ch		 ; plain key
226
        movzx   eax, ch          ; plain key
183
       mov   bl,[keymap+eax]
227
        mov     bl, [keymap+eax]
184
       mov   edx,[kb_state]
228
        mov     edx, [kb_state]
-
 
229
        test    dl, VKEY_CONTROL ; ctrl alt del
185
       test  dl,VKEY_CONTROL	 ; ctrl alt del
230
        jz      .noctrlaltdel
186
       jz    .noctrlaltdel
231
        
-
 
232
        test    dl, VKEY_ALT
187
       test  dl,VKEY_ALT
233
        jz      .noctrlaltdel
188
       jz    .noctrlaltdel
234
        
-
 
235
        cmp     ch, 53h
189
       cmp   ch,53h
236
        jne     .noctrlaltdel
190
       jne   .noctrlaltdel
237
        
191
       mov   [ctrl_alt_del],1
238
        mov     [ctrl_alt_del], 1
192
   .noctrlaltdel:
239
.noctrlaltdel:
-
 
240
        test    dl, VKEY_CONTROL ; ctrl on ?
193
       test  dl,VKEY_CONTROL	 ; ctrl on ?
241
        jz      @f
-
 
242
        
-
 
243
        sub     bl, 0x60
-
 
244
@@:
-
 
245
        test    dl, VKEY_CAPSLOCK        ; caps lock on ?
194
       jz    @f
246
        jz      .no_caps_lock
-
 
247
        
-
 
248
        test    dl, VKEY_SHIFT   ; shift on ?
-
 
249
        jz      .keymap_shif
-
 
250
        
-
 
251
        jmp     @f
-
 
252
;--------------------------------------
195
       sub   bl,0x60
253
.no_caps_lock:
-
 
254
        test    dl, VKEY_SHIFT   ; shift on ?
196
   @@: test  dl,VKEY_SHIFT	 ; shift on ?
255
        jz      @f
-
 
256
.keymap_shif:   
197
       jz    @f
257
        mov     bl, [keymap_shift+eax]
198
       mov   bl,[keymap_shift+eax]
258
@@:
-
 
259
        test    dl, VKEY_ALT     ; alt on ?
199
   @@: test  dl,VKEY_ALT	 ; alt on ?
260
        jz      @f
200
       jz    @f
261
        
201
       mov   bl,[keymap_alt+eax]
-
 
202
   @@:
262
        mov     bl, [keymap_alt+eax]
-
 
263
@@:
203
	mov	bh, 0
264
        jmp     .writekey
204
	jmp	.writekey
265
;--------------------------------------
205
.modifier:
266
.modifier:
206
	test	ch, ch
267
        test    ch, ch
207
	js	.modifier.up
268
        js      .modifier.up
-
 
269
        or      [kb_state], eax
208
	or	[kb_state], eax
270
        jmp     .writekey
209
	jmp	.writekey
271
;--------------------------------------
210
.modifier.up:
272
.modifier.up:
211
	not	eax
273
        not     eax
-
 
274
        and     [kb_state], eax
212
	and	[kb_state], eax
275
        jmp     .writekey
213
	jmp	.writekey
276
;--------------------------------------
214
.no_key.xor:
277
.no_key.xor:
215
	mov	bh, 0
278
        mov     bh, 0
-
 
279
        test    ch, ch
216
	test	ch, ch
280
        js      .writekey
217
	js	.writekey
281
        
218
	xor	[kb_state], eax
282
        xor     [kb_state], eax
219
	xor	[kb_lights], bl
-
 
220
	call	set_lights
283
        xor     [kb_lights], bl
221
 
284
        call    set_lights
222
.writekey:
285
.writekey:
223
; test for system hotkeys
286
; test for system hotkeys
224
	movzx	eax, ch
287
        movzx   eax, ch
225
	cmp	bh, 1
288
        cmp     bh, 1
-
 
289
        ja      .nohotkey
226
	ja	.nohotkey
290
        jb      @f
227
	jb	@f
291
        
228
	xor	eax, eax
292
        xor     eax, eax
229
@@:
293
@@:
230
	mov	eax, [hotkey_scancodes + eax*4]
294
        mov     eax, [hotkey_scancodes + eax*4]
231
.hotkey_loop:
295
.hotkey_loop:
-
 
296
        test    eax, eax
232
	test	eax, eax
297
        jz      .nohotkey
233
	jz	.nohotkey
298
        
234
	mov	cl, 0
299
        mov     cl, 0
-
 
300
        call    hotkey_do_test
235
	call	hotkey_do_test
301
        jc      .hotkey_cont
236
	jc	.hotkey_cont
302
        
237
	mov	cl, 2
303
        mov     cl, 2
-
 
304
        call    hotkey_do_test
238
	call	hotkey_do_test
305
        jc      .hotkey_cont
239
	jc	.hotkey_cont
306
        
240
	mov	cl, 4
307
        mov     cl, 4
241
	call	hotkey_do_test
308
        call    hotkey_do_test
242
	jnc	.hotkey_found
309
        jnc     .hotkey_found
243
.hotkey_cont:
310
.hotkey_cont:
-
 
311
        mov     eax, [eax]
244
	mov	eax, [eax]
312
        jmp     .hotkey_loop
245
	jmp	.hotkey_loop
313
;--------------------------------------
246
.hotkey_found:
314
.hotkey_found:
247
	mov	eax, [eax+8]
315
        mov     eax, [eax+8]
248
; put key in buffer for process in slot eax
316
; put key in buffer for process in slot eax
249
	mov	edi, hotkey_buffer
317
        mov     edi, hotkey_buffer
250
@@:
318
@@:
-
 
319
        cmp     dword [edi], 0
251
	cmp	dword [edi], 0
320
        jz      .found_free
252
	jz	.found_free
321
        
253
	add	edi, 8
322
        add     edi, 8
254
	cmp	edi, hotkey_buffer+120*8
323
        cmp     edi, hotkey_buffer+120*8
255
	jb	@b
324
        jb      @b
256
; no free space - replace first entry
325
; no free space - replace first entry
257
	mov	edi, hotkey_buffer
326
        mov     edi, hotkey_buffer
258
.found_free:
327
.found_free:
259
	mov	[edi], eax
328
        mov     [edi], eax
260
	movzx	eax, ch
329
        movzx   eax, ch
-
 
330
        cmp     bh, 1
261
	cmp	bh, 1
331
        jnz     @f
262
	jnz	@f
332
        
263
	xor	eax, eax
333
        xor     eax, eax
264
@@:
334
@@:
265
	mov	[edi+4], ax
335
        mov     [edi+4], ax
266
	mov	eax, [kb_state]
336
        mov     eax, [kb_state]
-
 
337
        mov     [edi+6], ax
267
	mov	[edi+6], ax
338
        jmp     .exit.irq1
268
	jmp	.exit.irq1
339
;--------------------------------------
269
.nohotkey:
340
.nohotkey:
-
 
341
        cmp     [keyboard_mode], 0; return from keymap
270
       cmp   [keyboard_mode],0 ; return from keymap
342
        jne     .scancode
271
       jne   .scancode
343
        
-
 
344
        test    bh, bh
272
	test	bh, bh
345
        jnz     .exit.irq1
273
	jnz	.exit.irq1
346
        
Line 274... Line -...
274
	test	bl, bl
-
 
275
	jz	.exit.irq1
347
        test    bl, bl
276
 
348
        jz      .exit.irq1
-
 
349
 
277
;.........................Part1 Start.......Code by Rus, optimize by Ghost...................................
350
        test    [kb_state], VKEY_NUMLOCK
278
	test  [kb_state], VKEY_NUMLOCK
351
        jz      .dowrite
Line 279... Line 352...
279
	jz     .dowrite
352
        
280
        cmp     cl, 0xE0
353
        cmp     cl, 0xE0
-
 
354
        jz      .dowrite
281
        jz      .dowrite
355
        
282
 
356
        cmp     ch, 55
-
 
357
        jnz     @f
283
	cmp	ch, 55
358
        
284
	jnz	@f
359
        mov     bl, 0x2A        ;*
285
	mov	bl, 0x2A	;*
360
        jmp     .dowrite
-
 
361
;--------------------------------------
286
	jmp	.dowrite
362
@@:
287
      @@:
363
        cmp     ch, 71
288
	cmp	ch, 71
364
        jb      .dowrite
289
	jb	.dowrite
365
        
290
	cmp	ch, 83
366
        cmp     ch, 83
291
	ja	.dowrite
-
 
292
	;push    eax
-
 
293
	movzx	eax, ch
-
 
294
	mov	bl, [numlock_map + eax - 71]
-
 
295
	;pop     eax
367
        ja      .dowrite
-
 
368
        
296
 
369
        movzx   eax, ch
297
;.........................Part1 End.................................................
370
        mov     bl, [numlock_map + eax - 71]
298
 
371
        jmp     .dowrite
299
	jmp	.dowrite
372
;--------------------------------------
300
.scancode:
373
.scancode:
301
	mov	bl, ch
374
        mov     bl, ch
302
.dowrite:
375
.dowrite:
303
       movzx eax,byte[KEY_COUNT]
376
        movzx   eax, byte[KEY_COUNT]
304
       cmp   al,120
377
        cmp     al, 120
305
       jae   .exit.irq1
-
 
306
       inc   eax
378
        jae     .exit.irq1
307
       mov   [KEY_COUNT],al
379
        inc     eax
308
       mov   [KEY_COUNT+eax],bl
-
 
309
 
-
 
310
   .exit.irq1:
-
 
311
       mov   [check_idle_semaphore],5
-
 
312
 
-
 
313
;       mov   al,0x20                  ; ready for next irq
-
 
314
;       out   0x20,al
380
        mov     [KEY_COUNT], al
315
 
-
 
-
 
381
        mov     [KEY_COUNT+eax], bl
316
;       restore_ring3_context
382
.exit.irq1:
317
;       iret
383
        mov     [check_idle_semaphore], 5
318
	ret
384
        ret
319
 
385
;---------------------------------------------------------------------
320
set_lights:
386
set_lights:
321
       mov   al,0xED
387
        mov     al, 0xED
322
       call  kb_write
-
 
323
       mov   al,[kb_lights]
-
 
324
       call  kb_write
388
        call    kb_write
325
       ret
389
        mov     al, [kb_lights]
326
 
390
        call    kb_write
327
;// mike.dld ]
391
        ret
328
;..........................Part2 Start.......Code by Rus.......................................
392
;---------------------------------------------------------------------
329
numlock_map:
393
numlock_map:
Line 338... Line 402...
338
    db	 0x31	;Num 1
402
    db   0x31   ;Num 1
339
    db	 0x32	;Num 2
403
    db   0x32   ;Num 2
340
    db	 0x33	;Num 3
404
    db   0x33   ;Num 3
341
    db	 0x30	;Num 0
405
    db   0x30   ;Num 0
342
    db	 0x2E	;Num .
406
    db   0x2E   ;Num .
343
;..........................Part2 End................................................
-
 
344
407
;---------------------------------------------------------------------
-
 
408