[Staff][Alpha] Emerson - TI-83+ Keyboard/Mouse

Here you can find side projects of the staff and great projects which we think should get extra support. (Note that featured projects are not projects by staff members of MaxCoderz)

Moderator: MaxCoderz Staff

User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

Looking good :P
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.
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?
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
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

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:

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
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.
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

Okay, that looks quite useable :)
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
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

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.
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

benryves wrote:my values will not work properly with a US keyboard, and I assume that a Dutch keyboard has another layout
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 ß. :)
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
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

In any case, people in the USA will get annoyed if they get a " when they press Shift+2 and I will get annoyed if I get an @ when I press Shift+2.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

I'm only annoyed when I forget to switch back from Russian or Arabic layout and enter gibberish instead of web addresses. :lol:
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

Simple localisation is here:
Image
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.
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

That cool, I assume the speed is just as typing on a calc.? Like is there any delay?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

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).
User avatar
Timendus
Calc King
Posts: 1729
Joined: Sun 23 Jan, 2005 12:37 am
Location: Netherlands
Contact:

Post by Timendus »

benryves 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.
Would you be willing to donate that routine to my project once you're done with it? :P I have a little idea that could make adding keyboard support a lot more popular :) clicky
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
User avatar
DigiTan
Calc Master
Posts: 1069
Joined: Fri 04 Mar, 2005 12:52 am
Location: NW Wisconsin
Contact:

Post by DigiTan »

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]
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

@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).
User avatar
KermMartian
Calc Wizard
Posts: 549
Joined: Tue 05 Jul, 2005 11:28 pm
Contact:

Post by KermMartian »

@Ben: No, I never did get that working, seems the the PS/2 protocol runs a bit faster. Once you get this in a semifinished state, I'd be happy to mess around with it and a mouse.
Image Image Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

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
Post Reply