Author Topic: Key presses  (Read 5174 times)

0 Members and 1 Guest are viewing this topic.

Offline kevinkore3

  • LV3 Member (Next: 100)
  • ***
  • Posts: 57
  • Rating: +0/-0
    • View Profile
Key presses
« on: March 31, 2015, 10:01:47 pm »
There is the isKeyPressed function, but that only detects the state of the key.
Say, for example, open a text editor and hold a key. One character will show up at first, then after half a second or so a bunch will start showing up rapidly.
Is there a function to capture this type of input in the SDK or should I implement one?
I'm curious because in a program I'm making I'm using tabs to loop through things, but it just loops through everyone really fast.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: Key presses
« Reply #1 on: April 02, 2015, 08:09:08 am »
That's automated key repetition and not implemented in libndls as it is more low-level (isKeyPressed reads from the keypad buffer directly).
You'll have to implement it yourself by using a counter variable and some booleans.

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: Key presses
« Reply #2 on: April 02, 2015, 02:52:45 pm »
I implemented something like that in nPDF for the arrow keys. You might want to look at the source code: https://github.com/Legimet/nPDF. And you can copy my code into your project under the terms of the GPL.

Offline kevinkore3

  • LV3 Member (Next: 100)
  • ***
  • Posts: 57
  • Rating: +0/-0
    • View Profile
Re: Key presses
« Reply #3 on: April 04, 2015, 05:45:50 pm »
On another note, is it possible to get fstream working? I'm missing basic_string.tcc (and probably other things) on my Windows machine, and my Linux laptop makes super large bogus a.outs that don't run.
« Last Edit: April 06, 2015, 09:11:17 pm by kevinkore3 »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: Key presses
« Reply #4 on: April 07, 2015, 04:41:25 pm »
You have to build the "new" SDK from source: http://github.com/ndless-nspire/Ndless
On Windows, use Cygwin, on linux it should work directly. fstream is fully supported, as is everything except threads.
See also http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux