]> Joshua Wise's Git repositories - vterm.git/commitdiff
Add a scancode lookup table.
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Tue, 1 Jul 2008 04:34:07 +0000 (00:34 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Tue, 1 Jul 2008 04:34:07 +0000 (00:34 -0400)
Makefile
VTerm.v
scancodes.txt [new file with mode: 0644]

index ef9e12a83a064f904e91ba951f4f06cd9d5ad21a..58574c28e01aa7e1087fd19aa8b88d48e14f29e3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,14 @@
 TARGET = VTerm
 VLOGS = VTerm.v
-VLOGS_ALL = $(VLOGS)
+VLOGS_ALL = $(VLOGS) scancodes.shifted.hex scancodes.unshifted.hex
+
+all: fpga_target
+
+scancodes.unshifted.hex: scancodes.txt
+       cut -f3 -d, scancodes.txt > scancodes.unshifted.hex
+
+scancodes.shifted.hex: scancodes.txt
+       cut -f4 -d, scancodes.txt > scancodes.shifted.hex
 
 BITGEN_OPTS = \
        -w \
@@ -26,7 +34,7 @@ BITGEN_OPTS = \
        -g DonePipe:No \
        -g DriveDone:No
 
-all: $(TARGET).svf
+fpga_target: $(TARGET).svf
 
 $(TARGET).ngc: $(TARGET).xst $(VLOGS_ALL)
        @mkdir -p xst/projnav.tmp
diff --git a/VTerm.v b/VTerm.v
index ff85303d111431451e285e68556e39b3b3b4435d..608624d4ce9964230bee39f24fe66224d96e88ea 100644 (file)
--- a/VTerm.v
+++ b/VTerm.v
@@ -364,6 +364,14 @@ module PS2(
        reg fixedclk = 0;
        reg [11:0] resetcountdown = 0;
        
+       reg [6:0] unshiftedrom [127:0]; initial $readmemh("scancodes.unshifted.hex", unshiftedrom);
+       reg [6:0] shiftedrom [127:0];   initial $readmemh("scancodes.shifted.hex", shiftedrom);
+       
+       reg mod_lshift = 0;
+       reg mod_rshift = 0;
+       reg mod_capslock = 0;
+       wire mod_shifted = (mod_lshift | mod_rshift) ^ mod_capslock;
+       
        reg nd = 0;
        reg lastnd = 0;
        
@@ -392,46 +400,30 @@ module PS2(
                        bitcount <= 0;
                        if(parity != (^ key)) begin
                                if(keyarrow) begin
-                                       keyarrow <= 0;
-                                       case(key)
+                                       casex(key)
                                                8'hF0: keyup <= 1;
+                                               8'hxx: keyarrow <= 0;
                                        endcase
                                end
                                else begin
                                        if(keyup) begin
                                                keyup <= 0;
+                                               keyarrow <= 0;
+                                               casex (key)
+                                               8'h12: mod_lshift <= 0;
+                                               8'h59: mod_rshift <= 0;
+                                               endcase
                                                // handle this? I don't fucking know
                                        end
                                        else begin
-                                               case(key)
+                                               casex(key)
                                                        8'hE0: keyarrow <= 1;   // handle these? I don't fucking know
                                                        8'hF0: keyup <= 1;
-                                                       8'h1C: begin nd <= ~nd; data <= 8'h41; end
-                                                       8'h32: begin nd <= ~nd; data <= 8'h42; end
-                                                       8'h21: begin nd <= ~nd; data <= 8'h43; end
-                                                       8'h23: begin nd <= ~nd; data <= 8'h44; end
-                                                       8'h24: begin nd <= ~nd; data <= 8'h45; end
-                                                       8'h2B: begin nd <= ~nd; data <= 8'h46; end
-                                                       8'h34: begin nd <= ~nd; data <= 8'h47; end
-                                                       8'h33: begin nd <= ~nd; data <= 8'h48; end
-                                                       8'h43: begin nd <= ~nd; data <= 8'h49; end
-                                                       8'h3B: begin nd <= ~nd; data <= 8'h4A; end
-                                                       8'h42: begin nd <= ~nd; data <= 8'h4B; end
-                                                       8'h4B: begin nd <= ~nd; data <= 8'h4C; end
-                                                       8'h3A: begin nd <= ~nd; data <= 8'h4D; end
-                                                       8'h31: begin nd <= ~nd; data <= 8'h4E; end
-                                                       8'h44: begin nd <= ~nd; data <= 8'h4F; end
-                                                       8'h4D: begin nd <= ~nd; data <= 8'h50; end
-                                                       8'h15: begin nd <= ~nd; data <= 8'h51; end
-                                                       8'h2D: begin nd <= ~nd; data <= 8'h52; end
-                                                       8'h1B: begin nd <= ~nd; data <= 8'h53; end
-                                                       8'h2C: begin nd <= ~nd; data <= 8'h54; end
-                                                       8'h3C: begin nd <= ~nd; data <= 8'h55; end
-                                                       8'h2A: begin nd <= ~nd; data <= 8'h56; end
-                                                       8'h1D: begin nd <= ~nd; data <= 8'h57; end
-                                                       8'h22: begin nd <= ~nd; data <= 8'h58; end
-                                                       8'h35: begin nd <= ~nd; data <= 8'h59; end
-                                                       8'h1A: begin nd <= ~nd; data <= 8'h60; end
+                                                       8'h12: mod_lshift <= 1;
+                                                       8'h59: mod_rshift <= 1;
+                                                       8'h14: mod_capslock <= ~mod_capslock;
+                                                       8'b0xxxxxxx: begin nd <= ~nd; data <= mod_shifted ? shiftedrom[key] : unshiftedrom[key]; end
+                                                       8'b1xxxxxxx: begin /* AAAAAAASSSSSSSS */ end
                                                endcase
                                        end
                                end
diff --git a/scancodes.txt b/scancodes.txt
new file mode 100644 (file)
index 0000000..8134e15
--- /dev/null
@@ -0,0 +1,128 @@
+00,,0,0
+01,F9,0,0
+02,,0,0
+03,F5,0,0
+04,F3,0,0
+05,F1,0,0
+06,F2,0,0
+07,F12,0,0
+08,,0,0
+09,F10,0,0
+0A,F8,0,0
+0B,F6,0,0
+0C,F4,0,0
+0D,^I,09,09
+0E,`,60,7E
+0F,,0,0
+10,,0,0
+11,alt,0,0
+12,shift,0,0
+13,,0,0
+14,ctrl,0,0
+15,Q,71,51
+16,1,31,21
+17,,0,0
+18,,0,0
+19,,0,0
+1A,Z,7A,5A
+1B,S,73,53
+1C,A,61,41
+1D,W,77,57
+1E,2,32,40
+1F,,0,0
+20,,0,0
+21,C,63,43
+22,X,78,58
+23,D,64,44
+24,E,65,45
+25,4,34,24
+26,3,33,23
+27,,0,0
+28,,0,0
+29,space,20,20
+2A,V,76,56
+2B,F,66,46
+2C,T,74,54
+2D,R,72,52
+2E,5,33,25
+2F,,0,0
+30,,0,0
+31,N,6E,4E
+32,B,62,42
+33,H,68,48
+34,G,67,47
+35,Y,79,59
+36,6,36,5E
+37,,0,0
+38,,0,0
+39,,0,0
+3A,M,6D,4D
+3B,J,6A,4A
+3C,U,75,55
+3D,7,37,26
+3E,8,38,2A
+3F,,0,0
+40,,0,0
+41,comma,2C,3C
+42,K,6B,4B
+43,I,69,49
+44,O,6F,4F
+45,0,30,29
+46,9,39,28
+47,,0,0
+48,,0,0
+49,.,2E,2C
+4A,/,2F,3F
+4B,L,6C,4C
+4C,;,3B,3A
+4D,P,70,50
+4E,-,2D,5F
+4F,,0,0
+50,,0,0
+51,,0,0
+52,',27,22
+53,,0,0
+54,[,5B,7B
+55,=,3D,2B
+56,,0,0
+57,,0,0
+58,capslock,0,0
+59,rshift,0,0
+5A,^M,0A,0A
+5B,],5D,7D
+5C,,0,0
+5D,\,5C,7C
+5E,,0,0
+5F,,0,0
+60,,0,0
+61,,0,0
+62,,0,0
+63,,0,0
+64,,0,0
+65,,0,0
+66,^H,08,08
+67,,0,0
+68,,0,0
+69,,0,0
+6A,,0,0
+6B,,0,0
+6C,,0,0
+6D,,0,0
+6E,,0,0
+6F,,0,0
+70,,0,0
+71,,0,0
+72,,0,0
+73,,0,0
+74,,0,0
+75,,0,0
+76,ESC,1B,1B
+77,,0,0
+78,F11,0,0
+79,,0,0
+7A,,0,0
+7B,,0,0
+7C,,0,0
+7D,,0,0
+7E,,0,0
+7F,,0,0
\ No newline at end of file
This page took 0.033774 seconds and 4 git commands to generate.