Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
644B

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