Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: willrandship on May 22, 2010, 12:12:40 am

Title: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: willrandship on May 22, 2010, 12:12:40 am
I'm just thinking, if we can find out how the keypads are differentiated, it could be implemented into the common.h for simpler cross-pad compatibility.

For instance, when ndless 2.0 comes out, many people may find the touch-version of the GBC emu to be mapped strangely. With changing key definitions, it could even work with the 84+ keypad flawlessly.

I was thinking something like this for the header.

Keys are defined for all the pads already

If (insert keypad detection function here)=84+ (or a number, maybe)
      {
        #define KEY_GEN_UP KEY_84_UP
        #define KEY_GEN_DOWN KEY_84_DOWN
       }
Repeat the if statement for the touch and clickpad, then when you write a program you use the generic keymap instead of a specific one. Obviously, it won't work for every program, but it should work for many, like the GBC emu and other Games.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: calcdude84se on May 22, 2010, 03:49:19 pm
Unfortunately, C doesn't work like that.
You'll have to either create a large look-up table whenever the program is run, or you'll have to check which keypad it is every time. The first option is probably easier.
If you need to know more why it doesn't work like that:
statements starting with a '#' are processed before the program is ever run. Those #define statements are processed while compiling and therefore aren't affected by that 'if'.
I don't know enough about the Nspire to draw up sample code, so I'll leave that to someone else.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: bwang on May 22, 2010, 04:18:37 pm
Your program can just detect everything on the fly; its unlikely it will use that many keys.
So, for example:
Code: [Select]
if (keypadType() == 84 && isKeyPressed(KEY_84_UP) || keypadType() == NSPIRE && isKeyPressed(KEY_NSPIRE_UP)) {
  //up code here
}
Unfortunately, I do not know how to implement the function keypadType().
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: willrandship on May 22, 2010, 05:37:10 pm
What about a getkey-style scanning function? It check for any open keys and returns them, possibly with multiple key detection! that would be cool.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: bwang on May 22, 2010, 07:01:08 pm
You can already do it using isKeyPressed(), which supports multiple keypresses.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: willrandship on May 22, 2010, 11:18:49 pm
hmm, do the nonexistent keys act as pressed or unpressed?
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: bwang on May 23, 2010, 01:24:02 am
What nonexistent keys?
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: willrandship on May 24, 2010, 10:25:48 pm
If you look at the Nspire keymap, and the 84+ keymap on hackspire, some bit combinations are marked "---" since they are not mapped to any existing keys on the pad.  I was wondering (or hoping) that maybe they would be in a pushed state. That would allow for identifying the 84+ keypad and Nspire keypad.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: bwang on May 25, 2010, 12:19:53 am
You could try testing it. Turn on a pixel if the key in question is down, since you can't print things to the screen.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: calc84maniac on May 25, 2010, 12:21:24 am
I'm pretty sure they read as unpressed.
Title: Re: Does anyone Know (or know anyone that might) how the nspire keypad works?
Post by: willrandship on May 25, 2010, 11:42:23 am
Drat. Well, now that idea's shot.

Brain Flash! What about having the user press the Enter key at the beginning? That way, if it's the 84+ keypad enter will be mapped in a different place than the ClickPad, and probably the TouchPad too. You couldn't use the define command, though, so you'd have to use int.