83Plus:Software:usb8x/BASIC Interface/KBDGetKey
From WikiTI
Contents
Synopsis
Name: KBDGetKey
Function Number: 11
Minimum usb8x version: 0.something
Gets keypress information from the USB KBD driver.
Inputs
None
Outputs
Each value in the list is the decimal value of the contents of the registers {A,B,C,D,E,H,L}.
- 1: Number of keys remaining in keyboard buffer
- 2: Raw key press modifiers
- 3: Raw key press keycode
- 4: Converted TIOS keyextend code
- 5: Converted TIOS _GetKey code (NOT the same as the BASIC getkey codes. . . pester someone to add a conversion)
- 6: nonsense
- 7: nonsense (mostly--whatever Dan left in H&L)
Notes
It'd be nice to get a normal BASIC getKey-style return code. Perhaps the KBD driver wrapper could overwrite H (element 6, which is usually zero anyway) with that before returing.
The raw key-press modifiers byte looks like this:
Bit 7 6 5 4 | 3 2 1 0 key Su Al Sh Cn | Su Al Sh Cn side Right | left Su=Super; Al=Alt; Sh=Shift; Cn=Control
Here's a loop to convert a byte into a list:
For(B,7,0,-1) If X-B^2>0 Then 1→lMODS(B+1) X-2^B→X End End
Then, to access bit 2 you would look at element 3 and so on. Note that if you Disp the list, it will show the bits in reverse order.
See Also
- [[../KBDInit|KBDInit]] - Initialize the keyboard driver.