git-svn-id: https://spexeah.com:8443/svn/Asuro@96 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
aaron 2017-05-18 13:41:54 +00:00
parent 9a2294863b
commit 92e0db5eb4
2 changed files with 42 additions and 27 deletions

View File

@ -34,13 +34,52 @@ procedure init();
procedure callback(scan_code : void); procedure callback(scan_code : void);
procedure buffer_push_sc(scan_code : uInt8); procedure buffer_push_sc(scan_code : uInt8);
procedure lang_UK();
procedure lang_USA();
implementation implementation
procedure init(); procedure init(pchar keyboard_layout);
begin begin
memset(uint32(@key_matrix[0]), 0, sizeof(TKeyInfo)*256); memset(uint32(@key_matrix[0]), 0, sizeof(TKeyInfo)*256);
memset(uint32(@key_buffer), 0, sizeof(TKeyInfo)); memset(uint32(@key_buffer), 0, sizeof(TKeyInfo)*128);
case keyboard_layout of
'USA' : lang_USA();
'UK' : lang_UK();
end;
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));
end;
end;
procedure buffer_push_sc(scan_code : uInt8);
var
i : uInt8;
begin
for i:=127 downto 1 do begin
key_buffer[i] := key_buffer[i - 1];
end;
key_buffer[0] := key_matrix[scan_code];
end;
procedure lang_UK();
begin
end;
procedure lang_USA();
begin
key_matrix[1].key_code := $1B; key_matrix[1].key_code := $1B;
key_matrix[2].key_code := $31; key_matrix[2].key_code := $31;
key_matrix[3].key_code := $32; key_matrix[3].key_code := $32;
@ -112,30 +151,6 @@ begin
key_matrix[87].key_code := $85; key_matrix[87].key_code := $85;
key_matrix[88].key_code := $86; key_matrix[88].key_code := $86;
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));
end;
console.writechar(char(key_buffer[0].key_code));
end;
procedure buffer_push_sc(scan_code : uInt8);
var
i : uInt32;
begin
for i:=127 downto 2 do begin
key_buffer[i] = key_buffer[i - 1];
end;
key_buffer[0] = key_matrix[scan_code];
end; end;
end. end.

View File

@ -49,7 +49,7 @@ begin
isr32.hook(uint32(@bios_data_area.tick_update)); isr32.hook(uint32(@bios_data_area.tick_update));
//drivers //drivers
keyboard.init(); keyboard.init('USA');
asm asm
MOV dds, CS MOV dds, CS