Subversion Repositories Kolibri OS

Rev

Rev 4263 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1547 Asper 1
;
2549 leency 2
;   ZKEY. Version 0.51.
1547 Asper 3
;   Virtual keyboard for KolibriOS.
4
;
5
;   Author:         Asper
6
;   Date of issue:  26.08.2009
7
;   Compiler:       FASM
8
;   Target:         KolibriOS
9
;
10
 
11
use32
9971 Doczom 12
        org     0x0
1547 Asper 13
 
9971 Doczom 14
        db     'MENUET01'
15
        dd     1                ; version
16
        dd     STARTAPP         ; program start
17
        dd     I_END            ; program image size
18
        dd     MEM              ; size memory for program
19
        dd     STACKTOP         ; base stack pointer
20
        dd     0
21
        dd     0
1547 Asper 22
 
9971 Doczom 23
include '../../../macros.inc'
1728 clevermous 24
include "ASPAPI.INC"
1547 Asper 25
 
26
N_KEYCOLOR equ 0x00677889 ; Normal button color
27
C_KEYCOLOR equ 0x00344556 ; Control button color
28
L_KEYCOLOR equ 0x00258778 ; Lock button color
29
TEXTCOLOR  equ 0x00FFFFFF ; Button caption color
30
 
4263 0CodErr 31
ASCII_KEYMAP_SIZE equ 128
1547 Asper 32
 
33
STARTAPP:
9971 Doczom 34
        mov     ecx, 1     ; to send scancodes.
35
        call    set_keyboard_mode
1547 Asper 36
 
9971 Doczom 37
        call    reload_ascii_keymap
38
        call    draw_window
39
        jmp     get_zkey_window_slot_number
1547 Asper 40
 
41
draw_window:
9971 Doczom 42
  test   byte [red_type], 1
43
  jnz    @f
44
  test   byte [red_type], 2
45
  jnz    .draw_switch_button
2549 leency 46
  start_draw_window 100,370,600,210,0x14224466,labelt
1547 Asper 47
 
9971 Doczom 48
  stdcall draw_button, 15,50,23,20,2,N_KEYCOLOR,keyText,3,TEXTCOLOR             ; Esc
1547 Asper 49
 
9971 Doczom 50
  stdcall draw_button, 70,50,23,20,3,N_KEYCOLOR,keyText+3,2,TEXTCOLOR   ; F1
51
  stdcall draw_button, 95,50,23,20,4,N_KEYCOLOR,keyText+5,2,TEXTCOLOR   ; F2
52
  stdcall draw_button, 120,50,23,20,5,N_KEYCOLOR,keyText+7,2,TEXTCOLOR  ; F3
53
  stdcall draw_button, 145,50,23,20,6,N_KEYCOLOR,keyText+9,2,TEXTCOLOR  ; F4
1547 Asper 54
 
55
  stdcall draw_button, 183,50,23,20,7,N_KEYCOLOR,keyText+11,2,TEXTCOLOR ; F5
56
  stdcall draw_button, 208,50,23,20,8,N_KEYCOLOR,keyText+13,2,TEXTCOLOR ; F6
57
  stdcall draw_button, 233,50,23,20,9,N_KEYCOLOR,keyText+15,2,TEXTCOLOR ; F7
58
  stdcall draw_button, 258,50,23,20,10,N_KEYCOLOR,keyText+17,2,TEXTCOLOR ; F8
59
 
60
  stdcall draw_button, 296,50,23,20,11,N_KEYCOLOR,keyText+19,2,TEXTCOLOR ; F9
61
  stdcall draw_button, 321,50,23,20,12,N_KEYCOLOR,keyText+21,3,TEXTCOLOR ; F10
62
  stdcall draw_button, 346,50,23,20,13,N_KEYCOLOR,keyText+24,3,TEXTCOLOR ; F11
63
  stdcall draw_button, 371,50,23,20,14,N_KEYCOLOR,keyText+27,3,TEXTCOLOR ; F12
64
@@:
65
  stdcall draw_button, 15,80,23,20,15,N_KEYCOLOR,ascii_keymap+41,1,TEXTCOLOR ;keyText+30,2,TEXTCOLOR     ; ~
66
  stdcall draw_button, 40,80,23,20,16,N_KEYCOLOR,ascii_keymap+2,1,TEXTCOLOR ;keyText+32,2,TEXTCOLOR      ; 1!
