Keyboard tweaks/fixes.

This commit is contained in:
Sorgelig 2022-03-07 20:22:42 +08:00
parent 9f2ac6ab76
commit ea9c50291c

View File

@ -94,47 +94,38 @@ assign data_in = cmd_test ? 8'h7d :
key_pending ? (keymac[8] ? 8'h79 : keymac[7:0]) : key_pending ? (keymac[8] ? 8'h79 : keymac[7:0]) :
8'h7b; 8'h7b;
wire depress = ~ps2_key[9]; wire press = ps2_key[9];
wire extended = ps2_key[8]; wire capslock_key = (ps2_key[8:0] == 'h58);
wire ignore_capslock = {extended,ps2_key[7:0]} == 9'h058 && capslock;
/* Handle key_pending, and multi-byte keypad responses */ /* Handle key_pending, and multi-byte keypad responses */
always @(posedge clk) begin always @(posedge clk) begin
reg old_stb; reg old_stb;
if (reset) begin if(ce) begin
key_pending <= 0;
old_stb <= ps2_key[10];
capslock <= 0;
end
else if(ce) begin
if (cmd_model | cmd_test) key_pending <= 0;
else if (pop_key) begin
if (keymac[8]) keymac[8] <= 0;
else key_pending <= 0;
end else begin
old_stb <= ps2_key[10]; old_stb <= ps2_key[10];
if(old_stb != ps2_key[10]) begin if(old_stb != ps2_key[10]) begin
/* Capslock handling */ /* Capslock handling */
if(ps2_key[7:0] == 8'h58 && !extended && !depress) capslock <= ~capslock; if(capslock_key && press) capslock <= ~capslock;
if(!key_pending && !ignore_capslock) begin if(!key_pending && !(capslock_key && capslock)) begin
key_pending <= 1; key_pending <= 1;
keymac <= {key_code[8],depress,key_code[6:0]}; keymac <= {key_code[8],~press,key_code[6:0]};
end end
end end
if (pop_key) begin
if (keymac[8]) keymac[8] <= 0;
else key_pending <= 0;
end end
end end
if (cmd_model | cmd_test | reset) key_pending <= 0;
if (reset) capslock <= 0;
end end
//use BRAM for table //use BRAM for table
wire [8:0] key_code = code[key_addr]; wire [8:0] key_code = code[ps2_key[8:0]];
reg [8:0] key_addr;
always @(posedge clk) key_addr <= {extended,ps2_key[7:0]};
wire [8:0] code[512] = wire [8:0] code[512] =
'{ '{
/* 000 */ 9'h07b, /* 000 */ 9'h07b,