#108945 - OOPMan - Mon Nov 13, 2006 11:23 am
Just a quick question which is probably pretty stupid but...
I'm mucking about with the keypad stuff and would just like to know what value to check for for keysDown() to indicate that no keys are down. I'd prefer not to have to call keysUp() with a long string of bit ands as well...
I'm probably missing something obivious here but using 0 didn't *seem* to work (It was in a switch statement and gcc complained that case 0 was duplicated of one of my prior cases...)
So, what value should I check for?
*waits for the laughter*
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#108948 - Mr Snowflake - Mon Nov 13, 2006 12:26 pm
Maybe a stupid reply, but shouldn't the lid bit be negated?
_________________
http://www.mrsnowflake.be
#108949 - OOPMan - Mon Nov 13, 2006 12:33 pm
Hmmmmmm, probably a good thing to check for...
Any other suggestions...
Basically what I'm trying to do is this...
1: User presses a key or combo of keys
2: Program records combo
3: When user releases all keys, program prints last key combo formed
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#108967 - outphase - Mon Nov 13, 2006 5:19 pm
One problem with this approach is that no one will release all keys at the same time, so your combo will be incomplete.
If I understand what you want to do correctly, you can negate bit 13 (KEY_LID), then check to see if the value is 0 for keyDown(). although I don't know if KEY_LID is 1 or 0 when it's open.
#108974 - OOPMan - Mon Nov 13, 2006 6:28 pm
That's a good point. I hadn't thought of that :-(
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#109028 - HyperHacker - Tue Nov 14, 2006 6:15 am
What I do is keep u32 KeysPressed and KeysHeld in IPC. On each VBlank ARM7 gathers all the keypad info and writes it into these. KeysPressed is the keys that were pressed this frame and KeysHeld is those that have been held for more than one frame. I don't recall the precise method I used to determine which are held, but I could look it up if you need it.
_________________
I'm a PSP hacker now, but I still <3 DS.
#109033 - OOPMan - Tue Nov 14, 2006 7:37 am
That might be useful, thanks HH :-)
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI
You can find my NDS homebrew projects here...
#109062 - josath - Tue Nov 14, 2006 6:05 pm
HyperHacker wrote: |
What I do is keep u32 KeysPressed and KeysHeld in IPC. On each VBlank ARM7 gathers all the keypad info and writes it into these. KeysPressed is the keys that were pressed this frame and KeysHeld is those that have been held for more than one frame. I don't recall the precise method I used to determine which are held, but I could look it up if you need it. |
libnds includes these functions now. You just have to call 'scanKeys()' every time to update them, then use:
keysDown() // keys pressed this frame
keysHeld() // keys which are held down
keysUp() // keys which were just let go this frame
#109065 - outphase - Tue Nov 14, 2006 7:05 pm
Using those functions, I guess you could record your keys held until keyup has a value.
#109226 - HyperHacker - Thu Nov 16, 2006 6:53 am
Interesting, but that means calling a function every time I want the key status, which probably has more overhead than just reading the data out of IPC.
_________________
I'm a PSP hacker now, but I still <3 DS.
#109239 - tepples - Thu Nov 16, 2006 8:35 am
HyperHacker wrote: |
that means calling a function every time I want the key status, which probably has more overhead than just reading the data out of IPC. |
Some function calls don't have overhead, and these are called static inline. If you find a place where wintermute forgot to mark a function in libnds for proper inlining, let him know.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#109253 - Mr Snowflake - Thu Nov 16, 2006 12:00 pm
tepples wrote: |
Some function calls don't have overhead, and these are called static inline. If you find a place where wintermute forgot to mark a function in libnds for proper inlining, let him know. |
If the functionbodies are declared in the header file, the static inline isn't needed. They will be implicitly inline.
_________________
http://www.mrsnowflake.be
#109276 - tepples - Thu Nov 16, 2006 7:35 pm
Mr Snowflake wrote: |
If the functionbodies are declared in the header file, the static inline isn't needed. They will be implicitly inline. |
As I understand it, what you say applies only in C++ and only to methods of a class.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.