102,6 → 102,9 |
ret |
;--------------------------------------------------------------------- |
align 4 |
; @brief Export function - Add new scancode in buffer |
; @param ecx - scancode |
; @return not return |
set_keyboard_data: |
movzx eax, word[thread_count]; top window process |
movzx eax, word[WIN_POS + eax*2] |
122,6 → 125,7 |
functions dd ? |
userdata dd ? |
ends |
|
struct KBDFUNC |
strucsize dd ? |
close dd ? |
137,6 → 141,10 |
keyboard_list_mutex MUTEX |
endg |
|
; @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 |
register_keyboard: |
push ebx |
movi eax, sizeof.KEYBOARD |
171,6 → 179,9 |
pop ebx |
ret 8 |
|
; @brief Export function - Delete keyboard |
; @param [esp + 4] - pointer on KEYBOARD structure |
; @return not return |
delete_keyboard: |
push ebx |
mov ebx, [esp+4+4] |
577,3 → 588,248 |
numlock_map db '789-456+1230.' |
endg |
;--------------------------------------------------------------------- |
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 |
;------------------------------------------------------------------------------ |