/kernel/branches/kolibrios-pe-clevermouse/hid/keyboard.inc |
---|
0,0 → 1,578 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
;; Distributed under terms of the GNU General Public License ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
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 |
VKEY_SHIFT = VKEY_LSHIFT + VKEY_RSHIFT |
VKEY_CONTROL = VKEY_LCONTROL + VKEY_RCONTROL |
VKEY_ALT = VKEY_LALT + VKEY_RALT |
uglobal |
align 4 |
kb_state dd 0 |
ext_code db 0 |
keyboard_mode db 0 |
keyboard_data db 0 |
altmouseb db 0 |
ctrl_alt_del db 0 |
kb_lights db 0 |
old_kb_lights db 0 |
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 |
xchg eax, edx |
and al, 3 |
call [hotkey_tests + edx*4] |
cmp al, 1 |
pop eax |
ret |
;-------------------------------------- |
.fail: |
stc |
pop eax |
ret |
;--------------------------------------------------------------------- |
align 4 |
set_keyboard_data: |
movzx eax, word[thread_count]; top window process |
movzx eax, word[WIN_POS+eax*2] |
shl eax, 8 |
mov al, [SLOT_BASE+eax+APPDATA.keyboard_mode] |
mov [keyboard_mode], al |
mov eax, ecx |
push ebx esi edi ebp |
call send_scancode |
pop ebp edi esi ebx |
ret |
;--------------------------------------------------------------------- |
struct KEYBOARD |
next dd ? |
prev dd ? |
functions dd ? |
userdata dd ? |
ends |
struct KBDFUNC |
strucsize dd ? |
close dd ? |
setlights dd ? |
ends |
iglobal |
keyboards: |
dd keyboards |
dd keyboards |
endg |
uglobal |
keyboard_list_mutex MUTEX |
endg |
register_keyboard: |
push ebx |
movi eax, sizeof.KEYBOARD |
call malloc |
test eax, eax |
jz .nothing |
mov ecx, [esp+4+4] |
mov [eax+KEYBOARD.functions], ecx |
mov ecx, [esp+8+4] |
mov [eax+KEYBOARD.userdata], ecx |
xchg eax, ebx |
mov ecx, keyboard_list_mutex |
call mutex_lock |
mov ecx, keyboards |
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 |
jbe .unlock |
mov ecx, [ecx+KBDFUNC.setlights] |
test ecx, ecx |
jz .unlock |
stdcall ecx, [ebx+KEYBOARD.userdata], dword [kb_lights] |
.unlock: |
mov ecx, keyboard_list_mutex |
call mutex_unlock |
xchg eax, ebx |
.nothing: |
pop ebx |
ret 8 |
delete_keyboard: |
push ebx |
mov ebx, [esp+4+4] |
mov ecx, keyboard_list_mutex |
call mutex_lock |
mov eax, [ebx+KEYBOARD.next] |
mov edx, [ebx+KEYBOARD.prev] |
mov [eax+KEYBOARD.prev], edx |
mov [edx+KEYBOARD.next], eax |
call mutex_unlock |
mov ecx, [ebx+KEYBOARD.functions] |
cmp [ecx+KBDFUNC.strucsize], KBDFUNC.close |
jbe .nothing |
mov ecx, [ecx+KBDFUNC.close] |
test ecx, ecx |
jz .nothing |
stdcall ecx, [ebx+KEYBOARD.userdata] |
.nothing: |
pop ebx |
ret 4 |
;--------------------------------------------------------------------- |
align 4 |
irq1: |
movzx eax, word[thread_count]; top window process |
movzx eax, word[WIN_POS+eax*2] |
shl eax, BSF sizeof.APPDATA |
mov al, [SLOT_BASE+eax+APPDATA.keyboard_mode] |
mov [keyboard_mode], al |
in al, 0x60 |
;-------------------------------------- |
send_scancode: |
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 |
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 |
;-------------------------------------- |
@@: |
cmp al, 0x5B |
jne @f |
cmp cl, 0xE0 |
jne @f |
mov eax, VKEY_LWIN |
mov bh, 0 |
jmp .modifier |
;-------------------------------------- |
@@: |
cmp al, 0x5C |
jne @f |
cmp cl, 0xE0 |
jne @f |
mov eax, VKEY_RWIN |
mov bh, 0 |
jmp .modifier |
;-------------------------------------- |
@@: |
cmp al, 0x2A |
jne @f |
cmp cl, 0xE0 |
je .writekey |
mov eax, VKEY_LSHIFT |
jmp .modifier |
;-------------------------------------- |
@@: |
cmp al, 0x36 |
jne @f |
cmp cl, 0xE0 |
je .writekey |
mov eax, VKEY_RSHIFT |
jmp .modifier |
;-------------------------------------- |
@@: |
cmp al, 0x38 |
jne @f |
mov eax, VKEY_LALT |
test cl, cl |
jz .modifier |
mov al, VKEY_RALT |
jmp .modifier |
;-------------------------------------- |
@@: |
cmp al, 0x1D |
jne @f |
mov eax, VKEY_LCONTROL |
test cl, cl |
jz .modifier |
mov al, VKEY_RCONTROL |
cmp cl, 0xE0 |
jz .modifier |
mov [ext_code], cl |
jmp .writekey |
;-------------------------------------- |
@@: |
cmp al, 0x3A |
jne @f |
mov bl, 4 |
mov eax, VKEY_CAPSLOCK |
jmp .no_key.xor |
;-------------------------------------- |
@@: |
cmp al, 0x45 |
jne @f |
test cl, cl |
jnz .writekey |
mov bl, 2 |
mov eax, VKEY_NUMLOCK |
jmp .no_key.xor |
;-------------------------------------- |
@@: |
cmp al, 0x46 |
jne @f |
mov bl, 1 |
mov eax, VKEY_SCRLOCK |
jmp .no_key.xor |
;-------------------------------------- |
@@: |
xor ebx, ebx |
test ch, ch |
js .writekey |
movzx eax, ch ; plain key |
mov bl, [keymap+eax] |
mov edx, [kb_state] |
test dl, VKEY_CONTROL ; ctrl alt del |
jz .noctrlaltdel |
test dl, VKEY_ALT |
jz .noctrlaltdel |
cmp ch, 53h |
jne .noctrlaltdel |
mov [ctrl_alt_del], 1 |
call wakeup_osloop |
.noctrlaltdel: |
test dl, VKEY_CONTROL ; ctrl on ? |
jz @f |
sub bl, 0x60 |
@@: |
test dl, VKEY_CAPSLOCK ; caps lock on ? |
jz .no_caps_lock |
test dl, VKEY_SHIFT ; shift on ? |
jz .keymap_shif |
jmp @f |
;-------------------------------------- |
.no_caps_lock: |
test dl, VKEY_SHIFT ; shift on ? |
jz @f |
.keymap_shif: |
mov bl, [keymap_shift+eax] |
@@: |
test dl, VKEY_ALT ; alt on ? |
jz @f |
mov bl, [keymap_alt+eax] |
@@: |
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 |
xor [kb_state], eax |
xor [kb_lights], bl |
.writekey: |
pushad |
; test for system hotkeys |
movzx eax, ch |
cmp bh, 1 |
ja .nohotkey |
jb @f |
xor eax, eax |
@@: |
mov eax, [hotkey_scancodes + eax*4] |
.hotkey_loop: |
test eax, eax |
jz .nohotkey |
mov cl, 0 |
call hotkey_do_test |
jc .hotkey_cont |
mov cl, 2 |
call hotkey_do_test |
jc .hotkey_cont |
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 |
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 |
xor eax, eax |
@@: |
mov [edi+4], ax |
mov eax, [kb_state] |
mov [edi+6], ax |
cmp [PID_lock_input], dword 0 |
je .nohotkey |
popad |
jmp .exit.irq1 |
;-------------------------------------- |
.nohotkey: |
popad |
cmp [keyboard_mode], 0; return from keymap |
jne .scancode |
test bh, bh |
jnz .exit.irq1 |
test bl, bl |
jz .exit.irq1 |
cmp cl, 0xE0 ; extended keycode |
jne @f |
cmp ch, 53 |
jne .dowrite |
mov bl, '/' |
jmp .dowrite |
@@: |
cmp ch, 55 |
jne @f |
mov bl, '*' |
jmp .dowrite |
@@: |
cmp ch, 74 |
jne @f |
mov bl, '-' |
jmp .dowrite |
@@: |
cmp ch, 78 |
jne @f |
mov bl, '+' |
jmp .dowrite |
@@: |
test [kb_state], VKEY_NUMLOCK |
jz .dowrite |
cmp ch, 71 |
jb .dowrite |
cmp ch, 83 |
ja .dowrite |
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 |
; store ascii or scancode |
mov [KEY_BUFF+eax-1], bl |
; store original scancode |
add eax, 120+2 |
push ecx |
cmp [keyboard_mode], 0; return from keymap |
je @f |
xor ch, ch |
@@: |
mov [KEY_BUFF+eax-1], ch |
pop ecx |
sub eax, 120+2 |
.exit.irq1: |
ret |
;--------------------------------------------------------------------- |
set_lights: |
push ebx esi |
mov ecx, keyboard_list_mutex |
call mutex_lock |
mov esi, keyboards |
.loop: |
mov esi, [esi+KEYBOARD.next] |
cmp esi, keyboards |
jz .done |
mov eax, [esi+KEYBOARD.functions] |
cmp dword [eax], KBDFUNC.setlights |
jbe .loop |
mov eax, [eax+KBDFUNC.setlights] |
test eax, eax |
jz .loop |
stdcall eax, [esi+KEYBOARD.userdata], dword [kb_lights] |
jmp .loop |
.done: |
mov ecx, keyboard_list_mutex |
call mutex_unlock |
pop esi ebx |
ret |
ps2_set_lights: |
stdcall disable_irq, 1 |
mov al, 0xED |
call kb_write_wait_ack |
mov al, [esp+8] |
call kb_write_wait_ack |
stdcall enable_irq, 1 |
ret 8 |
;// mike.dld ] |
proc check_lights_state_has_work? |
mov al, [kb_lights] |
cmp al, [old_kb_lights] |
ret |
endp |
check_lights_state: |
call check_lights_state_has_work? |
jz .nothing |
mov [old_kb_lights], al |
call set_lights |
.nothing: |
ret |
;--------------------------------------------------------------------- |
iglobal |
numlock_map db '789-456+1230.' |
endg |
;--------------------------------------------------------------------- |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibrios-pe-clevermouse/hid/mousedrv.inc |
---|
0,0 → 1,567 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
; check mouse |
; |
; |
; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y |
; FB10 -> FB17 mouse color mem |
; FB21 x move |
; FB22 y move |
; FB30 color temp |
; FB28 high bits temp |
; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under |
; FC00 -> FCFE com1/ps2 buffer |
; FCFF com1/ps2 buffer count starting from FC00 |
uglobal |
;-------------------------------------- |
align 4 |
mousecount dd ? |
mousedata dd ? |
Y_UNDER_sub_CUR_hot_y_add_curh dw ? |
Y_UNDER_subtraction_CUR_hot_y dw ? |
X_UNDER_sub_CUR_hot_x_add_curh dw ? |
X_UNDER_subtraction_CUR_hot_x dw ? |
endg |
iglobal |
;-------------------------------------- |
align 4 |
mouse_speed_factor dw 4 |
mouse_delay db 3 |
mouse_doubleclick_delay db 64 |
endg |
;----------------------------------------------------------------------------- |
align 4 |
draw_mouse_under: |
; return old picture |
cmp [_display.restore_cursor], 0 |
je @F |
pushad |
movzx eax, word [X_UNDER] |
movzx ebx, word [Y_UNDER] |
stdcall [_display.restore_cursor], eax, ebx |
popad |
ret |
@@: |
pushad |
xor ecx, ecx |
xor edx, edx |
mres: |
movzx eax, word [X_UNDER] |
movzx ebx, word [Y_UNDER] |
add eax, ecx |
add ebx, edx |
push ecx |
push edx |
push eax |
push ebx |
mov eax, edx |
shl eax, 6 |
shl ecx, 2 |
add eax, ecx |
add eax, mouseunder |
mov ecx, [eax] |
pop ebx |
pop eax |
mov edi, 1 ; force |
or ecx, 0x04000000 ; don't save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
pop edx |
pop ecx |
inc ecx |
cmp ecx, 16 |
jnz mres |
xor ecx, ecx |
inc edx |
cmp edx, 24 |
jnz mres |
popad |
ret |
;----------------------------------------------------------------------------- |
align 4 |
save_draw_mouse: |
cmp [_display.move_cursor], 0 |
je .no_hw_cursor |
pushad |
mov [X_UNDER], ax |
mov [Y_UNDER], bx |
movzx eax, word [MOUSE_Y] |
movzx ebx, word [MOUSE_X] |
push eax |
push ebx |
; mov ecx, [Screen_Max_X] |
; inc ecx |
; mul ecx |
mov eax, [d_width_calc_area + eax*4] |
add eax, [_display.win_map] |
movzx edx, byte [ebx+eax] |
shl edx, 8 |
mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
cmp esi, [current_cursor] |
je .draw |
mov eax, [thread_count] |
movzx eax, word [WIN_POS+eax*2] |
shl eax, 8 |
cmp eax, edx |
je @F |
mov esi, [def_cursor] |
cmp esi, [current_cursor] |
je .draw |
@@: |
push esi |
call [_display.select_cursor] |
mov [current_cursor], esi |
;-------------------------------------- |
align 4 |
.draw: |
stdcall [_display.move_cursor], esi |
popad |
ret |
;-------------------------------------- |
;align 4 |
;.fail: |
; mov ecx, [def_cursor] |
; mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
; stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax |
; popad |
; ret |
;-------------------------------------- |
align 4 |
.no_hw_cursor: |
pushad |
; save & draw |
mov [X_UNDER], ax |
mov [Y_UNDER], bx |
push eax |
push ebx |
mov ecx, 0 |
mov edx, 0 |
;-------------------------------------- |
align 4 |
drm: |
push eax |
push ebx |
push ecx |
push edx |
; helloworld |
push ecx |
add eax, ecx ; save picture under mouse |
add ebx, edx |
push ecx |
or ecx, 0x04000000 ; don't load to mouseunder area |
push eax ebx edx edi |
call [GETPIXEL] |
pop edi edx ebx eax |
mov [COLOR_TEMP], ecx |
pop ecx |
mov eax, edx |
shl eax, 6 |
shl ecx, 2 |
add eax, ecx |
add eax, mouseunder |
mov ebx, [COLOR_TEMP] |
and ebx, 0xffffff |
mov [eax], ebx |
pop ecx |
mov edi, edx ; y cycle |
shl edi, 4 ; *16 bytes per row |
add edi, ecx ; x cycle |
mov esi, edi |
add edi, esi |
add edi, esi ; *3 |
add edi, [MOUSE_PICTURE] ; we have our str address |
mov esi, edi |
add esi, 16*24*3 |
push ecx |
mov ecx, [COLOR_TEMP] |
call combine_colors |
and ecx, 0xffffff |
mov [MOUSE_COLOR_MEM], ecx |
pop ecx |
pop edx |
pop ecx |
pop ebx |
pop eax |
add eax, ecx ; we have x coord+cycle |
add ebx, edx ; and y coord+cycle |
push ecx |
mov ecx, [MOUSE_COLOR_MEM] |
mov edi, 1 ; force |
or ecx, 0x04000000 ; don't save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
pop ecx |
mov ebx, [esp+0] ; pure y coord again |
mov eax, [esp+4] ; and x |
inc ecx ; +1 cycle |
cmp ecx, 16 ; if more than 16 |
jnz drm |
xor ecx, ecx |
inc edx |
cmp edx, 24 |
jnz drm |
add esp, 8 |
popad |
ret |
;----------------------------------------------------------------------------- |
align 4 |
combine_colors: |
; in |
; ecx - color ( 00 RR GG BB ) |
; edi - ref to new color byte |
; esi - ref to alpha byte |
; |
; out |
; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
push eax |
push ebx |
push edx |
push ecx |
xor ecx, ecx |
; byte 0 |
mov eax, 0xff |
sub al, [esi+0] |
mov ebx, [esp] |
shr ebx, 16 |
and ebx, 0xff |
mul ebx |
shr eax, 8 |
add ecx, eax |
xor eax, eax |
xor ebx, ebx |
mov al, [edi+0] |
mov bl, [esi+0] |
mul ebx |
shr eax, 8 |
add ecx, eax |
shl ecx, 8 |
; byte 1 |
mov eax, 0xff |
sub al, [esi+1] |
mov ebx, [esp] |
shr ebx, 8 |
and ebx, 0xff |
mul ebx |
shr eax, 8 |
add ecx, eax |
xor eax, eax |
xor ebx, ebx |
mov al, [edi+1] |
mov bl, [esi+1] |
mul ebx |
shr eax, 8 |
add ecx, eax |
shl ecx, 8 |
; byte 2 |
mov eax, 0xff |
sub al, [esi+2] |
mov ebx, [esp] |
and ebx, 0xff |
mul ebx |
shr eax, 8 |
add ecx, eax |
xor eax, eax |
xor ebx, ebx |
mov al, [edi+2] |
mov bl, [esi+2] |
mul ebx |
shr eax, 8 |
add ecx, eax |
pop eax |
pop edx |
pop ebx |
pop eax |
ret |
;----------------------------------------------------------------------------- |
align 4 |
check_mouse_area_for_getpixel: |
; in: |
; eax = x |
; ebx = y |
; out: |
; ecx = new color |
push eax ebx |
; check for Y |
xor ecx, ecx |
mov cx, [Y_UNDER] ; [MOUSE_Y] |
cmp ebx, ecx |
jb .no_mouse_area |
add ecx, 23 ; mouse cursor Y size |
cmp ebx, ecx |
ja .no_mouse_area |
; offset Y |
sub bx, [Y_UNDER] ; [MOUSE_Y] |
;-------------------------------------- |
; check for X |
xor ecx, ecx |
mov cx, [X_UNDER] ; [MOUSE_X] |
cmp eax, ecx |
jb .no_mouse_area |
add ecx, 15 ; mouse cursor X size |
cmp eax, ecx |
ja .no_mouse_area |
; offset X |
sub ax, [X_UNDER] ; [MOUSE_X] |
;-------------------------------------- |
; eax = offset x |
; ebx = offset y |
shl ebx, 6 ;y |
shl eax, 2 ;x |
add eax, ebx |
add eax, mouseunder |
mov ecx, [eax] |
and ecx, 0xffffff |
or ecx, 0xff000000 |
pop ebx eax |
ret |
.no_mouse_area: |
xor ecx, ecx |
pop ebx eax |
ret |
;----------------------------------------------------------------------------- |
align 4 |
check_mouse_area_for_putpixel: |
; in: |
; ecx = x shl 16 + y |
; eax = color |
; out: |
; eax = new color |
push eax |
; check for Y |
mov ax, [Y_UNDER] ; [MOUSE_Y] |
cmp cx, ax |
jb .no_mouse_area |
add ax, 23 ; mouse cursor Y size |
cmp cx, ax |
ja .no_mouse_area |
; offset Y |
sub cx, [Y_UNDER] ; [MOUSE_Y] |
mov ax, cx |
shl eax, 16 |
; check for X |
mov ax, [X_UNDER] ; [MOUSE_X] |
shr ecx, 16 |
cmp cx, ax |
jb .no_mouse_area |
add ax, 15 ; mouse cursor X size |
cmp cx, ax |
ja .no_mouse_area |
; offset X |
sub cx, [X_UNDER] ; [MOUSE_X] |
mov ax, cx |
; eax = (offset y) shl 16 + (offset x) |
pop ecx |
push eax ebx |
mov ebx, eax |
shr ebx, 16 ; y |
and eax, 0xffff ; x |
shl ebx, 6 |
shl eax, 2 |
add eax, ebx |
add eax, mouseunder |
and ecx, 0xFFFFFF |
mov [eax], ecx |
pop ebx eax |
push esi edi |
rol eax, 16 |
movzx edi, ax ; y cycle |
shl edi, 4 ; *16 bytes per row |
shr eax, 16 |
add edi, eax ; x cycle |
lea edi, [edi*3] |
add edi, [MOUSE_PICTURE] ; we have our str address |
mov esi, edi |
add esi, 16*24*3 |
call combine_colors |
pop edi esi |
mov eax, ecx |
ret |
.no_mouse_area: |
pop eax |
ret |
;----------------------------------------------------------------------------- |
align 4 |
__sys_draw_pointer: |
pushad |
movzx ecx, word [X_UNDER] |
movzx edx, word [Y_UNDER] |
movzx ebx, word [MOUSE_Y] |
movzx eax, word [MOUSE_X] |
cmp [redrawmouse_unconditional], 0 |
je @f |
mov [redrawmouse_unconditional], 0 |
jmp redrawmouse |
@@: |
cmp eax, ecx |
jne redrawmouse |
cmp ebx, edx |
je nodmp |
;-------------------------------------- |
align 4 |
redrawmouse: |
pushfd |
cli |
call draw_mouse_under |
call save_draw_mouse |
; mov eax, [_display.select_cursor] |
; test eax, eax |
; jz @f |
cmp [_display.select_cursor], select_cursor |
jne @f |
xor eax, eax |
mov esi, [current_cursor] |
mov ax, [Y_UNDER] |
sub eax, [esi+CURSOR.hot_y] |
mov [Y_UNDER_subtraction_CUR_hot_y], ax |
add eax, [cur.h] |
mov [Y_UNDER_sub_CUR_hot_y_add_curh], ax |
mov ax, [X_UNDER] |
sub eax, [esi+CURSOR.hot_x] |
mov [X_UNDER_subtraction_CUR_hot_x], ax |
add eax, [cur.w] |
mov [X_UNDER_sub_CUR_hot_x_add_curh], ax |
@@: |
popfd |
nodmp: |
popad |
ret |
;----------------------------------------------------------------------------- |
align 4 |
proc set_mouse_data stdcall uses ecx edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
mov eax, [BtnState] |
and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements |
mov [BTN_DOWN], eax |
;-------------------------------------- |
mov eax, [XMoving] |
test [BtnState], 0x80000000 |
jnz .absolute_x |
test eax, eax |
jz @f |
call mouse_acceleration |
add ax, [MOUSE_X] |
jns .check_x |
xor eax, eax |
jmp .set_x |
.absolute_x: |
mov edx, [_display.width] |
mul edx |
shr eax, 15 |
.check_x: |
cmp ax, word[_display.width] |
jl .set_x |
mov ax, word[_display.width] |
dec ax |
.set_x: |
mov [MOUSE_X], ax |
;-------------------------------------- |
@@: |
mov eax, [YMoving] |
test [BtnState], 0x40000000 |
jnz .absolute_y |
test eax, eax |
jz @f |
neg eax |
call mouse_acceleration |
add ax, [MOUSE_Y] |
jns .check_y |
xor eax, eax |
jmp .set_y |
.absolute_y: |
mov edx, [_display.height] |
mul edx |
shr eax, 15 |
.check_y: |
cmp ax, word[_display.height] |
jl .set_y |
mov ax, word[_display.height] |
dec ax |
.set_y: |
mov [MOUSE_Y], ax |
;-------------------------------------- |
@@: |
mov eax, [VScroll] |
test eax, eax |
jz @f |
add [MOUSE_SCROLL_V], ax |
bts word [BTN_DOWN], 15 |
@@: |
mov eax, [HScroll] |
test eax, eax |
jz @f |
add [MOUSE_SCROLL_H], ax |
bts dword [BTN_DOWN], 23 |
@@: |
mov [mouse_active], 1 |
call wakeup_osloop |
ret |
endp |
;----------------------------------------------------------------------------- |
mouse_acceleration: |
neg ax |
jl mouse_acceleration |
add al, [mouse_delay] |
mul al |
mov cx, [mouse_speed_factor] |
dec ax |
shr ax, cl |
inc ax |
test eax, eax |
jns @f |
neg ax |
@@: |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibrios-pe-clevermouse/hid/set_dtc.inc |
---|
0,0 → 1,203 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision$ |
;setting date,time,clock and alarm-clock |
;add sys_settime at servetable as for ex. 22 fcn: |
; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK |
; ebx =0 - set time ecx - 00SSMMHH |
; ebx =1 - set date ecx=00DDMMYY |
; ebx =2 - set day of week ecx- 1-7 |
; ebx =3 - set alarm-clock ecx - 00SSMMHH |
; out: 0 -Ok 1 -wrong format 2 -battery low |
sys_settime: |
cli |
mov al, 0x0d |
out 0x70, al |
in al, 0x71 |
bt ax, 7 |
jnc bat_low |
cmp ebx, 2;day of week |
jne nosetweek |
test ecx, ecx ;test day of week |
je wrongtime |
cmp ecx, 7 |
ja wrongtime |
mov edx, 0x70 |
call startstopclk |
dec edx |
mov al, 6 |
out dx, al |
inc edx |
mov al, cl |
out dx, al |
jmp endsettime |
nosetweek: ;set date |
cmp ebx, 1 |
jne nosetdate |
cmp cl, 0x99;test year |
ja wrongtime |
shl ecx, 4 |
cmp cl, 0x90 |
ja wrongtime |
cmp ch, 0x99;test month |
ja wrongtime |
shr ecx, 4 |
test ch, ch |
je wrongtime |
cmp ch, 0x12 |
ja wrongtime |
shl ecx, 8 |
bswap ecx ;ebx=00YYMMDD |
test cl, cl ;test day |
je wrongtime |
shl ecx, 4 |
cmp cl, 0x90 |
ja wrongtime |
shr ecx, 4 |
cmp ch, 2 ;February |
jne testday |
cmp cl, 0x29 |
ja wrongtime |
jmp setdate |
testday: |
cmp ch, 8 |
jb testday1;Aug-Dec |
bt cx, 8 |
jnc days31 |
jmp days30 |
testday1: |
bt cx, 8 ;Jan-Jul ex.Feb |
jnc days30 |
days31: |
cmp cl, 0x31 |
ja wrongtime |
jmp setdate |
days30: |
cmp cl, 0x30 |
ja wrongtime |
setdate: |
mov edx, 0x70 |
call startstopclk |
dec edx |
mov al, 7 ;set days |
out dx, al |
inc edx |
mov al, cl |
out dx, al |
dec edx |
mov al, 8 ;set months |
out dx, al |
inc edx |
mov al, ch |
out dx, al |
dec edx |
mov al, 9 ;set years |
out dx, al |
inc edx |
shr ecx, 8 |
mov al, ch |
out dx, al |
jmp endsettime |
nosetdate: ;set time or alarm-clock |
cmp ebx, 3 |
ja wrongtime |
cmp cl, 0x23 |
ja wrongtime |
cmp ch, 0x59 |
ja wrongtime |
shl ecx, 4 |
cmp cl, 0x90 |
ja wrongtime |
cmp ch, 0x92 |
ja wrongtime |
shl ecx, 4 |
bswap ecx ;00HHMMSS |
cmp cl, 0x59 |
ja wrongtime |
shl ecx, 4 |
cmp cl, 0x90 |
ja wrongtime |
shr ecx, 4 |
mov edx, 0x70 |
call startstopclk |
dec edx |
cmp ebx, 3 |
je setalarm |
xor eax, eax;al=0-set seconds |
out dx, al |
inc edx |
mov al, cl |
out dx, al |
dec edx |
mov al, 2 ;set minutes |
out dx, al |
inc edx |
mov al, ch |
out dx, al |
dec edx |
mov al, 4 ;set hours |
out dx, al |
inc edx |
shr ecx, 8 |
mov al, ch |
out dx, al |
jmp endsettime |
setalarm: |
mov al, 1;set seconds for al. |
out dx, al |
inc edx |
mov al, cl |
out dx, al |
dec edx |
mov al, 3;set minutes for al. |
out dx, al |
inc edx |
mov al, ch |
out dx, al |
dec edx |
mov al, 5;set hours for al. |
out dx, al |
inc edx |
shr ecx, 8 |
mov al, ch |
out dx, al |
dec edx |
mov al, 0x0b;enable irq's |
out dx, al |
inc dx |
in al, dx |
bts ax, 5;set bit 5 |
out dx, al |
endsettime: |
dec edx |
call startstopclk |
sti |
and [esp+36-4], dword 0 |
ret |
bat_low: |
sti |
mov [esp+36-4], dword 2 |
ret |
wrongtime: |
sti |
mov [esp+36-4], dword 1 |
ret |
startstopclk: |
mov al, 0x0b |
out dx, al |
inc dx |
in al, dx |
btc ax, 7 |
out dx, al |
ret |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Rev |
\ No newline at end of property |
/kernel/branches/kolibrios-pe-clevermouse/hid/. |
---|
Property changes: |
Added: svn:ignore |
+*.mnt |
+lang.inc |
+*.bat |
+out.txt |
+scin* |
+*.obj |