67
  stdcall draw_button, 65,80,23,20,17,N_KEYCOLOR,ascii_keymap+3,1,TEXTCOLOR ;keyText+34,2,TEXTCOLOR      ; 2@
68
  stdcall draw_button, 90,80,23,20,18,N_KEYCOLOR,ascii_keymap+4,1,TEXTCOLOR ;keyText+36,2,TEXTCOLOR      ; 3#
69
  stdcall draw_button, 115,80,23,20,19,N_KEYCOLOR,ascii_keymap+5,1,TEXTCOLOR ;keyText+38,2,TEXTCOLOR     ; 4$
70
  stdcall draw_button, 140,80,23,20,20,N_KEYCOLOR,ascii_keymap+6,1,TEXTCOLOR ;keyText+40,2,TEXTCOLOR     ; 5%
71
  stdcall draw_button, 165,80,23,20,21,N_KEYCOLOR,ascii_keymap+7,1,TEXTCOLOR ;keyText+42,2,TEXTCOLOR     ; 6^
72
  stdcall draw_button, 190,80,23,20,22,N_KEYCOLOR,ascii_keymap+8,1,TEXTCOLOR ;keyText+44,2,TEXTCOLOR     ; 7&
73
  stdcall draw_button, 215,80,23,20,23,N_KEYCOLOR,ascii_keymap+9,1,TEXTCOLOR ;keyText+46,2,TEXTCOLOR     ; 8*
74
  stdcall draw_button, 240,80,23,20,24,N_KEYCOLOR,ascii_keymap+10,1,TEXTCOLOR ;keyText+48,2,TEXTCOLOR    ; 9(
75
  stdcall draw_button, 265,80,23,20,25,N_KEYCOLOR,ascii_keymap+11,1,TEXTCOLOR ;keyText+50,2,TEXTCOLOR    ; 0)
76
  stdcall draw_button, 290,80,23,20,26,N_KEYCOLOR,ascii_keymap+12,1,TEXTCOLOR ;keyText+52,2,TEXTCOLOR    ; -_
77
  stdcall draw_button, 315,80,23,20,27,N_KEYCOLOR,ascii_keymap+13,1,TEXTCOLOR ;keyText+54,2,TEXTCOLOR    ; =+
78
  stdcall draw_button, 340,80,23,20,28,N_KEYCOLOR,ascii_keymap+43,1,TEXTCOLOR ;keyText+56,2,TEXTCOLOR    ; \|
79
  stdcall draw_button, 365,80,30,20,29,N_KEYCOLOR,keyText+58,4,TEXTCOLOR ; bksp
80
 
9971 Doczom 81
  stdcall draw_button, 15 ,103,33,20,30,N_KEYCOLOR,keyText+62,3,TEXTCOLOR       ; Tab
1547 Asper 82
  stdcall draw_button, 50 ,103,23,20,31,N_KEYCOLOR,ascii_keymap+16,1,TEXTCOLOR ;keyText+65,2,TEXTCOLOR   ; Q
83
  stdcall draw_button, 75 ,103,23,20,32,N_KEYCOLOR,ascii_keymap+17,1,TEXTCOLOR ;keyText+67,2,TEXTCOLOR   ; W
84
  stdcall draw_button, 100,103,23,20,33,N_KEYCOLOR,ascii_keymap+18,1,TEXTCOLOR ;keyText+69,2,TEXTCOLOR   ; E
85
  stdcall draw_button, 125,103,23,20,34,N_KEYCOLOR,ascii_keymap+19,1,TEXTCOLOR ;keyText+71,2,TEXTCOLOR   ; R
86
  stdcall draw_button, 150,103,23,20,35,N_KEYCOLOR,ascii_keymap+20,1,TEXTCOLOR ;keyText+73,2,TEXTCOLOR   ; T
87
  stdcall draw_button, 175,103,23,20,36,N_KEYCOLOR,ascii_keymap+21,1,TEXTCOLOR ;keyText+75,2,TEXTCOLOR   ; Y
88
  stdcall draw_button, 200,103,23,20,37,N_KEYCOLOR,ascii_keymap+22,1,TEXTCOLOR ;keyText+77,2,TEXTCOLOR   ; U
