2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-05-22 17:15:14 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
2021-06-20 01:36:32 +02:00
|
|
|
VKEY_LSHIFT = 00000000_00000001b
|
|
|
|
VKEY_RSHIFT = 00000000_00000010b
|
|
|
|
VKEY_LCONTROL = 00000000_00000100b
|
|
|
|
VKEY_RCONTROL = 00000000_00001000b
|
|
|
|
VKEY_LALT = 00000000_00010000b
|
|
|
|
VKEY_RALT = 00000000_00100000b
|
|
|
|
VKEY_CAPSLOCK = 00000000_01000000b
|
|
|
|
VKEY_NUMLOCK = 00000000_10000000b
|
|
|
|
VKEY_SCRLOCK = 00000001_00000000b
|
|
|
|
VKEY_LWIN = 00000010_00000000b
|
|
|
|
VKEY_RWIN = 00000100_00000000b
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2021-06-20 01:36:32 +02:00
|
|
|
VKEY_SHIFT = VKEY_LSHIFT + VKEY_RSHIFT
|
|
|
|
VKEY_CONTROL = VKEY_LCONTROL + VKEY_RCONTROL
|
|
|
|
VKEY_ALT = VKEY_LALT + VKEY_RALT
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
uglobal
|
2015-09-05 03:40:56 +02:00
|
|
|
align 4
|
|
|
|
kb_state dd 0
|
2011-10-14 23:38:50 +02:00
|
|
|
ext_code db 0
|
|
|
|
|
|
|
|
keyboard_mode db 0
|
|
|
|
keyboard_data db 0
|
|
|
|
|
|
|
|
altmouseb db 0
|
|
|
|
ctrl_alt_del db 0
|
|
|
|
|
2015-09-05 03:40:56 +02:00
|
|
|
kb_lights db 0
|
2012-04-11 21:06:32 +02:00
|
|
|
old_kb_lights db 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
align 4
|
|
|
|
hotkey_scancodes rd 256 ; we have 256 scancodes
|
|
|
|
hotkey_list rd 256*4 ; max 256 defined hotkeys
|
|
|
|
hotkey_buffer rd 120*2 ; buffer for 120 hotkeys
|
|
|
|
endg
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
hotkey_tests dd hotkey_test0
|
|
|
|
dd hotkey_test1
|
|
|
|
dd hotkey_test2
|
|
|
|
dd hotkey_test3
|
|
|
|
dd hotkey_test4
|
|
|
|
hotkey_tests_num = 5
|
|
|
|
endg
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
hotkey_test0:
|
|
|
|
test al, al
|
|
|
|
setz al
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
hotkey_test1:
|
|
|
|
test al, al
|
|
|
|
setnp al
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
hotkey_test2:
|
|
|
|
cmp al, 3
|
|
|
|
setz al
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
hotkey_test3:
|
|
|
|
cmp al, 1
|
|
|
|
setz al
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
hotkey_test4:
|
|
|
|
cmp al, 2
|
|
|
|
setz al
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
hotkey_do_test:
|
|
|
|
push eax
|
|
|
|
mov edx, [kb_state]
|
|
|
|
shr edx, cl
|
|
|
|
add cl, cl
|
|
|
|
mov eax, [eax+4]
|
|
|
|
shr eax, cl
|
|
|
|
and eax, 15
|
|
|
|
cmp al, hotkey_tests_num
|
|
|
|
jae .fail
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
xchg eax, edx
|
|
|
|
and al, 3
|
|
|
|
call [hotkey_tests + edx*4]
|
|
|
|
cmp al, 1
|
|
|
|
pop eax
|
|
|
|
ret
|
|
|
|
;--------------------------------------
|
|
|
|
.fail:
|
|
|
|
stc
|
|
|
|
pop eax
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
align 4
|
2023-04-09 20:19:13 +02:00
|
|
|
; @brief Export function - Add new scancode in buffer
|
|
|
|
; @param ecx - scancode
|
|
|
|
; @return not return
|
2011-10-14 23:38:50 +02:00
|
|
|
set_keyboard_data:
|
2021-06-16 12:04:10 +02:00
|
|
|
movzx eax, word[thread_count]; top window process
|
2022-02-12 18:27:41 +01:00
|
|
|
movzx eax, word[WIN_POS + eax*2]
|
2022-06-04 01:34:04 +02:00
|
|
|
shl eax, BSF sizeof.APPDATA
|
2022-02-12 18:27:41 +01:00
|
|
|
mov al, [SLOT_BASE + eax + APPDATA.keyboard_mode]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [keyboard_mode], al
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, ecx
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
push ebx esi edi ebp
|
|
|
|
call send_scancode
|
|
|
|
pop ebp edi esi ebx
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
2023-04-09 20:19:13 +02:00
|
|
|
struct KEYBOARD
|
|
|
|
next dd ?
|
|
|
|
prev dd ?
|
|
|
|
functions dd ?
|
|
|
|
userdata dd ?
|
2012-04-11 21:06:32 +02:00
|
|
|
ends
|
2023-04-09 20:19:13 +02:00
|
|
|
|
|
|
|
struct KBDFUNC
|
|
|
|
strucsize dd ?
|
|
|
|
close dd ?
|
|
|
|
setlights dd ?
|
2012-04-11 21:06:32 +02:00
|
|
|
ends
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
keyboards:
|
|
|
|
dd keyboards
|
|
|
|
dd keyboards
|
|
|
|
endg
|
|
|
|
uglobal
|
|
|
|
keyboard_list_mutex MUTEX
|
|
|
|
endg
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
; @brief Export function - Registration new keyboard
|
|
|
|
; @param [esp + 4] - pointer on KBDFUNC this keyboard
|
|
|
|
; @param [esp + 8] - userdata for callback function
|
|
|
|
; @return eax = pointer on KEYBOARD structure or 0 on error
|
2012-04-11 21:06:32 +02:00
|
|
|
register_keyboard:
|
|
|
|
push ebx
|
2013-06-04 13:14:37 +02:00
|
|
|
movi eax, sizeof.KEYBOARD
|
2012-04-11 21:06:32 +02:00
|
|
|
call malloc
|
|
|
|
test eax, eax
|
|
|
|
jz .nothing
|
|
|
|
mov ecx, [esp+4+4]
|
2022-02-12 18:27:41 +01:00
|
|
|
mov [eax + KEYBOARD.functions], ecx
|
2012-04-11 21:06:32 +02:00
|
|
|
mov ecx, [esp+8+4]
|
2022-02-12 18:27:41 +01:00
|
|
|
mov [eax + KEYBOARD.userdata], ecx
|
2012-04-11 21:06:32 +02:00
|
|
|
xchg eax, ebx
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
call mutex_lock
|
|
|
|
mov ecx, keyboards
|
2022-02-12 18:27:41 +01:00
|
|
|
mov edx, [ecx + KEYBOARD.prev]
|
|
|
|
mov [ebx + KEYBOARD.next], ecx
|
|
|
|
mov [ebx + KEYBOARD.prev], edx
|
|
|
|
mov [edx + KEYBOARD.next], ebx
|
|
|
|
mov [ecx + KEYBOARD.prev], ebx
|
|
|
|
mov ecx, [ebx + KEYBOARD.functions]
|
|
|
|
cmp [ecx + KBDFUNC.strucsize], KBDFUNC.setlights
|
2012-04-11 21:06:32 +02:00
|
|
|
jbe .unlock
|
2022-02-12 18:27:41 +01:00
|
|
|
mov ecx, [ecx + KBDFUNC.setlights]
|
2012-04-11 21:06:32 +02:00
|
|
|
test ecx, ecx
|
|
|
|
jz .unlock
|
2022-02-12 18:27:41 +01:00
|
|
|
stdcall ecx, [ebx + KEYBOARD.userdata], dword [kb_lights]
|
2012-04-11 21:06:32 +02:00
|
|
|
.unlock:
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
call mutex_unlock
|
|
|
|
xchg eax, ebx
|
|
|
|
.nothing:
|
|
|
|
pop ebx
|
|
|
|
ret 8
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
; @brief Export function - Delete keyboard
|
|
|
|
; @param [esp + 4] - pointer on KEYBOARD structure
|
|
|
|
; @return not return
|
2012-04-11 21:06:32 +02:00
|
|
|
delete_keyboard:
|
|
|
|
push ebx
|
|
|
|
mov ebx, [esp+4+4]
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
call mutex_lock
|
2022-02-12 18:27:41 +01:00
|
|
|
mov eax, [ebx + KEYBOARD.next]
|
|
|
|
mov edx, [ebx + KEYBOARD.prev]
|
|
|
|
mov [eax + KEYBOARD.prev], edx
|
|
|
|
mov [edx + KEYBOARD.next], eax
|
2012-04-11 21:06:32 +02:00
|
|
|
call mutex_unlock
|
2022-02-12 18:27:41 +01:00
|
|
|
mov ecx, [ebx + KEYBOARD.functions]
|
|
|
|
cmp [ecx + KBDFUNC.strucsize], KBDFUNC.close
|
2012-04-11 21:06:32 +02:00
|
|
|
jbe .nothing
|
2022-02-12 18:27:41 +01:00
|
|
|
mov ecx, [ecx + KBDFUNC.close]
|
2012-04-11 21:06:32 +02:00
|
|
|
test ecx, ecx
|
|
|
|
jz .nothing
|
2022-02-12 18:27:41 +01:00
|
|
|
stdcall ecx, [ebx + KEYBOARD.userdata]
|
2012-04-11 21:06:32 +02:00
|
|
|
.nothing:
|
|
|
|
pop ebx
|
|
|
|
ret 4
|
|
|
|
;---------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
irq1:
|
2021-06-16 12:04:10 +02:00
|
|
|
movzx eax, word[thread_count]; top window process
|
2022-02-12 18:27:41 +01:00
|
|
|
movzx eax, word[WIN_POS + eax*2]
|
2021-06-20 01:36:32 +02:00
|
|
|
shl eax, BSF sizeof.APPDATA
|
2022-02-12 18:27:41 +01:00
|
|
|
mov al, [SLOT_BASE + eax + APPDATA.keyboard_mode]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [keyboard_mode], al
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
in al, 0x60
|
|
|
|
;--------------------------------------
|
|
|
|
send_scancode:
|
2022-06-04 01:34:04 +02:00
|
|
|
;DEBUGF 1, "K : Scan code: %x \n", al
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [keyboard_data], al
|
|
|
|
; ch = scancode
|
|
|
|
; cl = ext_code
|
|
|
|
; bh = 0 - normal key
|
|
|
|
; bh = 1 - modifier (Shift/Ctrl/Alt)
|
|
|
|
; bh = 2 - extended code
|
|
|
|
mov ch, al
|
|
|
|
cmp al, 0xE0
|
|
|
|
je @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp al, 0xE1
|
|
|
|
jne .normal_code
|
|
|
|
@@:
|
|
|
|
mov bh, 2
|
|
|
|
mov [ext_code], al
|
|
|
|
jmp .writekey
|
|
|
|
;--------------------------------------
|
|
|
|
.normal_code:
|
|
|
|
mov cl, 0
|
|
|
|
xchg cl, [ext_code]
|
|
|
|
and al, 0x7F
|
|
|
|
mov bh, 1
|
2013-03-08 17:27:43 +01:00
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x5B
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2013-03-08 17:27:43 +01:00
|
|
|
cmp cl, 0xE0
|
2013-03-08 18:07:30 +01:00
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2013-03-08 17:27:43 +01:00
|
|
|
mov eax, VKEY_LWIN
|
2013-03-08 18:07:30 +01:00
|
|
|
mov bh, 0
|
2013-03-08 17:27:43 +01:00
|
|
|
jmp .modifier
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x5C
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2013-03-08 17:27:43 +01:00
|
|
|
cmp cl, 0xE0
|
2013-03-08 18:07:30 +01:00
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2013-03-08 17:27:43 +01:00
|
|
|
mov eax, VKEY_RWIN
|
2013-03-08 18:07:30 +01:00
|
|
|
mov bh, 0
|
2013-03-08 17:27:43 +01:00
|
|
|
jmp .modifier
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
cmp al, 0x2A
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0xE0
|
|
|
|
je .writekey
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, VKEY_LSHIFT
|
|
|
|
jmp .modifier
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x36
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp cl, 0xE0
|
|
|
|
je .writekey
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, VKEY_RSHIFT
|
|
|
|
jmp .modifier
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x38
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, VKEY_LALT
|
|
|
|
test cl, cl
|
|
|
|
jz .modifier
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, VKEY_RALT
|
|
|
|
jmp .modifier
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x1D
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, VKEY_LCONTROL
|
|
|
|
test cl, cl
|
|
|
|
jz .modifier
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, VKEY_RCONTROL
|
|
|
|
cmp cl, 0xE0
|
|
|
|
jz .modifier
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [ext_code], cl
|
|
|
|
jmp .writekey
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x3A
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov bl, 4
|
|
|
|
mov eax, VKEY_CAPSLOCK
|
|
|
|
jmp .no_key.xor
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x45
|
|
|
|
jne @f
|
|
|
|
test cl, cl
|
|
|
|
jnz .writekey
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov bl, 2
|
|
|
|
mov eax, VKEY_NUMLOCK
|
|
|
|
jmp .no_key.xor
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
cmp al, 0x46
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov bl, 1
|
|
|
|
mov eax, VKEY_SCRLOCK
|
|
|
|
jmp .no_key.xor
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
xor ebx, ebx
|
|
|
|
test ch, ch
|
|
|
|
js .writekey
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, ch ; plain key
|
2022-02-12 18:27:41 +01:00
|
|
|
mov bl, [keymap + eax]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, [kb_state]
|
|
|
|
test dl, VKEY_CONTROL ; ctrl alt del
|
|
|
|
jz .noctrlaltdel
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
test dl, VKEY_ALT
|
|
|
|
jz .noctrlaltdel
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 53h
|
|
|
|
jne .noctrlaltdel
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [ctrl_alt_del], 1
|
2013-05-27 11:02:35 +02:00
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
.noctrlaltdel:
|
|
|
|
test dl, VKEY_CONTROL ; ctrl on ?
|
|
|
|
jz @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
sub bl, 0x60
|
|
|
|
@@:
|
|
|
|
test dl, VKEY_CAPSLOCK ; caps lock on ?
|
|
|
|
jz .no_caps_lock
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
test dl, VKEY_SHIFT ; shift on ?
|
|
|
|
jz .keymap_shif
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp @f
|
|
|
|
;--------------------------------------
|
|
|
|
.no_caps_lock:
|
|
|
|
test dl, VKEY_SHIFT ; shift on ?
|
|
|
|
jz @f
|
2024-05-22 17:15:14 +02:00
|
|
|
.keymap_shif:
|
2022-02-12 18:27:41 +01:00
|
|
|
mov bl, [keymap_shift + eax]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
test dl, VKEY_ALT ; alt on ?
|
|
|
|
jz @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
mov bl, [keymap_alt + eax]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
jmp .writekey
|
|
|
|
;--------------------------------------
|
|
|
|
.modifier:
|
|
|
|
test ch, ch
|
|
|
|
js .modifier.up
|
|
|
|
or [kb_state], eax
|
|
|
|
jmp .writekey
|
|
|
|
;--------------------------------------
|
|
|
|
.modifier.up:
|
|
|
|
not eax
|
|
|
|
and [kb_state], eax
|
|
|
|
jmp .writekey
|
|
|
|
;--------------------------------------
|
|
|
|
.no_key.xor:
|
|
|
|
mov bh, 0
|
|
|
|
test ch, ch
|
|
|
|
js .writekey
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
xor [kb_state], eax
|
|
|
|
xor [kb_lights], bl
|
|
|
|
.writekey:
|
2012-04-13 23:39:02 +02:00
|
|
|
pushad
|
2011-10-14 23:38:50 +02:00
|
|
|
; test for system hotkeys
|
|
|
|
movzx eax, ch
|
|
|
|
cmp bh, 1
|
|
|
|
ja .nohotkey
|
|
|
|
jb @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
mov eax, [hotkey_scancodes + eax*4]
|
|
|
|
.hotkey_loop:
|
|
|
|
test eax, eax
|
|
|
|
jz .nohotkey
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov cl, 0
|
|
|
|
call hotkey_do_test
|
|
|
|
jc .hotkey_cont
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov cl, 2
|
|
|
|
call hotkey_do_test
|
|
|
|
jc .hotkey_cont
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov cl, 4
|
|
|
|
call hotkey_do_test
|
|
|
|
jnc .hotkey_found
|
|
|
|
.hotkey_cont:
|
|
|
|
mov eax, [eax]
|
|
|
|
jmp .hotkey_loop
|
|
|
|
;--------------------------------------
|
|
|
|
.hotkey_found:
|
|
|
|
mov eax, [eax+8]
|
|
|
|
; put key in buffer for process in slot eax
|
|
|
|
mov edi, hotkey_buffer
|
|
|
|
@@:
|
|
|
|
cmp dword [edi], 0
|
|
|
|
jz .found_free
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 8
|
|
|
|
cmp edi, hotkey_buffer+120*8
|
|
|
|
jb @b
|
|
|
|
; no free space - replace first entry
|
|
|
|
mov edi, hotkey_buffer
|
|
|
|
.found_free:
|
|
|
|
mov [edi], eax
|
|
|
|
movzx eax, ch
|
|
|
|
cmp bh, 1
|
|
|
|
jnz @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
mov [edi+4], ax
|
|
|
|
mov eax, [kb_state]
|
|
|
|
mov [edi+6], ax
|
2012-06-01 02:58:16 +02:00
|
|
|
|
|
|
|
cmp [PID_lock_input], dword 0
|
|
|
|
je .nohotkey
|
|
|
|
|
|
|
|
popad
|
|
|
|
jmp .exit.irq1
|
2011-10-14 23:38:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
.nohotkey:
|
2012-04-13 23:39:02 +02:00
|
|
|
popad
|
2012-06-01 02:58:16 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [keyboard_mode], 0; return from keymap
|
|
|
|
jne .scancode
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
test bh, bh
|
|
|
|
jnz .exit.irq1
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
test bl, bl
|
|
|
|
jz .exit.irq1
|
|
|
|
|
2014-05-20 10:24:37 +02:00
|
|
|
cmp cl, 0xE0 ; extended keycode
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
cmp ch, 53
|
|
|
|
jne .dowrite
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2014-05-20 10:24:37 +02:00
|
|
|
mov bl, '/'
|
|
|
|
jmp .dowrite
|
|
|
|
@@:
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 55
|
2014-05-20 10:24:37 +02:00
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2014-05-20 10:24:37 +02:00
|
|
|
mov bl, '*'
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .dowrite
|
|
|
|
@@:
|
2014-05-20 10:24:37 +02:00
|
|
|
|
|
|
|
cmp ch, 74
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2014-05-20 10:24:37 +02:00
|
|
|
mov bl, '-'
|
|
|
|
jmp .dowrite
|
|
|
|
@@:
|
|
|
|
|
|
|
|
cmp ch, 78
|
|
|
|
jne @f
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2014-05-20 10:24:37 +02:00
|
|
|
mov bl, '+'
|
|
|
|
jmp .dowrite
|
|
|
|
@@:
|
|
|
|
|
|
|
|
test [kb_state], VKEY_NUMLOCK
|
|
|
|
jz .dowrite
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 71
|
|
|
|
jb .dowrite
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp ch, 83
|
|
|
|
ja .dowrite
|
2024-05-22 17:15:14 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, ch
|
|
|
|
mov bl, [numlock_map + eax - 71]
|
|
|
|
jmp .dowrite
|
|
|
|
;--------------------------------------
|
|
|
|
.scancode:
|
|
|
|
mov bl, ch
|
|
|
|
.dowrite:
|
|
|
|
movzx eax, byte[KEY_COUNT]
|
|
|
|
cmp al, 120
|
|
|
|
jae .exit.irq1
|
|
|
|
inc eax
|
|
|
|
mov [KEY_COUNT], al
|
2014-02-25 02:03:37 +01:00
|
|
|
; store ascii or scancode
|
2022-02-12 18:27:41 +01:00
|
|
|
mov [KEY_BUFF + eax -1], bl
|
2014-02-25 02:03:37 +01:00
|
|
|
; store original scancode
|
|
|
|
add eax, 120+2
|
2014-03-05 16:31:09 +01:00
|
|
|
push ecx
|
|
|
|
cmp [keyboard_mode], 0; return from keymap
|
|
|
|
je @f
|
|
|
|
|
|
|
|
xor ch, ch
|
|
|
|
@@:
|
2022-02-12 18:27:41 +01:00
|
|
|
mov [KEY_BUFF + eax -1], ch
|
2014-03-05 16:31:09 +01:00
|
|
|
pop ecx
|
2014-02-25 02:03:37 +01:00
|
|
|
sub eax, 120+2
|
2011-10-14 23:38:50 +02:00
|
|
|
.exit.irq1:
|
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
|
|
|
set_lights:
|
2012-04-11 21:06:32 +02:00
|
|
|
push ebx esi
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
call mutex_lock
|
|
|
|
mov esi, keyboards
|
|
|
|
.loop:
|
2022-02-12 18:27:41 +01:00
|
|
|
mov esi, [esi + KEYBOARD.next]
|
2012-04-11 21:06:32 +02:00
|
|
|
cmp esi, keyboards
|
|
|
|
jz .done
|
2022-02-12 18:27:41 +01:00
|
|
|
mov eax, [esi + KEYBOARD.functions]
|
2012-04-11 21:06:32 +02:00
|
|
|
cmp dword [eax], KBDFUNC.setlights
|
|
|
|
jbe .loop
|
2022-02-12 18:27:41 +01:00
|
|
|
mov eax, [eax + KBDFUNC.setlights]
|
2012-04-11 21:06:32 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .loop
|
2022-02-12 18:27:41 +01:00
|
|
|
stdcall eax, [esi + KEYBOARD.userdata], dword [kb_lights]
|
2012-04-11 21:06:32 +02:00
|
|
|
jmp .loop
|
|
|
|
.done:
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
call mutex_unlock
|
|
|
|
pop esi ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
ps2_set_lights:
|
2013-03-04 12:01:50 +01:00
|
|
|
stdcall disable_irq, 1
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, 0xED
|
2014-07-29 12:41:27 +02:00
|
|
|
call kb_write_wait_ack
|
2012-04-11 21:06:32 +02:00
|
|
|
mov al, [esp+8]
|
2014-07-29 12:41:27 +02:00
|
|
|
call kb_write_wait_ack
|
2013-03-04 12:01:50 +01:00
|
|
|
stdcall enable_irq, 1
|
2012-04-11 21:06:32 +02:00
|
|
|
ret 8
|
|
|
|
|
|
|
|
;// mike.dld ]
|
2013-05-27 11:02:35 +02:00
|
|
|
proc check_lights_state_has_work?
|
2012-04-11 21:06:32 +02:00
|
|
|
mov al, [kb_lights]
|
|
|
|
cmp al, [old_kb_lights]
|
2013-05-27 11:02:35 +02:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
check_lights_state:
|
|
|
|
call check_lights_state_has_work?
|
2012-04-11 21:06:32 +02:00
|
|
|
jz .nothing
|
|
|
|
mov [old_kb_lights], al
|
|
|
|
call set_lights
|
|
|
|
.nothing:
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
;---------------------------------------------------------------------
|
2021-06-20 01:36:32 +02:00
|
|
|
iglobal
|
|
|
|
numlock_map db '789-456+1230.'
|
|
|
|
endg
|
2011-10-14 23:38:50 +02:00
|
|
|
;---------------------------------------------------------------------
|
2023-04-09 20:19:13 +02:00
|
|
|
align 4
|
|
|
|
kb_write_wait_ack:
|
|
|
|
|
|
|
|
push ecx edx
|
|
|
|
|
|
|
|
mov dl, al
|
|
|
|
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
|
|
|
|
.wait_output_ready:
|
|
|
|
in al, 0x64
|
|
|
|
test al, 2
|
|
|
|
jz @f
|
|
|
|
loop .wait_output_ready
|
|
|
|
mov ah, 1
|
|
|
|
jmp .nothing
|
|
|
|
@@:
|
|
|
|
mov al, dl
|
|
|
|
out 0x60, al
|
|
|
|
mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's
|
|
|
|
.wait_ack:
|
|
|
|
in al, 0x64
|
|
|
|
test al, 1
|
|
|
|
jnz @f
|
|
|
|
loop .wait_ack
|
|
|
|
mov ah, 1
|
|
|
|
jmp .nothing
|
|
|
|
@@:
|
|
|
|
in al, 0x60
|
|
|
|
xor ah, ah
|
|
|
|
|
|
|
|
.nothing:
|
|
|
|
pop edx ecx
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; 66 sys function. ;;
|
|
|
|
;; in eax=66,ebx in [0..5],ecx,edx ;;
|
|
|
|
;; out eax ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
f66call:
|
|
|
|
dd sys_process_def.1 ; 1 = set keyboard mode
|
|
|
|
dd sys_process_def.2 ; 2 = get keyboard mode
|
|
|
|
dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift
|
|
|
|
dd sys_process_def.4 ; 4 = set system-wide hotkey
|
|
|
|
dd sys_process_def.5 ; 5 = delete installed hotkey
|
|
|
|
dd sys_process_def.6 ; 6 = disable input, work only hotkeys
|
|
|
|
dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6
|
|
|
|
endg
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
sys_process_def:
|
|
|
|
dec ebx
|
|
|
|
cmp ebx, 7
|
|
|
|
jae .not_support ;if >=8 then or eax,-1
|
|
|
|
|
|
|
|
mov edi, [current_slot]
|
|
|
|
jmp dword [f66call + ebx*4]
|
|
|
|
|
|
|
|
.not_support:
|
|
|
|
or [esp + SYSCALL_STACK.eax], -1
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.1:
|
|
|
|
mov [edi + APPDATA.keyboard_mode], cl
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.2: ; 2 = get keyboard mode
|
|
|
|
movzx eax, byte [edi + APPDATA.keyboard_mode]
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.3: ;3 = get keyboard ctrl, alt, shift
|
|
|
|
mov eax, [kb_state]
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.4:
|
|
|
|
mov edi, [current_slot_idx]
|
|
|
|
mov eax, hotkey_list
|
|
|
|
@@:
|
|
|
|
cmp dword [eax + 8], 0
|
|
|
|
jz .found_free
|
|
|
|
add eax, 16
|
|
|
|
cmp eax, hotkey_list+16*256
|
|
|
|
jb @b
|
|
|
|
mov dword [esp + SYSCALL_STACK.eax], 1
|
|
|
|
ret
|
|
|
|
.found_free:
|
|
|
|
mov [eax + 8], edi
|
|
|
|
mov [eax + 4], edx
|
|
|
|
movzx ecx, cl
|
|
|
|
lea ecx, [hotkey_scancodes+ecx*4]
|
|
|
|
mov edx, [ecx]
|
|
|
|
mov [eax], edx
|
|
|
|
mov [ecx], eax
|
|
|
|
mov [eax + 12], ecx
|
|
|
|
test edx, edx
|
|
|
|
jz @f
|
|
|
|
mov [edx + 12], eax
|
|
|
|
@@:
|
|
|
|
and dword [esp + SYSCALL_STACK.eax], 0
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.5:
|
|
|
|
mov edi, [current_slot_idx]
|
|
|
|
movzx ebx, cl
|
|
|
|
lea ebx, [hotkey_scancodes+ebx*4]
|
|
|
|
mov eax, [ebx]
|
|
|
|
.scan:
|
|
|
|
test eax, eax
|
|
|
|
jz .notfound
|
|
|
|
cmp [eax + 8], edi
|
|
|
|
jnz .next
|
|
|
|
cmp [eax + 4], edx
|
|
|
|
jz .found
|
|
|
|
.next:
|
|
|
|
mov eax, [eax]
|
|
|
|
jmp .scan
|
|
|
|
.notfound:
|
|
|
|
mov dword [esp + SYSCALL_STACK.eax], 1
|
|
|
|
ret
|
|
|
|
.found:
|
|
|
|
mov ecx, [eax]
|
|
|
|
jecxz @f
|
|
|
|
mov edx, [eax + 12]
|
|
|
|
mov [ecx + 12], edx
|
|
|
|
@@:
|
|
|
|
mov ecx, [eax + 12]
|
|
|
|
mov edx, [eax]
|
|
|
|
mov [ecx], edx
|
|
|
|
xor edx, edx
|
|
|
|
mov [eax + 4], edx
|
|
|
|
mov [eax + 8], edx
|
|
|
|
mov [eax + 12], edx
|
|
|
|
mov [eax], edx
|
|
|
|
mov [esp + SYSCALL_STACK.eax], edx
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.6:
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
mov eax, [PID_lock_input]
|
|
|
|
test eax, eax
|
|
|
|
jnz @f
|
|
|
|
; get current PID
|
|
|
|
mov eax, [current_slot]
|
|
|
|
mov eax, [eax + APPDATA.tid]
|
|
|
|
; set current PID for lock input
|
|
|
|
mov [PID_lock_input], eax
|
|
|
|
@@:
|
|
|
|
popfd
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
.7:
|
|
|
|
mov eax, [PID_lock_input]
|
|
|
|
test eax, eax
|
|
|
|
jz @f
|
|
|
|
; get current PID
|
|
|
|
mov ebx, [current_slot]
|
|
|
|
mov ebx, [ebx + APPDATA.tid]
|
|
|
|
; compare current lock input with current PID
|
|
|
|
cmp ebx, eax
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
mov [PID_lock_input], eax
|
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
uglobal
|
|
|
|
PID_lock_input dd 0x0
|
|
|
|
endg
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
; @brief System function 2 - Get pressed key
|
|
|
|
; @param eax = 2- number function
|
|
|
|
; @return eax = 1 - buffer empty, else
|
|
|
|
; al = 0, ah = code pressed key,
|
|
|
|
; 16-23 bits - scancode pressed key(in ASCII mode)
|
|
|
|
; if al=2 ah=scancode pressed key, 16-31 bits - state control keys
|
|
|
|
sys_getkey:
|
|
|
|
mov [esp + SYSCALL_STACK.eax], dword 1
|
|
|
|
; test main buffer
|
|
|
|
mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK
|
|
|
|
movzx ecx, word [WIN_STACK + ebx * 2]
|
|
|
|
mov edx, [thread_count]
|
|
|
|
cmp ecx, edx
|
|
|
|
jne .finish
|
|
|
|
cmp [KEY_COUNT], byte 0
|
|
|
|
je .finish
|
|
|
|
movzx ax, byte [KEY_BUFF + 120 + 2]
|
|
|
|
shl eax, 8
|
|
|
|
mov al, byte [KEY_BUFF]
|
|
|
|
shl eax, 8
|
|
|
|
push eax
|
|
|
|
dec byte [KEY_COUNT]
|
|
|
|
and byte [KEY_COUNT], 127
|
|
|
|
movzx ecx, byte [KEY_COUNT]
|
|
|
|
add ecx, 2
|
|
|
|
mov eax, KEY_BUFF + 1
|
|
|
|
mov ebx, KEY_BUFF
|
|
|
|
call memmove
|
|
|
|
add eax, 120 + 2
|
|
|
|
add ebx, 120 + 2
|
|
|
|
call memmove
|
|
|
|
pop eax
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.ret_eax:
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
|
|
|
ret
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.finish:
|
|
|
|
; test hotkeys buffer
|
|
|
|
mov ecx, hotkey_buffer
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
|
|
|
cmp [ecx], ebx
|
|
|
|
jz .found
|
|
|
|
add ecx, 8
|
|
|
|
cmp ecx, hotkey_buffer + 120 * 8
|
|
|
|
jb @b
|
|
|
|
ret
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.found:
|
|
|
|
mov ax, [ecx + 6]
|
|
|
|
shl eax, 16
|
|
|
|
mov ah, [ecx + 4]
|
|
|
|
mov al, 2
|
|
|
|
and dword [ecx + 4], 0
|
|
|
|
and dword [ecx], 0
|
|
|
|
jmp .ret_eax
|
2024-05-22 17:15:14 +02:00
|
|
|
;------------------------------------------------------------------------------
|