Author Topic: Does anyone Know (or know anyone that might) how the nspire keypad works?  (Read 7730 times)

0 Members and 1 Guest are viewing this topic.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
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.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
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.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
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().
« Last Edit: May 22, 2010, 04:20:29 pm by bwang »

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
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.

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
You can already do it using isKeyPressed(), which supports multiple keypresses.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
hmm, do the nonexistent keys act as pressed or unpressed?

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
What nonexistent keys?

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
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.

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
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.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
I'm pretty sure they read as unpressed.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
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.