Difference between revisions of "83Plus:Software:usb8x/BASIC Interface/KBDGetKey"

From WikiTI
Jump to: navigation, search
(/* Notes *. added a note about the lock keys)
m (Very minor wiki markup conversion)
 
Line 17: Line 17:
 
* 3: Raw key press keycode
 
* 3: Raw key press keycode
 
* 4: Converted TIOS keyextend code
 
* 4: Converted TIOS keyextend code
* 5: Converted TIOS _GetKey code (<em>not</em> the same as the BASIC getkey codes. . . pester someone to add a conversion)
+
* 5: Converted TIOS _GetKey code (''not'' the same as the BASIC getkey codes. . . pester someone to add a conversion)
 
* 6: ''nonsense''
 
* 6: ''nonsense''
 
* 7: ''nonsense'' (mostly--whatever Dan left in H&L)
 
* 7: ''nonsense'' (mostly--whatever Dan left in H&L)
Line 25: Line 25:
  
  
<strong>Beware!</strong> Pressing scroll-, caps-, or num-lock may crash the program and possibly the driver! I don't know why exactly this happens, but <em>does</em> need to be fixed by somebody. My experience has been that it results in the program quitting for no apparent reason, and then, if you try running it again, a possible crash.  
+
'''Beware!''' Pressing scroll-, caps-, or num-lock may crash the program and possibly the driver! I don't know why exactly this happens, but ''does'' need to be fixed by somebody. My experience has been that it results in the program quitting for no apparent reason, and then, if you try running it again, a possible crash.  
  
  

Latest revision as of 14:37, 7 February 2007

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.


Beware! Pressing scroll-, caps-, or num-lock may crash the program and possibly the driver! I don't know why exactly this happens, but does need to be fixed by somebody. My experience has been that it results in the program quitting for no apparent reason, and then, if you try running it again, a possible crash.


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.