From 7d28637740e7af358dd032d1edc05034268eee7c Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 20 May 2020 20:31:56 -0400 Subject: [PATCH] ps2: add shift support --- blk/412 | 7 ++++++- blk/413 | 22 +++++++++++----------- blk/414 | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 blk/414 diff --git a/blk/412 b/blk/412 index a728e7a..f1374d2 100644 --- a/blk/412 +++ b/blk/412 @@ -8,4 +8,9 @@ ( 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, ( 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, diff --git a/blk/413 b/blk/413 index d695bf5..f040937 100644 --- a/blk/413 +++ b/blk/413 @@ -1,12 +1,12 @@ -: (key) 0 ( dummy ) BEGIN DROP (ps2kc) DUP UNTIL ( kc ) - DUP 0xe0 ( extended ) = IF ( ignore ) DROP (key) EXIT THEN - DUP 0xf0 ( break ) = IF DROP ( ) - ( get next key and see if it's a shift ) - (key) _shift? IF ( drop shift ) 0 PS2_SHIFT ! 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 ! (key) EXIT THEN - ( ah, finally, we have a gentle run-of-the-mill KC ) - PS2_CODES + C@ DUP NOT IF DROP (key) EXIT THEN ; +( 28 ) 0 C, 32 C, 'V' C, 'F' C, 'T' C, 'R' C, '%' C, 0 C, +( 30 ) 0 C, 'N' C, 'B' C, 'H' C, 'G' C, 'Y' C, '^' C, 0 C, +( 38 ) 0 C, 0 C, 'M' C, 'J' C, 'U' C, '&' C, '*' C, 0 C, +( 40 ) 0 C, '<' C, 'K' C, 'I' C, 'O' C, ')' C, '(' C, 0 C, +( 48 ) 0 C, '>' C, '?' C, 'L' C, ':' C, 'P' C, '_' C, 0 C, +( 50 ) 0 C, 0 C, '"' C, 0 C, '{' C, '+' C, 0 C, 0 C, +( 58 ) 0 C, 0 C, 13 C, '}' C, 0 C, '|' C, 0 C, 0 C, +( 60 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 8 C, 0 C, +( 68 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, +( 70 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 27 C, 0 C, +( 78 ) 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, 0 C, diff --git a/blk/414 b/blk/414 new file mode 100644 index 0000000..c74986b --- /dev/null +++ b/blk/414 @@ -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 ; +