Hi folks,
I’ve been writing a SGI Performer program with linux kernel
based joystick support, but I thought it would be nice
to move the joystick support to SDL for better portability.
The joystick support is the only thing I want from SDL,
but I’ve been having some problems. The two behaviour
I have been getting are:
-
If I run SDL_Init with ‘SDL_INIT_JOYSTICK’, my program finds
my joystick ok, but does not receive any events from it. The
program however exits normally.
-
If I run SDL_Init with ‘SDL_INIT_VIDEO|SDL_INIT_JOYSTICK’,
my program finds my joystick ok, and receives events from it,
but the program hangs on exit. A back trace in gdb shows that
it gets stuck here:
(gdb) bt
#0 0xb53ca561 in __waitpid_nocancel () from /lib/tls/libpthread.so.0
#1 0xb58d123d in pfExitWithoutExit () from /usr/lib/libpf.so.5
#2 0xb58d125b in pfExit () from /usr/lib/libpf.so.5
#3 0x080632bd in main ()
Can anybody suggest a workaround to make this work?
Details about my setup:
Debian Sarge;
Linux kernel 2.6.11;
SDL comes from the package libsdl1.2-dev, package has version
1.2.7+1.2.8cvs20041007-4.1 (whatever that means);
Performer version 3.2;
gcc 3.3.5;
glibc 2.3.2.
Cheers,
Chris
I’ve been writing a SGI Performer program with linux kernel
based joystick support, but I thought it would be nice
to move the joystick support to SDL for better portability.
The joystick support is the only thing I want from SDL,
but I’ve been having some problems. The two behaviour
I have been getting are:
-
If I run SDL_Init with ‘SDL_INIT_JOYSTICK’, my program finds
my joystick ok, but does not receive any events from it. The
program however exits normally.
-
If I run SDL_Init with ‘SDL_INIT_VIDEO|SDL_INIT_JOYSTICK’,
my program finds my joystick ok, and receives events from it,
but the program hangs on exit.
If you create a small demo SDL program does it hang, too? Are all SDL
programs hanging in your environment or just the one you created? Does
it make a difference if you do not use SDL_INIT_JOYSTICK?
A back trace in gdb shows that
it gets stuck here:
(gdb) bt
#0 0xb53ca561 in __waitpid_nocancel () from /lib/tls/libpthread.so.0
#1 0xb58d123d in pfExitWithoutExit () from /usr/lib/libpf.so.5
#2 0xb58d125b in pfExit () from /usr/lib/libpf.so.5
#3 0x080632bd in main ()
Are you using threads in your program?
ChrisOn 6/1/05, Chris Want wrote:
–
E-Mail: Chris Nystrom
Business: http://www.shaklee.net/austin
Blog: http://conversazione.blogspot.com/
AIM: nystromchris
Chris Nystrom wrote:
If you create a small demo SDL program does it hang, too? Are all SDL
programs hanging in your environment or just the one you created? Does
it make a difference if you do not use SDL_INIT_JOYSTICK?
A small demo program, (e.g. testjoystick.c that comes with the
debian libsdl1.2-dev package) does not hang and works fine.
When I strip the testjoystick.c so it does not use any video
routines and init SDL with SDL_INIT_JOYSTICK instead of
SDL_INIT_VIDEO|SDL_INIT_JOYSTICK, it again does not hang,
but it does not get any joystick events.
Are you using threads in your program?
Yes, it links with pthreads and the program forks so that
there is an application, a culling, and a drawing thread
(this is a common thing to do with Performer, and my
program is essentially a hack of their ‘perfly’ program).
Is this a bad thing to do when using sdl?
Cheers,
Chris
Quoth Chris Want , on 2005-06-01 22:03:34 -0600:
A small demo program, (e.g. testjoystick.c that comes with the
debian libsdl1.2-dev package) does not hang and works fine.
When I strip the testjoystick.c so it does not use any video
routines and init SDL with SDL_INIT_JOYSTICK instead of
SDL_INIT_VIDEO|SDL_INIT_JOYSTICK, it again does not hang,
but it does not get any joystick events.
You need SDL_INIT_VIDEO to get any events, I believe. I can’t seem to
find the documentation for this, though… all I can find is a note in
the SDL_PumpEvents manual page saying only to call it from “the thread
that set the video mode”. O.o Does anyone else have better information
than this?
—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050602/cfd9c404/attachment.pgp
You need SDL_INIT_VIDEO to get any events, I believe. I can’t seem to
find the documentation for this, though… all I can find is a note in
the SDL_PumpEvents manual page saying only to call it from “the thread
that set the video mode”. O.o Does anyone else have better information
than this?
Hi Drake,
Yeah, that should probably be added to the documentation
if it is indeed a necessary condition for events to be
read – certainly every joystick example I’ve seen
from googling uses the SDL_INIT_VIDEO setting as well
as SDL_INIT_JOYSTICK.
Regarding my problem with SGI performer, I now have it working:
it works if I initialize SDL after the processes fork
(I had been initializing it before the fork). Thanks
to Chris Nystrom for asking the right questions!
Regards,
Chris