#173474 - protomank - Fri Apr 09, 2010 12:35 am
I am having a strange problem with my code and a certain key combination. When I hold left and press A button, it do not activate the JUMP, but instead, keeps walking left, even if I release the direcional key. But, the second time I press the button, it jumps!
This do not happens for RIGHT direction, only left! Very strange, here is my code:
Code: |
scanKeys();
keys_down = keysHeld();
if (keys_down & KEY_A) {
keyState[0][KEYJUMP]='1';
}
if (keys_down & KEY_B) {
keyState[0][KEYATTACK]='1';
}
if (keys_down & KEY_START) {
keyState[0][KEYSTART]='1';
}
if (keys_down & KEY_LEFT) {
keyState[0][KEYX]='2';
} else if (keys_down & KEY_RIGHT) {
keyState[0][KEYX]='1';
}
if (keys_down & KEY_UP) {
keyState[0][KEYY]='2';
} else if (keys_down & KEY_DOWN) {
keyState[0][KEYY]='1';
}
|
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173475 - elwing - Fri Apr 09, 2010 7:45 am
at first sight it seems correct... maybe the problem is in your code that actually process the "keyState" variable?
that said, why don't you use boolean/integer (ok I see the problem with the type... you'dd want boolean for the simple key but an integer for the directions...) value rather than a char for your keystate? and for the direction won't something like left = -1 right =1 be more convenient for a latter use?
#173476 - protomank - Fri Apr 09, 2010 10:56 am
There is not problem with the keystate code (yeah, I use char for multi-purpose reasons, but I should just use short int anyway) as it does run fine in other platforms, and I checked the keys variable value.
I'm starting to think this is another conflict between SDL and libNDS. Man, it is just frustating how people port SDL to some platform then stop maintaining it :-(
SDL is wonderful to port projects, but I'm having a lot of problems because the ports for PS2 and DS were dropped, mostly in mixer. Iĺl try to fix joystick code in the SDL by myself, but if I am not able to fix it, seems like DS port is about to go off the boat.
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173798 - protomank - Sat May 01, 2010 2:29 pm
Anyone?
This is a major blocker for my game :-(
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173799 - Pete_Lockwood - Sat May 01, 2010 3:51 pm
Probably not enough code to go on. Print the values of each element of keyState[0] to the screen right after the code you've got there, see how they change, and take it from there.
_________________
It's not an illusion, it just looks like one.
#173800 - protomank - Sat May 01, 2010 4:30 pm
This, obviously, was the first thing I did...
Jump: 8 (I am not sure if those are the correct keycodes, but it does not matter to see the logic of the problem)
Holding left: 24
Holding Left and then pressing Jump: 24
Holding Left and then pressing Jump for a second time: 32 (8 and 24)
Anyway, there seems to be a problem in SDL, because keyDown simply do not work correctly. I can fix that, but only if I know the cause, and I do not know libNDS, THAT is my problem and why asked for help :-(
I only need a clue of what might be causing this isse, Interrumpt conflict is my guess, but I do not know libNSD enought to understand why, or where should I start looking.
Anyway, I'll try to find help in the devkitpro/libnds forums, to see if I can get help.
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173801 - headspin - Sat May 01, 2010 4:48 pm
Where are you turning the key states off?
Eg.
Code: |
if (keys_down & KEY_A)
keyState[0][KEYJUMP]='1';
else
keyState[0][KEYJUMP]='0'; |
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
#173802 - protomank - Sat May 01, 2010 5:15 pm
I have a call to clean_input at the start of the function
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173804 - elhobbs - Sat May 01, 2010 11:29 pm
Is sdl calling scankeys for you? This should only be called once each frame. Try using keysCurrent() instead of keysHeld(). You will need to keep track of button state transitions yourself though.
#173806 - protomank - Sat May 01, 2010 11:39 pm
I've tryied this already. Look, I really looked in this one, the problem seems to be a bit lower, some kind of clonflict in keys interrupts caused by SDL in DS, due to changes made in libNDS after the time SDL was ported to it.
All in all, it seems I have only one option: find a very old version of libNDS and compile SDL with it. The problem, is that the devkitpro site on sourceforge do not hosts old versions :-P
Probally I'll have to get a old date from svn and try to compile libNDS myself... or just forget about it :)
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173807 - Pete_Lockwood - Sun May 02, 2010 12:54 am
Kinda funny, you're asking for help then b1tching out everyone that suggests anything.
Why download old libNds? Why not download the SDL source and fix that?
_________________
It's not an illusion, it just looks like one.
#173808 - protomank - Sun May 02, 2010 3:07 am
Pete_Lockwood wrote: |
Kinda funny, you're asking for help then b1tching out everyone that suggests anything. |
Sorry if I gave this imrpession, but sometimes I really get tired of people telling the problem is in my code, after I telling, it is not :)
I've debugged this very well, I am not gatting the correct key codes form libnds, the SAME code without SDL does work fine, there seems to be a conflicts between SDL and libNDS somewhere I can't find, sadly.
Pete_Lockwood wrote: |
Why download old libNds? Why not download the SDL source and fix that? |
OK, how? That is what I am trying, and asking for help (and not looking for bugs on the simpler part).
That is the point, I've tryied, all sugestions given here were tryied before, by me, on SDL code. This bug is REALLY strange, really, really strange, even more now that I found that on emulators, it does not happen as in the real console... it amuses me :-P
Anyway, I've started to look at the whole SDL code, looking for interrupts and such, but for now I'll just focus my efforts into PS2 and XBox, cause I have little time to fix SDL for all those ports. Seems like all of them share a common problem, a nive person ports SDL to them, but later stops improving/fixing. But hey, real life is better than supporting old code, so I can't complain about them ;)
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173809 - elhobbs - Sun May 02, 2010 3:45 am
protomank wrote: |
I've tryied this already. Look, I really looked in this one, the problem seems to be a bit lower, some kind of clonflict in keys interrupts caused by SDL in DS, due to changes made in libNDS after the time SDL was ported to it.
All in all, it seems I have only one option: find a very old version of libNDS and compile SDL with it. The problem, is that the devkitpro site on sourceforge do not hosts old versions :-P
Probally I'll have to get a old date from svn and try to compile libNDS myself... or just forget about it :) |
Using keysCurrent() can detect the current state of all the keys except the x, y, and the touchpad from the arm9 without irqs or any access to or communication with the arm7. If you are using keysCurrent and experiencing this behaviour then the problem is most likely with your code.
In any case, good luck with your ps2 and xbox coding. I hope the forums for those platforms can magically solve every problem that you run into.
#173812 - protomank - Sun May 02, 2010 1:43 pm
Sarcasm... No, they don't.. hey man, I asked sorry, what do you want me to tell you guys? It is not a defect in MY part of the code, I did a printf (actually used SDL_TTF) to printf the codes I get from scanKeys/currentKeys, and the value is wrong. If you do not know the cause, just say so, not need to enter on a guessing game.
Thanks anyway.
My complete code is at http://www.sf.net/projects/rockman-engine/
Get it and fix (magically if needed), if the problem is on it, and not libNDS+libSDL, I dare you ;)
Bye.
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173819 - sajiimori - Sun May 02, 2010 8:38 pm
protomank wrote: |
If you do not know the cause, just say so, not need to enter on a guessing game. |
LOL. Why would anyone post a message just to say they don't know? Obviously, the people responding are those who are willing to guess. What did you expect? A flood of praise for how smart you are, that you supposedly narrowed the problem down to a specific function, but didn't bother going one step further and fixing the problem? Wow. Good job there.
#173820 - Pete_Lockwood - Sun May 02, 2010 9:53 pm
protomank wrote: |
It is not a defect in MY part of the code |
Apparently it is - you're the one bringing an unsupported library into the mix. If you test YOUR code just against libNds and it doesn't behave I'm pretty sure you'll get a lot more interest.
_________________
It's not an illusion, it just looks like one.
#173832 - Miked0801 - Mon May 03, 2010 6:44 pm
Must resist the temptation to post snarky comment...
#173909 - protomank - Fri May 07, 2010 9:01 pm
Pete_Lockwood wrote: |
protomank wrote: | It is not a defect in MY part of the code |
Apparently it is - you're the one bringing an unsupported library into the mix. If you test YOUR code just against libNds and it doesn't behave I'm pretty sure you'll get a lot more interest. |
That is, actually, what I was trying to tell you guys, but every single question was about my part of the code :)
And, yes, SDL is not supported currently by anyone, I was willing to do it, but needed just a clue on the libNDS part, something like: "inconsistent key reading can be caused by a call to waitSync somewhere inside the loop.".
Thanks anyway, looks like the DS homebrew scene is a bit sad, as libNDS is a bit too unstable (API-wise) and some libs just break often because of this. And people just say: "drop it, we do not support this anymore". :-P
Anyway, does anyone know where I can find old versions of libnds and devkitpro? The official site deletes the old ones in the project page on sourceforge...
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#173912 - elhobbs - Fri May 07, 2010 10:00 pm
protomank - I thought you had given up on ds homebrew? or perhaps you have and you are now just complaing about ds homebrew for fun?
most of the "unstable" libs are because people used things like the IPC struct that was marked as depreciated and for internal use only - right from the beginning. I believe that the real problem is that people generate trash libs that rely on unsupported features and then disappear.
#173920 - relminator - Sat May 08, 2010 4:37 am
protomank wrote: |
That is, actually, what I was trying to tell you guys, but every single question was about my part of the code :)
And, yes, SDL is not supported currently by anyone, I was willing to do it, but needed just a clue on the libNDS part, something like: "inconsistent key reading can be caused by a call to waitSync somewhere inside the loop.".
Thanks anyway, looks like the DS homebrew scene is a bit sad, as libNDS is a bit too unstable (API-wise) and some libs just break often because of this. And people just say: "drop it, we do not support this anymore". :-P
Anyway, does anyone know where I can find old versions of libnds and devkitpro? The official site deletes the old ones in the project page on sourceforge... |
I'm speaking from a noob's standpoint here (started coding for the DS a month ago) and all I could say is that libnds is a really good lib to abstract the hardware. Not too abstracted and not too low-level. Using libnds and devkitPro for the past month was very fun. SDL's interface (I've used it on windows) is not well suited to the DS core and that's probably why their isn't much support.
So I would suggest giving it a try because 1 day after I first installed devkitPro and libnds, I was able to make this:
http://rel.betterwebber.com/junk.php?id=98
And in a month, I made a game engine with 2d and 3d support.
Download:
http://rel.betterwebber.com/junk.php?id=101
screen:
[Images not permitted - Click here to view it]
So try to give libnds a shot. Not only would you learn more about the hardware but it would also make your code "recent".
Just my 2 cents.
_________________
http://rel.betterwebber.com
#173923 - elhobbs - Sat May 08, 2010 2:18 pm
Protoman - I noticed that you have references to palib in your makefile. Palib is known to cause problems with libnds.
Maybe you already answered this question but did you build sdl against the version of libnds that you have installed? If you built sdl then upgraded libnds that could cause a problem.
#174326 - protomank - Sun May 30, 2010 12:28 am
Do not ask me exactaly how... but the problem was fixed.
I recently reinstalled my Ubuntu box, then made some cleaning in my code (nothing to do with input or DS, I didn't even was trying to do anything DS-related) and ... voil?! I suspect there was some trash in the ndslib somewhere, that was cleaned when I did my backup/restore of the SDK.... VERY-VERY strange (because I had cleaned all the DS SDK stuff earlier to check it was not trash).
The good news is that the major blocker was fixed, and now I can focus on improving speed, lowering memory usage and implement sound and music. :)
_________________
Iuri Fiedoruk
http://rockbot.upperland.net
#174339 - Jinroh - Mon May 31, 2010 10:14 am
Glad to hear everything's fixed for you. ^_^
Your project is pretty cool and it'll be nice to have a portable DS version. ^^
_________________
The lone Wolf howls, driven by pride he presses on. Knowing not where he goes, but only where he wants to be.
~Me~