89
  stdcall draw_button, 225,103,23,20,38,N_KEYCOLOR,ascii_keymap+23,1,TEXTCOLOR ;keyText+79,2,TEXTCOLOR   ; I
90
  stdcall draw_button, 250,103,23,20,39,N_KEYCOLOR,ascii_keymap+24,1,TEXTCOLOR ;keyText+81,2,TEXTCOLOR   ; O
91
  stdcall draw_button, 275,103,23,20,40,N_KEYCOLOR,ascii_keymap+25,1,TEXTCOLOR ;keyText+83,2,TEXTCOLOR   ; P
92
  stdcall draw_button, 300,103,23,20,41,N_KEYCOLOR,ascii_keymap+26,1,TEXTCOLOR ;keyText+85,3,TEXTCOLOR   ; [{
93
  stdcall draw_button, 325,103,23,20,42,N_KEYCOLOR,ascii_keymap+27,1,TEXTCOLOR ;keyText+88,3,TEXTCOLOR   ; ]}
9971 Doczom 94
  stdcall draw_button, 350,103,45,43,43,N_KEYCOLOR,keyText+91,5,TEXTCOLOR       ; Enter
1547 Asper 95
 
9971 Doczom 96
  stdcall draw_button, 15 ,126,43,20,44,L_KEYCOLOR,keyText+96 ,4,TEXTCOLOR      ; lock
1547 Asper 97
  stdcall draw_button, 60 ,126,23,20,45,N_KEYCOLOR,ascii_keymap+30,1,TEXTCOLOR ;keyText+100,2,TEXTCOLOR  ; A
98
  stdcall draw_button, 85 ,126,23,20,46,N_KEYCOLOR,ascii_keymap+31,1,TEXTCOLOR ;keyText+102,2,TEXTCOLOR  ; S
99
  stdcall draw_button, 110,126,23,20,47,N_KEYCOLOR,ascii_keymap+32,1,TEXTCOLOR ;keyText+104,2,TEXTCOLOR  ; D
100
  stdcall draw_button, 135,126,23,20,48,N_KEYCOLOR,ascii_keymap+33,1,TEXTCOLOR ;keyText+106,2,TEXTCOLOR  ; F
101
  stdcall draw_button, 160,126,23,20,49,N_KEYCOLOR,ascii_keymap+34,1,TEXTCOLOR ;keyText+108,2,TEXTCOLOR  ; G
102
  stdcall draw_button, 185,126,23,20,50,N_KEYCOLOR,ascii_keymap+35,1,TEXTCOLOR ;keyText+110,2,TEXTCOLOR  ; H
103
  stdcall draw_button, 210,126,23,20,51,N_KEYCOLOR,ascii_keymap+36,1,TEXTCOLOR ;keyText+112,2,TEXTCOLOR  ; J
104
  stdcall draw_button, 235,126,23,20,52,N_KEYCOLOR,ascii_keymap+37,1,TEXTCOLOR ;keyText+114,2,TEXTCOLOR  ; K
105
  stdcall draw_button, 260,126,23,20,53,N_KEYCOLOR,ascii_keymap+38,1,TEXTCOLOR ;keyText+116,2,TEXTCOLOR  ; L
106
  stdcall draw_button, 285,126,23,20,54,N_KEYCOLOR,ascii_keymap+39,1,TEXTCOLOR ;keyText+118,3,TEXTCOLOR  ; ;:
107
  stdcall draw_button, 310,126,23,20,55,N_KEYCOLOR,ascii_keymap+40,1,TEXTCOLOR ;keyText+121,3,TEXTCOLOR  ; '"
108
 
9971 Doczom 109
  stdcall draw_button, 15 ,149,53,20,56,C_KEYCOLOR,keyText+124,5,TEXTCOLOR      ; Shift
1547 Asper 110
  stdcall draw_button, 70 ,149,23,20,57,N_KEYCOLOR,ascii_keymap+44,1,TEXTCOLOR ;keyText+129,2,TEXTCOLOR  ; Z
111
  stdcall draw_button, 95 ,149,23,20,58,N_KEYCOLOR,ascii_keymap+45,1,TEXTCOLOR ;keyText+131,2,TEXTCOLOR  ; X
112
  stdcall draw_button, 120,149,23,20,59,N_KEYCOLOR,ascii_keymap+46,1,TEXTCOLOR ;keyText+133,2,TEXTCOLOR  ; C
