Sdl_joystickclose Does Not Work With Usb In Official Sdk


GP2X_Coder

Member
Joined
May 17, 2006
Messages
220
Age
52
Location
USA
Website
mysite.verizon.net
Can anyone else confirm this with the officail sdk for the gp2x.

It works perfect in windows but on the Gp2x it only release the first joystick PEP Joy.

Can anyone test this out if you have BOB or Cradle?

I can open all of the usb controllers that are attached and get them all to work fine but when I go to close them it will only release the first joystick and that is the Gp2x's joystick its called PEP Joy and then crashes on the rest of them. Anybody have any Idea's ? I first check with SDL_JoystickOpened( ) and it shows that the joysticks are open but when I call SDL_JoystickClose() for each of them it will only release the first one none of the USB ones and then crashes??

Thanks for any help?

Here is a test I made real fast if you want to compile it and it will work on windows but crash on the gp2x :(

CODE

#include "SDL/SDL.h"
#include <unistd.h>

int TotalJoyFound = 0;
SDL_Joystick **JoyStick;

char *ExeDir = NULL;
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

// Get the total number of joysticks attached to the device
TotalJoyFound = SDL_NumJoysticks();

// If we found any joysticks for this test
if( TotalJoyFound )
{
// Create the joysticks
JoyStick = new SDL_Joystick*[ TotalJoyFound ];


// Now lets open all of the joysticks found
for( int a = 0; a < TotalJoyFound; a++ )
{
JoyStick[ a ] = SDL_JoystickOpen( a );

// If the joysticks are opened close them
if( SDL_JoystickOpened( a ) )
SDL_JoystickClose( JoyStick[ a ] );
}

// Delete the joysticks
if( JoyStick )
delete [] JoyStick;
}
//Quit SDL
SDL_Quit();

#ifdef GP2X

// Finished with program now return to the main
chdir( "/usr/gp2x" );
execl( "/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL );

#endif

return 0;
}
 
I tested SDL with usb gamepads on my cradle with 3 gamepads. All my code worked well!

I think something wrong with your code
 
quasist said:
I tested SDL with usb gamepads on my cradle with 3 gamepads. All my code worked well!

I think something wrong with your code
Are you sure that the joysticks were released see if the joysticks will move the icons on the gp2x screen around when you exit the program or not.

Orkie said:
Why are you using the official SDK?
Because no other lib's are useful to me at this time I am constantly changing the pixels of my surfaces so HW surfaces are completely slower SW surface are way faster so I just used what GP released.
 
Last edited by a moderator:
GP2X_Coder said:
Because no other lib's are useful to me at this time I am constantly changing the pixels of my surfaces so HW surfaces are completely slower SW surface are way faster so I just used what GP released.
There are other improvements in HW SDL other than HW surfaces :). Hardware surfaces are no slower with the mmuhack applied too (and you can use software surfaces with HW SDL anyway).
 
Last edited by a moderator:
Orkie said:
GP2X_Coder said:
Because no other lib's are useful to me at this time I am constantly changing the pixels of my surfaces so HW surfaces are completely slower SW surface are way faster so I just used what GP released.
There are other improvements in HW SDL other than HW surfaces :). Hardware surfaces are no slower with the mmuhack applied too (and you can use software surfaces with HW SDL anyway).


I heard that if you use the HW lib's that you have to release the source code along with it to everyone since it is a static build of an SDL Lib according to license? I have a lot of code that is used commercially and I can't reveal that to everyone. :unsure: What really bothers me is that I know that my code is not incorrect how much more simplier can it get call SDL_JoystickOpen() then check with SDL_JoystickOpened() to see if it is open and if the joysticks are open call SDL_JoystickClose(). It's super simple but it does not work with usb controllers. It has to be a problem with the official sdl lib. My engine is 100% Complete and this is the only problem I have that I can't seem to fix!
 
Last edited by a moderator:
Nope, you have to release your .o files on request so they can relink against any SDL version (you don't have to support this), but this is basically the same as releasing a binary but in lots of little chunks, they can't get any of your code. I don't think GPH's SDL supports USB controllers anyway.
 
Orkie said:
relink against any SDL version (you don't have to support this)
Does that mean that my software doesn't have to be backwards compatible to older versions of SDL?
 
Last edited by a moderator:
It only has to link against the SDL version you used, which you should also supply the source for I think.
 
Orkie said:
I don't think GPH's SDL supports USB controllers anyway.
That would be weird for GPH to release a BOB or Cradle and their own SDK won't support devices for it. :blink:
What is even stranger is that I upgraded to firmware 3.0 and the program no longer crashes it still doesn't release the joysticks correctly but it at least exists from the game now. :huh: I compiled the program for both Linux and for Windows and it released all of the controllers correctly so now I know that the problem is in the GPH SDL Lib's and not my code.
 
Last edited by a moderator:
Back
Top