Updated keyboard driver.

git-svn-id: https://spexeah.com:8443/svn/Asuro@213 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
aaron 2017-10-23 06:02:23 +00:00
parent a53754258c
commit 9d27e6cb0f

View File

@ -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;
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();