113
  stdcall draw_button, 145,149,23,20,60,N_KEYCOLOR,ascii_keymap+47,1,TEXTCOLOR ;keyText+135,2,TEXTCOLOR  ; V
114
  stdcall draw_button, 170,149,23,20,61,N_KEYCOLOR,ascii_keymap+48,1,TEXTCOLOR ;keyText+137,2,TEXTCOLOR  ; B
115
  stdcall draw_button, 195,149,23,20,62,N_KEYCOLOR,ascii_keymap+49,1,TEXTCOLOR ;keyText+139,2,TEXTCOLOR  ; N
116
  stdcall draw_button, 220,149,23,20,63,N_KEYCOLOR,ascii_keymap+50,1,TEXTCOLOR ;keyText+141,2,TEXTCOLOR  ; M
117
  stdcall draw_button, 245,149,23,20,64,N_KEYCOLOR,ascii_keymap+51,1,TEXTCOLOR ;keyText+143,3,TEXTCOLOR  ; ,<
118
  stdcall draw_button, 270,149,23,20,65,N_KEYCOLOR,ascii_keymap+52,1,TEXTCOLOR ;keyText+146,3,TEXTCOLOR  ; .>
119
  stdcall draw_button, 295,149,23,20,66,N_KEYCOLOR,ascii_keymap+53,1,TEXTCOLOR ;keyText+149,2,TEXTCOLOR  ; /?
120
 
9971 Doczom 121
  test    byte [red_type], 1
122
  jnz     @f
123
  stdcall draw_button, 320,149,75,20,67,C_KEYCOLOR,keyText+151,5,TEXTCOLOR      ; Shift
1547 Asper 124
 
9971 Doczom 125
  stdcall draw_button, 15 ,172,30,20,68,C_KEYCOLOR,keyText+156,4,TEXTCOLOR      ; Ctrl
126
  stdcall draw_button, 47 ,172,30,20,69,C_KEYCOLOR,keyText+160,3,TEXTCOLOR      ; Win
127
  stdcall draw_button, 79 ,172,30,20,70,C_KEYCOLOR,keyText+163,3,TEXTCOLOR      ; Alt
128
  stdcall draw_button, 111,172,156,20,71,N_KEYCOLOR,keyText+166,1,TEXTCOLOR     ;  Space
129
  stdcall draw_button, 269,172,30,20,72,C_KEYCOLOR,keyText+167,3,TEXTCOLOR      ; Alt
130
  stdcall draw_button, 301,172,30,20,73,C_KEYCOLOR,keyText+170,3,TEXTCOLOR      ; Win
131
  stdcall draw_button, 333,172,30,20,74,C_KEYCOLOR,keyText+173,3,TEXTCOLOR      ; [=]
132
  stdcall draw_button, 365,172,30,20,75,C_KEYCOLOR,keyText+176,4,TEXTCOLOR      ; Ctrl
1547 Asper 133
 
9971 Doczom 134
  stdcall draw_button, 405,50 ,23,20,76,N_KEYCOLOR,keyText+180,3,TEXTCOLOR      ; psc
135
  stdcall draw_button, 430,50 ,23,20,77,L_KEYCOLOR,keyText+183,3,TEXTCOLOR      ; slk
136
  stdcall draw_button, 455,50 ,23,20,78,N_KEYCOLOR,keyText+186,3,TEXTCOLOR      ; brk
137
  stdcall draw_button, 405,80 ,23,20,79,N_KEYCOLOR,keyText+189,3,TEXTCOLOR      ; Ins
138
  stdcall draw_button, 430,80 ,23,20,80,N_KEYCOLOR,keyText+192,2,TEXTCOLOR      ; Hm
139
  stdcall draw_button, 455,80 ,23,20,81,N_KEYCOLOR,keyText+194,3,TEXTCOLOR      ; Pup
140
  stdcall draw_button, 405,103 ,23,20,82,N_KEYCOLOR,keyText+197,3,TEXTCOLOR     ; Del
141
  stdcall draw_button, 430,103 ,23,20,83,N_KEYCOLOR,keyText+200,3,TEXTCOLOR     ; End
