Are you going to try the interrupt again, or will you have the user call some kind of getkey routine that then calls the user defined key up/down handlers and returns on Enter or something?benryves wrote:What would be ideal would be to provide internal event handlers that could be called on keyup/keydown which would then jump over to the user's custom handler. These event handlers could look for special keys and adjust the keyboard LEDs and set internal flags that could be used to detect the status of certain keys.
[Staff][Alpha] Emerson - TI-83+ Keyboard/Mouse
Moderator: MaxCoderz Staff
Looking good
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Currently I just have a call to keyb_update in my main loop, and the keyb_update function calls the user's functions. You could use it a bit like this:
Of course, you don't have to use my helper functions and can do everything manually through at_[get|send]_byte. What I'll probably do is add a further, optional layer of abstraction with a keyb_getk function that installs its own event handlers so that you can just call keyb_getk in a loop and it'll work a little like _getCSC.
Code: Select all
_initialise:
; Disable the keyup event handler:
call keyb_reset_keyup
; Enable the keydown event handler:
ld hl,_key_down
call keyb_set_keydown
_main_loop:
call keyb_update ; Do all the keyboard magic
; Check for [clear]
bcall(_getCSC)
cp skClear
jr nz, _main_loop
ret ; Exit
;;;;
_key_down:
; This function is called when a key is pressed.
; A contains the key code.
cp em_sc_escape
ret nz ; Not escape
ld hl,_esc
bcall(_putS)
ret
_esc:
.db "Escape was pressed!",0
Okay, that looks quite useable
How about adding another layer and implementing a keyb_getString routine?
How about adding another layer and implementing a keyb_getString routine?
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
With regards to that - one very important thing would be a translation routine that would convert scancodes into ASCII characters taking into account the status byte (which records the keyboard LEDs and the shift/alt/ctrl status). However, for each layout you'd have to have a different table - my values will not work properly with a US keyboard, and I assume that a Dutch keyboard has another layout (I know French is AZERTY and German is QWERTZ, for example). An AT or PS/2 keyboard only sends back the physical location of the key on the keyboard - NOT the character name.
One possible solution is that the routines don't have any translation tables built-in as standard; they look for a program called 'KEYMAPS' or similar on the calculator and use that as a translation table. This way, any program using these routines would leave it up to the end-user to have the KEYMAPS file on their calculator and thus the program of localisation is sorted out.
One possible solution is that the routines don't have any translation tables built-in as standard; they look for a program called 'KEYMAPS' or similar on the calculator and use that as a translation table. This way, any program using these routines would leave it up to the end-user to have the KEYMAPS file on their calculator and thus the program of localisation is sorted out.
Dutch keyboards normally use the US or UK layout. We're not as stubborn as the French, and we don't use ö, ü, etc quite as often as the Germans do. We don't even have the ß.benryves wrote:my values will not work properly with a US keyboard, and I assume that a Dutch keyboard has another layout
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Simple localisation is here:
http://www.gamedev.net/community/forums ... id=2353610
@Timendus: keyi_* (key input/translation routines) are one above keyb_* (keyboard routines), and I'll probably write some simple string input routines on top of them which should handle the basic functions (backspace, delete, cursor movement) for you. You could then bind event handlers to them (eg on_enter). I'll probably set them up so that typing on the TI's keyboard will also enter text for them.
http://www.gamedev.net/community/forums ... id=2353610
@Timendus: keyi_* (key input/translation routines) are one above keyb_* (keyboard routines), and I'll probably write some simple string input routines on top of them which should handle the basic functions (backspace, delete, cursor movement) for you. You could then bind event handlers to them (eg on_enter). I'll probably set them up so that typing on the TI's keyboard will also enter text for them.
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
As fast as typing on your keyboard on your PC, repeat rate and all. There is a tiny delay if you press Num Lock/Caps Lock/Scroll Lock as it needs to update the status LEDs on the keyboard in the next pass - that is, if you call keyb_update, it'll detect one of the keys and update the internal status byte, but won't send the new keyboard LED status command until you call keyb_update again (it is designed to be called in a loop).
Would you be willing to donate that routine to my project once you're done with it? I have a little idea that could make adding keyboard support a lot more popular clickybenryves wrote:I'll probably write some simple string input routines on top of them which should handle the basic functions (backspace, delete, cursor movement) for you. You could then bind event handlers to them (eg on_enter). I'll probably set them up so that typing on the TI's keyboard will also enter text for them.
http://clap.timendus.com/ - The Calculator Link Alternative Protocol
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
http://api.timendus.com/ - Make your life easier, leave the coding to the API
http://vera.timendus.com/ - The calc lover's OS
How did you manage the timing between the calc and the keyboard?
My diet consists of nails, code-stealers, and HP fans.
Projects:
Robot War [TI-82, TI Flash App]
Sonic the Hedgehog [Multiplatform]
Projects:
Robot War [TI-82, TI Flash App]
Sonic the Hedgehog [Multiplatform]
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
@Timendus: Sure thing.
@DigiTan: They keyboard generates the clock signal - I poll this using a _wait_bit_low and a _wait_bit_high pair of routines that wait for the clock to go high or low (if they don't change within 255 checks they time out, so if you don't have a keyboard connected you can't go into an infinite loop). By holding the clock line low, you can prevent the keyboard from sending a scancode (releasing it when you want the keyboard to send the keystrokes it has buffered).
http://www.computer-engineering.org/ps2protocol/ <- this might be of interest (The PS/2 keyboard uses the AT protocol).
@DigiTan: They keyboard generates the clock signal - I poll this using a _wait_bit_low and a _wait_bit_high pair of routines that wait for the clock to go high or low (if they don't change within 255 checks they time out, so if you don't have a keyboard connected you can't go into an infinite loop). By holding the clock line low, you can prevent the keyboard from sending a scancode (releasing it when you want the keyboard to send the keystrokes it has buffered).
http://www.computer-engineering.org/ps2protocol/ <- this might be of interest (The PS/2 keyboard uses the AT protocol).
- KermMartian
- Calc Wizard
- Posts: 549
- Joined: Tue 05 Jul, 2005 11:28 pm
- Contact:
- benryves
- Maxcoderz Staff
- Posts: 3087
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Sorry to necro an old thread, but I sent Kerm my AT routines after a bit of prompting, and have done some more work on them myself, and extended them to support the mouse.
You can download a demo, or watch a video of the mouse/keyboard routines in action here:
http://www.gamedev.net/community/forums ... id=2488040
You can download a demo, or watch a video of the mouse/keyboard routines in action here:
http://www.gamedev.net/community/forums ... id=2488040