Updated keyboard driver.
git-svn-id: https://spexeah.com:8443/svn/Asuro@213 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
		@@ -25,48 +25,38 @@ type
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    PKeyInfo = ^TKeyInfo;
 | 
					    PKeyInfo = ^TKeyInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pp_hook_method = procedure(key_info : TKeyInfo);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
    key_matrix : array [1..256] of TKeyInfo;
 | 
					    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 init(keyboard_layout : array of TKeyInfo);
 | 
				
			||||||
procedure callback(scan_code : void);
 | 
					procedure hook(proc : pp_hook_method);
 | 
				
			||||||
procedure buffer_push_sc(scan_code : uInt8);
 | 
					 | 
				
			||||||
procedure lang_USA();
 | 
					procedure lang_USA();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
implementation
 | 
					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);
 | 
					procedure callback(scan_code : void);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
    if key_matrix[uint8(scan_code)].key_code <> 0 then begin
 | 
					    if key_matrix[uint8(scan_code)].key_code <> 0 then begin
 | 
				
			||||||
        buffer_push_sc(uint8(scan_code));
 | 
					        if captin_hook <> nil then captin_hook(key_matrix[uint8(scan_code)]);
 | 
				
			||||||
        console.writechar(char(key_buffer[0].key_code));
 | 
					 | 
				
			||||||
        console.writehexln(uint8(scan_code));
 | 
					 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure buffer_push_sc(scan_code : uInt8);
 | 
					procedure init(keyboard_layout : array of TKeyInfo);  
 | 
				
			||||||
var
 | 
					 | 
				
			||||||
    i : uInt8; 
 | 
					 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
    for i:=127 downto 1 do begin
 | 
					    if keyboard_layout[1].key_code = 0 then lang_USA();
 | 
				
			||||||
        key_buffer[i] := key_buffer[i - 1];
 | 
					    isr33.hook(uint32(@callback));
 | 
				
			||||||
    end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    key_buffer[0] := key_matrix[scan_code];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					procedure hook(proc : pp_hook_method); 
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					    captin_hook := proc;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure lang_USA();
 | 
					procedure lang_USA();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user