142
  stdcall draw_button, 455,103 ,23,20,84,N_KEYCOLOR,keyText+203,3,TEXTCOLOR     ; Pdn
143
  stdcall draw_button, 430,149,23,20,85,C_KEYCOLOR,keyText+206,1,TEXTCOLOR      ; ^
144
  stdcall draw_button, 405,172,23,20,86,C_KEYCOLOR,keyText+207,1,TEXTCOLOR      ; v
145
  stdcall draw_button, 430,172,23,20,87,C_KEYCOLOR,keyText+208,1,TEXTCOLOR      ; <
146
  stdcall draw_button, 455,172,23,20,88,C_KEYCOLOR,keyText+209,2,TEXTCOLOR      ;  >
1547 Asper 147
 
9971 Doczom 148
  stdcall draw_button, 488,80 ,23,20,89,L_KEYCOLOR,keyText+211,3,TEXTCOLOR      ; nlk
149
  stdcall draw_button, 513,80 ,23,20,90,N_KEYCOLOR,keyText+214,1,TEXTCOLOR      ; /
150
  stdcall draw_button, 538,80 ,23,20,91,N_KEYCOLOR,keyText+215,1,TEXTCOLOR      ; *
151
  stdcall draw_button, 563,80 ,23,20,92,N_KEYCOLOR,keyText+216,1,TEXTCOLOR      ; -
152
  stdcall draw_button, 488,103 ,23,20,93,N_KEYCOLOR,keyText+217,1,TEXTCOLOR     ; 7
153
  stdcall draw_button, 513,103 ,23,20,94,N_KEYCOLOR,keyText+218,1,TEXTCOLOR     ; 8
154
  stdcall draw_button, 538,103 ,23,20,95,N_KEYCOLOR,keyText+219,1,TEXTCOLOR     ; 9
155
  stdcall draw_button, 488,126,23,20,96,N_KEYCOLOR,keyText+220,1,TEXTCOLOR      ; 4
156
  stdcall draw_button, 513,126,23,20,97,N_KEYCOLOR,keyText+221,1,TEXTCOLOR      ; 5
157
  stdcall draw_button, 538,126,23,20,98,N_KEYCOLOR,keyText+222,1,TEXTCOLOR      ; 6
158
  stdcall draw_button, 488,149,23,20,99,N_KEYCOLOR,keyText+223,1,TEXTCOLOR      ; 1
159
  stdcall draw_button, 513,149,23,20,100,N_KEYCOLOR,keyText+224,1,TEXTCOLOR     ; 2
160
  stdcall draw_button, 538,149,23,20,101,N_KEYCOLOR,keyText+225,1,TEXTCOLOR     ; 3
161
  stdcall draw_button, 488,172,48,20,102,N_KEYCOLOR,keyText+226,1,TEXTCOLOR     ; 0
162
  stdcall draw_button, 538,172,23,20,103,N_KEYCOLOR,keyText+227,1,TEXTCOLOR     ; .
163
  stdcall draw_button, 563,103 ,23,43,104,N_KEYCOLOR,keyText+228,1,TEXTCOLOR    ; +
164
  stdcall draw_button, 563,149,23,43,105,N_KEYCOLOR,keyText+229,3,TEXTCOLOR     ; Ent
1547 Asper 165
 
166
 .draw_switch_button:
9971 Doczom 167
  mov   eax, 6
168
  mul   byte [keyboard_mode]
169
  add   eax, SwitchText
170
  stdcall draw_button, 513,28,46,20,106,0x00700000,eax,6,TEXTCOLOR       ; Scan/ASCII switch
4263 0CodErr 171
 
9971 Doczom 172
  xor   al, al
173
  xchg  al, [red_type]
174
  test  al, 2
175
  jnz   .skip_end_draw_window ; if we draw switch button without redraw window then end_draw_window not need
4263 0CodErr 176
 
1547 Asper 177
@@:
178
 .draw_indicators_area:
179
  call lights_on
180
 
181
  end_draw_window
4263 0CodErr 182
 
183
.skip_end_draw_window:
1547 Asper 184
ret
185
 
186
get_zkey_window_slot_number:
9971 Doczom 187
        mov     eax, 18
188
        mov     ebx, 7
189
        int     0x40
190
        mov     [zkey_window], eax
1547 Asper 191
set_event_mask:
9971 Doczom 192
        mov     eax, 40
