From 9d27e6cb0f19dba291d7bb62c1739c30051803a5 Mon Sep 17 00:00:00 2001 From: aaron Date: Mon, 23 Oct 2017 06:02:23 +0000 Subject: [PATCH] Updated keyboard driver. git-svn-id: https://spexeah.com:8443/svn/Asuro@213 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c --- src/driver/keyboard.pas | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/driver/keyboard.pas b/src/driver/keyboard.pas index 9a62b2b9..a0cfd826 100644 --- a/src/driver/keyboard.pas +++ b/src/driver/keyboard.pas @@ -25,48 +25,38 @@ type PKeyInfo = ^TKeyInfo; + pp_hook_method = procedure(key_info : TKeyInfo); + + var - key_matrix : array [1..256] of TKeyInfo; - key_buffer : array[1..128] of TkeyInfo; + key_matrix : array [1..256] of TKeyInfo; + captin_hook : pp_hook_method = nil; procedure init(keyboard_layout : array of TKeyInfo); -procedure callback(scan_code : void); -procedure buffer_push_sc(scan_code : uInt8); +procedure hook(proc : pp_hook_method); procedure lang_USA(); implementation -procedure init(keyboard_layout : array of TKeyInfo); -begin - memset(uint32(@key_matrix[0]), 0, sizeof(TKeyInfo)*256); - memset(uint32(@key_buffer), 0, sizeof(TKeyInfo)*128); - - if keyboard_layout[1].key_code = 0 then lang_USA(); - - isr33.hook(uint32(@callback)); - -end; procedure callback(scan_code : void); begin if key_matrix[uint8(scan_code)].key_code <> 0 then begin - buffer_push_sc(uint8(scan_code)); - console.writechar(char(key_buffer[0].key_code)); - console.writehexln(uint8(scan_code)); + if captin_hook <> nil then captin_hook(key_matrix[uint8(scan_code)]); end; end; -procedure buffer_push_sc(scan_code : uInt8); -var - i : uInt8; +procedure init(keyboard_layout : array of TKeyInfo); begin - for i:=127 downto 1 do begin - key_buffer[i] := key_buffer[i - 1]; - end; + if keyboard_layout[1].key_code = 0 then lang_USA(); + isr33.hook(uint32(@callback)); +end; - key_buffer[0] := key_matrix[scan_code]; +procedure hook(proc : pp_hook_method); +begin + captin_hook := proc; end; procedure lang_USA();