From bf523330dae3294ff9eca690a3818e9f03644eac Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Fri, 7 Aug 2015 13:18:23 +0000 Subject: [PATCH] VNC viewer: improved keyboard support git-svn-id: svn://kolibrios.org@5693 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network/vncc/gui.inc | 2 +- programs/network/vncc/keymap.inc | 119 +++++++++++-------------------- programs/network/vncc/vncc.asm | 58 ++++++++++----- 3 files changed, 83 insertions(+), 96 deletions(-) diff --git a/programs/network/vncc/gui.inc b/programs/network/vncc/gui.inc index f9e9d41f2..7cb410076 100644 --- a/programs/network/vncc/gui.inc +++ b/programs/network/vncc/gui.inc @@ -28,7 +28,7 @@ draw_gui: cmp [status], STATUS_CONNECTING ja @f - mov ebx, 25 shl 16 + 14 + mov ebx, 25 shl 16 + 24 xor ecx, ecx mov edx, serverstr mov esi, userstr-serverstr diff --git a/programs/network/vncc/keymap.inc b/programs/network/vncc/keymap.inc index 6372923d3..e4d69e5a8 100644 --- a/programs/network/vncc/keymap.inc +++ b/programs/network/vncc/keymap.inc @@ -19,19 +19,13 @@ generate_keymap: mcall 26, 2, 2, keymap_shift+128 mcall 26, 2, 3, keymap_alt+128 - mov esi, keymap+128 mov edi, keymap - mov ecx, 128 call convert_keymap - mov esi, keymap_shift+128 mov edi, keymap_shift - mov ecx, 128 call convert_keymap - mov esi, keymap_alt+128 mov edi, keymap_alt - mov ecx, 128 call convert_keymap ret @@ -39,83 +33,50 @@ generate_keymap: convert_keymap: + + push edi + lea esi, [edi+128] + mov ecx, 128 + xor eax, eax .loop: lodsb - - cmp al, 0x08 ; Backspace - jne @f - mov ax, 0x08ff - jmp .next - @@: - cmp al, 0x09 ; Tab - jne @f - mov ax, 0x09ff - jmp .next - @@: - cmp al, 0x0d ; Enter - jne @f - mov ax, 0x0dff - jmp .next - @@: - cmp al, 0x1b ; Escape - jne @f - mov ax, 0x1bff - jmp .next - @@: - cmp al, 0x34 ; Insert - jne @f - mov ax, 0x63ff - jmp .next - @@: - cmp al, 0xb6 ; Delete - jne @f - mov ax, 0xffff - jmp .next - @@: - cmp al, 0xb4 ; Home - jne @f - mov ax, 0x50ff - jmp .next - @@: - cmp al, 0xb5 ; End - jne @f - mov ax, 0x57ff - jmp .next - @@: - cmp al, 0xb8 ; PgUp - jne @f - mov ax, 0x55ff - jmp .next - @@: - cmp al, 0xb7 ; PgDown - jne @f - mov ax, 0x56ff - jmp .next - @@: - cmp al, 0xb0 ; Left - jne @f - mov ax, 0x51ff - jmp .next - @@: - cmp al, 0xb2 ; Up - jne @f - mov ax, 0x52ff - jmp .next - @@: - cmp al, 0xb3 ; Right - jne @f - mov ax, 0x53ff - jmp .next - @@: - cmp al, 0xb1 ; Down - jne @f - mov ax, 0x54ff - jmp .next - @@: - shl ax, 8 - .next: stosw dec ecx jnz .loop + pop edi + +; Fill in some keysyms for non-ascii keys + mov word[edi+01*2], 0x1bff ; Escape + mov word[edi+14*2], 0x08ff ; Backspace + mov word[edi+15*2], 0x09ff ; Tab + mov word[edi+28*2], 0x0dff ; Enter + mov word[edi+29*2], 0xe3ff ; Left control key + mov word[edi+42*2], 0xe1ff ; Left shift + mov word[edi+54*2], 0xe2ff ; Right shift + mov word[edi+56*2], 0xe9ff ; Left alt key + mov word[edi+59*2], 0xbeff ; f1 + mov word[edi+60*2], 0xbfff ; f2 + mov word[edi+61*2], 0xc0ff ; f3 + mov word[edi+62*2], 0xc1ff ; f4 + mov word[edi+63*2], 0xc2ff ; f5 + mov word[edi+64*2], 0xc3ff ; f6 + mov word[edi+65*2], 0xc4ff ; f7 + mov word[edi+66*2], 0xc5ff ; f8 + mov word[edi+67*2], 0xc6ff ; f9 + mov word[edi+68*2], 0xc7ff ; f10 + mov word[edi+71*2], 0x50ff ; home + mov word[edi+72*2], 0x52ff ; up + mov word[edi+73*2], 0x55ff ; pg up + mov word[edi+75*2], 0x51ff ; left + mov word[edi+77*2], 0x53ff ; right + mov word[edi+79*2], 0x57ff ; end + mov word[edi+80*2], 0x54ff ; down + mov word[edi+81*2], 0x56ff ; pg down + mov word[edi+82*2], 0x63ff ; insert + mov word[edi+83*2], 0xffff ; delete + mov word[edi+87*2], 0xc8ff ; f11 + mov word[edi+88*2], 0xc9ff ; f12 + mov word[edi+91*2], 0xebff ; left super + ret \ No newline at end of file diff --git a/programs/network/vncc/vncc.asm b/programs/network/vncc/vncc.asm index a33c9c9ec..ac33e373f 100644 --- a/programs/network/vncc/vncc.asm +++ b/programs/network/vncc/vncc.asm @@ -159,11 +159,11 @@ mainloop: key: mcall 66, 3 - mov ebx, eax + mov ebx, eax ; get modifier keys - mcall 2 - cmp ah, 224 ; ext - je mainloop ;; TODO + mcall 2 ; get key scancode + cmp ah, 224 ; extended keycode? + je .extended xor al, al test ah, 0x80 ; key up? @@ -172,26 +172,46 @@ key: @@: mov byte[KeyEvent.down], al - shr eax, 7 - and eax, 0x000000fe + movzx eax, ah test ebx, 100000b ; alt? - jz @f - add eax, 512 + jz .no_alt + mov ax, [keymap_alt+eax*2] jmp .key - @@: + .no_alt: + test ebx, 11b ; shift? - jz @f - add eax, 256 - @@: + jz .no_shift + mov ax, [keymap_shift+eax*2] + jmp .key + .no_shift: + + test ebx, 10000000b ; numlock ? + jz .no_numlock + cmp al, 71 + jb .no_numlock + cmp al, 83 + ja .no_numlock + mov ah, [keymap_numlock+eax-71] + xor al, al + jmp .key + + .extended: ; extended keys always use regular keymap + mcall 2 + shr eax, 8 + jz mainloop + .no_numlock: + mov ax, [keymap+eax*2] .key: - mov ax, [keymap+eax] + test ax, ax + jz mainloop mov word[KeyEvent.key+2], ax DEBUGF 1, "Sending key: 0x%x\n", ax mcall send, [socketnum], KeyEvent, 8, 0 jmp mainloop + mouse: ; DEBUGF 1, "Sending pointer event\n" @@ -222,6 +242,12 @@ button: include_debug_strings +keymap_numlock: + db '7', '8', '9', '-' + db '4', '5', '6', '+' + db '1', '2', '3' + db '0', '.' + HandShake db "RFB 003.003", 10 ClientInit db 0 ; not shared @@ -323,9 +349,9 @@ update_gui dd 0 mouse_dd dd 0 update_framebuffer dd 0 -URLbox edit_box 235, 70, 10, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0 -USERbox edit_box 200, 90, 10, 0xffffff, 0x6f9480, 0, 0, 0, 127, username, mouse_dd, ed_focus, 0, 0 -PASSbox edit_box 200, 90, 30, 0xffffff, 0x6f9480, 0, 0, 0, 127, password, mouse_dd, ed_pass, 0, 0 +URLbox edit_box 235, 70, 20, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0 +USERbox edit_box 215, 90, 10, 0xffffff, 0x6f9480, 0, 0, 0, 127, username, mouse_dd, ed_focus, 0, 0 +PASSbox edit_box 215, 90, 30, 0xffffff, 0x6f9480, 0, 0, 0, 127, password, mouse_dd, ed_pass, 0, 0 serverstr db "server:" userstr db "username:"