193
        mov     ebx, EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE ; 39 ; 100111b
194
        int     0x40
1547 Asper 195
 
196
still:
9971 Doczom 197
        call    get_receiver_window_slot_number
198
        call    get_receiver_window_keyboard_mode ; return in ecx keyboard_mode for set_keyboard_mode
199
        call    set_keyboard_mode
4263 0CodErr 200
; delete_switch_button
9971 Doczom 201
        mov eax, 8
202
        mov edx, BT_DEL + 0x00700000
203
        int     0x40
204
 
205
        mov    byte [red_type], 2
206
        call    draw_window.draw_switch_button
4263 0CodErr 207
 
9971 Doczom 208
        mov     eax, 10               ; Wait for an event in the queue.
209
        int     0x40
1547 Asper 210
 
9971 Doczom 211
        cmp     al, EV_REDRAW         ; redraw request ?
212
        jz      red
213
        cmp     al, EV_KEY            ; key in buffer ?
214
        jz      key
215
        cmp     al, EV_BUTTON         ; button in buffer ?
216
        jz      button
1547 Asper 217
 
9971 Doczom 218
        jmp     still
1547 Asper 219
 
220
red:
9971 Doczom 221
        call    draw_window
222
        jmp     still
1547 Asper 223
 
224
key:
9971 Doczom 225
        mov     eax, 2
226
        int     0x40
1547 Asper 227
 
228
;        push    ax
9971 Doczom 229
        call    get_control_keys_state
230
        cmp     [locks], ax
231
        je      @f
1547 Asper 232
 
233
      .reload:
9971 Doczom 234
        call    reload_ascii_keymap
235
        mov     byte [red_type], 1
236
        call    draw_window
1547 Asper 237
       @@:
238
;        pop     dx
239
;        jmp     button.select_key_code
9971 Doczom 240
        jmp     still
1547 Asper 241
 
242
button:
9971 Doczom 243
        mov     eax, 17             ; Get pressed button code
244
        int     0x40
245
        cmp     ah, 1               ; Test x button
246
        je      close_app
1547 Asper 247
 
9971 Doczom 248
        cmp     ah, 106             ; Test Scan/ASCII switch button
249
        jne     .keyboard_keys
250
        mov     cl, 1
251
        sub     cl, byte [keyboard_mode]
252
        call    set_keyboard_mode
253
        mov     byte [red_type], 2
254
        jmp     red
1547 Asper 255
 
256
      .keyboard_keys:
9971 Doczom 257
        cmp     ah, 2               ; Test if pressed buttons
258
        jb      still               ; is a ZKEY keyboard key...
259
        cmp     ah, 106
260
        jnb     still               ; ...so, if not then still,
261
        mov     [butt], ah          ; if yes then save pressed button ID
1547 Asper 262
      .test_slot:
9971 Doczom 263
        mov     eax, [zkey_window]              ; Test is receiver ZKEY window
264
        mov     ecx, [receiver_window]
265
        cmp     eax, ecx
266
        je      still                           ; if yes still.
1547 Asper 267
      .activate_receiver_window:
9971 Doczom 268
        mov     eax, 18
269
        mov     ebx, 3
270
        int     0x40
1547 Asper 271
 
272
      call reload_ascii_keymap
273
 
274
      .read_key_scancode:
9971 Doczom 275
        xor     edx, edx
276
        movzx   si, byte [butt]                 ; Read scan code of the key from the table.
277
        sub     si, 2
278
        mov     dl, [keyCodes+si]               ; Set dl = scancode of the key corresponding to the pressed button.
279
        cmp     dl, 0xA0
280
        jb      .select_key_code                ; If not extended key then select ascii or scan to send and then send it to the receiver.
1547 Asper 281
 
9971 Doczom 282
        cmp     dl, 0xA6                        ; Test if it's extended2 key
283
        jne     .read_ext_key                   ; if not go to prepare to send simply extended key.
284
        mov     dl, 0xE1                        ; Send extended2 scancode...
285
        call    send_key
286
        mov     dl, 0x1D                        ; ...and extended scancode,
287
        call    send_key                        ;
288
        mov     dl, [keyCodes.ext2]             ; (There is only one ext2 key - 'Break')
289
        jmp     .send_key_code                          ; so... send it's normal scan code.
