Re: keyboard help
"IllusionEye" wrote:
> I would like to know how to put a sequence of keys into the keyboard
buffer (memory).
It's been a long time since I've worked with this, so I'm a bit fuzzy on
this...
The keyboard buffer is a circular queue. The addresses are:
KEY_BUFFER = 1054
FIRST_INDEX = 1050
LAST_INDEX = 1052
KEY_BUFFER is the address of the circular buffer.
FIRST_INDEX is the index (offset) to the first key in the buffer
LAST_INDEX is the index (offset) to the last key in the buffer
When FIRST_INDEX = LAST_INDEX, the buffer is empty. You can zap the buffer
by setting them to the same value:
poke( FIRST_INDEX, peek( LAST_INDEX ) )
I *think* the buffer can hold up to 16 characters. Each character is stored
as two bytes - the scan key code and the key code. Notice the "- 29" and "-
30"; I hacked at the values until the worked.
scanCode = peek( KEY_BUFFER + peek( FIRST_INDEX ) - 29 )
keyCode = peek( KEY_BUFFER + peek( FIRST_INDEX ) - 30 )
So the buffer is (I think) 32 bytes long in total. Since it's circular,
don't forget to wrap your characters. Obviously, when the LAST_INDEX is
advanced past the end of the buffer, it needs to wrap around to the
beginning again. If the LAST_INDEX is advanced onto the FIRST_INDEX, the
buffer will be overwritten.
Ick.
-- David Cuny
|
Not Categorized, Please Help
|
|