Calculator Community > Calculator C

Does anyone Know (or know anyone that might) how the nspire keypad works?

(1/3) > >>

willrandship:
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.

calcdude84se:
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.

bwang:
Your program can just detect everything on the fly; its unlikely it will use that many keys.
So, for example:

--- Code: ---if (keypadType() == 84 && isKeyPressed(KEY_84_UP) || keypadType() == NSPIRE && isKeyPressed(KEY_NSPIRE_UP)) {
  //up code here
}

--- End code ---
Unfortunately, I do not know how to implement the function keypadType().

willrandship:
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.

bwang:
You can already do it using isKeyPressed(), which supports multiple keypresses.

Navigation

[0] Message Index

[#] Next page

Go to full version