1547 Asper 290
      .read_ext_key:
9971 Doczom 291
        sub     dl, 0xA0                        ; Read extended key scan code from the table.
292
        movzx   si, dl
293
        mov     dl, [keyCodes.ext+si]
1547 Asper 294
     .send_ext:
9971 Doczom 295
        push    dx                              ; Send extended scancode to the receiver's window.
296
        mov     dl, 0xE0
297
        call    send_key
298
        pop     dx
1547 Asper 299
;        jmp     .send_key_code
9971 Doczom 300
      .select_key_code:                 ; Select what to send ASCII or scan.
301
        cmp     [keyboard_mode], 0      ; Test if ZKEY must send ASCII.
302
        jne     .send_key_code
1547 Asper 303
 
304
;        mov     esi, ext0               ; Set esi to the beginning of the ext0 table.
9971 Doczom 305
        and     edx, 0x7F
1547 Asper 306
;      @@:
307
;        cmp     dl, byte [esi]
308
;        je      .send_key_code
309
;        inc     esi
310
;        cmp     esi, ext0end
311
;        jng     @b
312
      .read_ascii:
9971 Doczom 313
        mov     dl, byte [ascii_keymap+edx]     ; Read ASCII from the keymap table.
1547 Asper 314
      .send_key_code:
9971 Doczom 315
        call    send_key                ; Finally send the key to the receiver's window.
1547 Asper 316
      .wait:
9971 Doczom 317
        mov     eax, 5
318
        mov     ebx, 1                  ; Wait 0.01 second.
319
        int     0x40
1547 Asper 320
      .activate_zkey_window:
9971 Doczom 321
        mov     eax, 18
322
        mov     ebx, 3
323
        mov     ecx, [zkey_window]
324
        int     0x40
1547 Asper 325
 
9971 Doczom 326
        jmp     still
1547 Asper 327
 
328
 
329
close_app:
9971 Doczom 330
    mov  eax,-1                  ; close this program
1547 Asper 331
    int  0x40
332
 
333
 
334
;**********************************
335
;*  input: ecx = type of mode     *
336
;**********************************
337
 
338
set_keyboard_mode:
9971 Doczom 339
        mov     eax, 66
340
        mov     ebx, 1     ; Set keyboard mode
341
        int     0x40
342
        mov     [keyboard_mode], cl
1547 Asper 343
ret
344
 
345
get_control_keys_state:    ; This routine works only in Scan keyboard mode.
9971 Doczom 346
        mov     eax, 66
347
        mov     ebx, 3
348
        int     0x40
1547 Asper 349
ret
350
 
351
 
352
;**********************************
353
;*  input: ecx = type of map      *
354
;**********************************
355
 
356
get_keyboard_map:
9971 Doczom 357
        mov     eax, 26
358
        mov     ebx, 2
359
        mov     edx, ascii_keymap
360
        int     0x40
1547 Asper 361
ret
362
 
363
 
364
reload_ascii_keymap:
9971 Doczom 365
        call    get_control_keys_state
366
        mov     ecx, 1
1547 Asper 367
 
9971 Doczom 368
        test    ax, 3                           ; Shift pressed ?
369
        jnz      @f
370
        test    ax, 0x40                        ; Caps  Lock  on ?
371
        jz      .load_ascii_keymap
1547 Asper 372
      @@:
9971 Doczom 373
        mov     ecx, 2
1547 Asper 374
      .load_ascii_keymap:
9971 Doczom 375
        call    get_keyboard_map
1547 Asper 376
  ret
377
 
378
 
379
 
380
get_receiver_window_slot_number:
9971 Doczom 381
        mov     eax, 18
382
        mov     ebx, 7
383
        int     0x40
384
        mov     ebx, [zkey_window]
385
        cmp     eax, ebx
386
        je      @f
387
        mov     [receiver_window], eax
1547 Asper 388
      @@:
389
  ret
390
 
4263 0CodErr 391
get_receiver_window_keyboard_mode:
9971 Doczom 392
        mov     eax, 9
393
        mov     ebx, PROCINFO_BUFF
394
        mov     ecx, [receiver_window]
395
        int     0x40
396
        movzx   ecx, byte [ebx + process_information.keyboard_mode]
397
        ret
4263 0CodErr 398
 
