I've been working on some code for an event-driven keypad manager, which I have been meaning to attempt for ages. I finally got something working so I thought I'd share it with you.
The idea is you register event handlers for certain keypad events (up, down and hold) and in the main loop of your program, you call a despatch routine which calls the required handlers.
A typical program might look something like this:
Code: Select all
.glBeginKeyEventList()
.onKeyDown(GL_KEY_CLEAR) myOnKeyClearHandler
.onKeyDown(GL_KEY_MODE) quittoshell
.onKeyHold(GL_KEY_LEFT) myOnKeyLeftHandler
.onKeyHold(GL_KEY_RIGHT) myOnKeyRightHandler
.glEndKeyEventList()
Forever: call glPollKeyEvents
call glDespatchKeyEvents
; program code
jp Forever
myOnKeyClearHandler:
; etc

Although doing direct-input yourself would be faster, for people like me who can't be bothered writing keyboard input code, this could be ideal. It's also handy for test-bed code when you just need some quick-n-dirty keyboard input.
The source can be downloaded here
The files:
* glinput.inc - equates 'n' stuff
* glinput.asm - the code
* glinput.txt - "I can't believe it's not documentation" (tm).
* etch.asm - quick-n-dirty example "etch-a-sketch" program for MirageOS.
If you use it and find it useful, find any bugs, or have a suggestion, let me know!