ps2: add shift support

This commit is contained in:
Virgil Dupras 2020-05-20 20:31:56 -04:00
parent b874a1c175
commit 7d28637740
3 changed files with 32 additions and 12 deletions

View File

@ -8,4 +8,9 @@
( 68 ) 0 C, '1' C, 0 C, '4' C, '7' C, 0 C, 0 C, 0 C, ( 68 ) 0 C, '1' C, 0 C, '4' C, '7' C, 0 C, 0 C, 0 C,
( 70 ) '0' C, '.' C, '2' C, '5' C, '6' C, '8' C, 27 C, 0 C, ( 70 ) '0' C, '.' C, '2' C, '5' C, '6' C, '8' C, 27 C, 0 C,
( 78 ) 0 C, 0 C, '3' C, 0 C, 0 C, '9' C, 0 C, 0 C, ( 78 ) 0 C, 0 C, '3' C, 0 C, 0 C, '9' C, 0 C, 0 C,
: _shift? ( kc -- f ) DUP 0x12 = SWAP 0x59 = OR ; ( Same values, but shifted )
( 00 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C,
( 08 ) 0 C, 0 C, 0 C, 0 C, 0 C, 9 C, '~' C, 0 C,
( 10 ) 0 C, 0 C, 0 C, 0 C, 0 C, 'Q' C, '!' C, 0 C,
( 18 ) 0 C, 0 C, 'Z' C, 'S' C, 'A' C, 'W' C, '@' C, 0 C,
( 20 ) 0 C, 'C' C, 'X' C, 'D' C, 'E' C, '$' C, '#' C, 0 C,

22
blk/413
View File

@ -1,12 +1,12 @@
: (key) 0 ( dummy ) BEGIN DROP (ps2kc) DUP UNTIL ( kc ) ( 28 ) 0 C, 32 C, 'V' C, 'F' C, 'T' C, 'R' C, '%' C, 0 C,
DUP 0xe0 ( extended ) = IF ( ignore ) DROP (key) EXIT THEN ( 30 ) 0 C, 'N' C, 'B' C, 'H' C, 'G' C, 'Y' C, '^' C, 0 C,
DUP 0xf0 ( break ) = IF DROP ( ) ( 38 ) 0 C, 0 C, 'M' C, 'J' C, 'U' C, '&' C, '*' C, 0 C,
( get next key and see if it's a shift ) ( 40 ) 0 C, '<' C, 'K' C, 'I' C, 'O' C, ')' C, '(' C, 0 C,
(key) _shift? IF ( drop shift ) 0 PS2_SHIFT ! THEN ( 48 ) 0 C, '>' C, '?' C, 'L' C, ':' C, 'P' C, '_' C, 0 C,
( whether we had a shift or not, we return the next ) ( 50 ) 0 C, 0 C, '"' C, 0 C, '{' C, '+' C, 0 C, 0 C,
(key) EXIT THEN ( 58 ) 0 C, 0 C, 13 C, '}' C, 0 C, '|' C, 0 C, 0 C,
DUP 0x7f > IF DROP (key) EXIT THEN ( 60 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 8 C, 0 C,
DUP _shift? IF DROP 1 PS2_SHIFT ! (key) EXIT THEN ( 68 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C,
( ah, finally, we have a gentle run-of-the-mill KC ) ( 70 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 27 C, 0 C,
PS2_CODES + C@ DUP NOT IF DROP (key) EXIT THEN ; ( 78 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C,

15
blk/414 Normal file
View File

@ -0,0 +1,15 @@
: _shift? ( kc -- f ) DUP 0x12 = SWAP 0x59 = OR ;
: _get ( -- kc ) 0 ( dummy ) BEGIN DROP (ps2kc) DUP UNTIL ;
: (key) _get
DUP 0xe0 ( extended ) = IF ( ignore ) DROP (key) EXIT THEN
DUP 0xf0 ( break ) = IF DROP ( )
( get next kc and see if it's a shift )
_get _shift? IF ( drop shift ) 0 PS2_SHIFT C! THEN
( whether we had a shift or not, we return the next )
(key) EXIT THEN
DUP 0x7f > IF DROP (key) EXIT THEN
DUP _shift? IF DROP 1 PS2_SHIFT C! (key) EXIT THEN
( ah, finally, we have a gentle run-of-the-mill KC )
PS2_CODES PS2_SHIFT @ IF 0x80 + THEN + C@
DUP NOT IF DROP (key) THEN ;