1547 Asper 399
;************************************
400
;*  input: edx = code of the key    *
401
;************************************
402
 
403
send_key:
9971 Doczom 404
        mov     eax, 72
405
        mov     ebx, 1
406
        mov     ecx, 2
407
        int     0x40
1547 Asper 408
  ret
409
 
410
lights_on:
9971 Doczom 411
   bar 491,51,95,15,0                      ; indicators area
1547 Asper 412
   rectangle 490,50,96,16,TEXTCOLOR
413
 
414
   call    get_control_keys_state
9971 Doczom 415
   mov     [locks], ax
1547 Asper 416
   test ax, 0x40
417
   jz @f
418
   ;stdcall bar, 532, 53, 10, 11, 0x0000FF00
419
   bar 532, 53, 10, 11, 0x0000FF00
420
 @@:
421
   test ax, 0x80
422
   jz @f
423
   ;stdcall bar, 500, 53, 10, 11, 0x0000FF00
424
   bar 500, 53, 10, 11, 0x0000FF00
425
 @@:
426
   test ax, 0x100
427
   jz @f
428
   ;stdcall bar, 565, 53, 10, 11, 0x0000FF00
429
   bar 565, 53, 10, 11, 0x0000FF00
430
 @@:
431
ret
432
 
433
; DATA AREA
434
 
435
; Application Title
2549 leency 436
labelt db 'ZKEY v0.51 - keyboard for KolibriOS', 0
1547 Asper 437
 
438
SwitchText db ' ASCII SCAN '
439
 
440
;Button names
441
keyText db 'EscF1F2F3F4F5F6F7F8F9F10F11F12'
9971 Doczom 442
        db '~1!2@3#4$5%6^7&8*9(0)-_=+\|bksp'
443
        db 'TabQWERTYUIOP{[}]Enter'
444
        db 'lockASDFGHJKL;:''"'
445
        db 'ShiftZXCVBNM,<.>/?Shift'
446
        db 'CtrlWinAlt AltWin[=]Ctrl'
447
        db 'pscslkbrkInsHmPupDelEndPdn^'
448
        db 'nlk/*-7894561230.+Ent'
1547 Asper 449
 
450
;Key scan codes
451
keyCodes:
9971 Doczom 452
        db 0x01, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x57, 0x58
453
        db 0x29, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x2B, 0x0E
454
        db 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C
455
        db 0x3A, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28
456
        db 0x2A, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36
457
        db 0x1D, 0xA0, 0x38, 0x39, 0xA1, 0xA2, 0xA3, 0xA4
458
        db 0xA5, 0x46, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0
459
        db 0x45, 0xB1, 0x37, 0x4A, 0x47, 0x48, 0x49, 0x4B, 0x4C, 0x4D, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x4E, 0xB2
1547 Asper 460
      .ext:
9971 Doczom 461
        db 0x5B, 0x38, 0x5C, 0x5D, 0x1D
462
        db 0x37, 0x00, 0x52, 0x47, 0x49, 0x53, 0x4F, 0x51, 0x48, 0x4B, 0x50, 0x4D
463
        db 0x35, 0x1C
464
      .ext2  db 0x45      ; Just Break :)
1547 Asper 465
 
466
;ext0:
467
;    db   0x1D, 0x29, 0x2A, 0x36, 0x37, 0x38, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40
468
;    db   0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D
469
;    db   0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x57, 0x58
470
;ext0end:
471
 
9971 Doczom 472
receiver_window dd 0      ; Slot number of the receiver
473
zkey_window dd 0          ; Slot number of ZKEY
474
butt    db 0              ; Pressed button ID
475
locks   dw 0              ; NumLock, CapsLock, ScrollLock lights mask
1547 Asper 476
 
9971 Doczom 477
keyboard_mode db 0        ; Scan or ASCII keys to send ?  0 - ASCII , 1 - Scan
478
red_type      db 0        ; Type of window redraw. 0 - default , 1 - on ASCII_keymap change , 2 - Switch button pressed.
1547 Asper 479
 
9971 Doczom 480
I_END:                    ; End of application code and data marker
1547 Asper 481
 
9971 Doczom 482
ascii_keymap:   rb ASCII_KEYMAP_SIZE
483
 
484
PROCINFO_BUFF process_information
485
 
486
        rb 4096
487
STACKTOP:
488
MEM:
489