From ce96116465ff9da95a75e99f28e0830ec7f86fee Mon Sep 17 00:00:00 2001 From: "Marat Zakiyanov (Mario79)" Date: Tue, 25 Feb 2014 01:03:37 +0000 Subject: [PATCH] Function 2 (get the code of the pressed key) for AL = 0 in EAX bits 16-23 = contain scancode for pressed key git-svn-id: svn://kolibrios.org@4588 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/const.inc | 2 +- kernel/trunk/docs/sysfuncr.txt | 3 ++- kernel/trunk/docs/sysfuncs.txt | 4 +++- kernel/trunk/gui/event.inc | 6 +++++- kernel/trunk/hid/keyboard.inc | 7 ++++++- kernel/trunk/kernel.asm | 7 ++++++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 27d5c33dcb..70a51b54e2 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -205,7 +205,7 @@ FDD_BUFF equ (OS_BASE+0x000D000) ;512 WIN_TEMP_XY equ (OS_BASE+0x000F300) KEY_COUNT equ (OS_BASE+0x000F400) -KEY_BUFF equ (OS_BASE+0x000F401) +KEY_BUFF equ (OS_BASE+0x000F401) ; 120*2 + 2*2 = 244 bytes, actually 255 bytes BTN_COUNT equ (OS_BASE+0x000F500) BTN_BUFF equ (OS_BASE+0x000F501) diff --git a/kernel/trunk/docs/sysfuncr.txt b/kernel/trunk/docs/sysfuncr.txt index eec630d53d..93b3c01bf7 100644 --- a/kernel/trunk/docs/sysfuncr.txt +++ b/kernel/trunk/docs/sysfuncr.txt @@ -151,7 +151,8 @@ Возвращаемое значение: * если буфер пуст, возвращается eax=1 * если буфер непуст, то возвращается al=0, ah=код нажатой клавиши, - старшее слово регистра eax обнулено + биты 16-23 содержат сканкод нажатой клавиши, + биты 23-31 обнулены * если есть "горячая клавиша", то возвращается al=2, ah=сканкод нажатой клавиши (0 для управляющих клавиш), старшее слово регистра eax содержит состояние управляющих клавиш diff --git a/kernel/trunk/docs/sysfuncs.txt b/kernel/trunk/docs/sysfuncs.txt index d84e213c5f..af863fe714 100644 --- a/kernel/trunk/docs/sysfuncs.txt +++ b/kernel/trunk/docs/sysfuncs.txt @@ -148,7 +148,9 @@ Parameters: Returned value: * if the buffer is empty, function returns eax=1 * if the buffer is not empty, function returns al=0, - ah=code of the pressed key, high word of eax is zero + ah=code of the pressed key, + bits 16-23 = contain scancode for pressed key, + bits 23-31 = zero * if there is "hotkey", function returns al=2, ah=scancode of the pressed key (0 for control keys), high word of eax contains a status of control keys at the moment diff --git a/kernel/trunk/gui/event.inc b/kernel/trunk/gui/event.inc index 3ee514d222..4aa9da8f70 100644 --- a/kernel/trunk/gui/event.inc +++ b/kernel/trunk/gui/event.inc @@ -454,7 +454,11 @@ align 4 cmp al, 120 jae .result ;overflow inc byte[KEY_COUNT] - mov [KEY_COUNT+1+eax], dl + mov [KEY_BUFF+eax], dl +; store empty scancode + add eax, 120+2 + mov [KEY_BUFF+eax], byte 0 + sub eax, 120+2 ;-------------------------------------- align 4 .result: diff --git a/kernel/trunk/hid/keyboard.inc b/kernel/trunk/hid/keyboard.inc index 83ee8f8c54..829330d08c 100644 --- a/kernel/trunk/hid/keyboard.inc +++ b/kernel/trunk/hid/keyboard.inc @@ -488,7 +488,12 @@ send_scancode: jae .exit.irq1 inc eax mov [KEY_COUNT], al - mov [KEY_COUNT+eax], bl +; store ascii or scancode + mov [KEY_COUNT+eax], bl ; actually KEY_BUFF + EAX - 1 +; store original scancode + add eax, 120+2 + mov [KEY_COUNT+eax], ch ; actually KEY_BUFF + EAX - 1 + sub eax, 120+2 .exit.irq1: ret ;--------------------------------------------------------------------- diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index ac10f44e4b..02861399fe 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -3129,7 +3129,9 @@ sys_getkey: jne .finish cmp [KEY_COUNT], byte 0 je .finish - movzx eax, byte [KEY_BUFF] + movzx ax, byte [KEY_BUFF + 120 + 2] + shl eax, 8 + mov al, byte [KEY_BUFF] shl eax, 8 push eax dec byte [KEY_COUNT] @@ -3139,6 +3141,9 @@ sys_getkey: 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