Hi,
I was in the same position this summer. Previously I'd used SDL for a
gamepad, but now needed to resurrect that code and redo it for a
wheel+pedals.
I looked at vrpn but failed to really grok it. In the same time it took
me to bash my head against the vrpn examples, I wrote the sdl code. The
following should be enough for you to do a quick test. SDL also supports
"hats", and force-feedback was part of the Google Summer of Code, but I
haven't seen any results of that yet.
best wishes
Mike
ps) Note this is hard-coded for 10 buttons+5axis
void testSDLJoystick() {
SDL_Joystick *joy;
// Initialize the joystick subsystem
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
// Check for joystick
if(SDL_NumJoysticks()>0){
// Open joystick
joy=SDL_JoystickOpen(0);
if(joy)
{
printf("Opened Joystick 0\n");
printf("Name: %s\n", SDL_JoystickName(0));
printf("Number of Axes: %d\n", SDL_JoystickNumAxes(joy));
printf("Number of Buttons: %d\n", SDL_JoystickNumButtons(joy));
printf("Number of Balls: %d\n", SDL_JoystickNumBalls(joy));
double axis[5];
bool button[10];
for(;;) {
SDL_JoystickUpdate();
printf("Joystick ");
for(int i=0;i<5;i++) {
axis[i]=SDL_JoystickGetAxis(joy,i) / 32768.0;
printf("a_%d=%0.3f ",i,axis[i]);
}
for(int i=0;i<10;i++) {
button[i]=SDL_JoystickGetButton(joy,i);
printf("b_%d=%d ",i,button[i]);
}
printf("\n");
}
}
else
printf("Couldn't open Joystick 0\n");
// Close if opened
if(SDL_JoystickOpened(0))
SDL_JoystickClose(joy);
}
Joe Lyga wrote:
I'm interested in using a usb joystick and/or wheel with
openscenegraph. They're both usb human interface devices. Has anyone
done any work with usb human interface devices in openscenegraph, or
used usb gamepads, joysticks, or wheels as inputs?
I've heard about a few solutions, including "Object Oriented Input
System", SDL, and VPRN. I'm looking for a multiplatform solution that
doesn't necessarily have to be that complicated.
Thanks!
------------------------------------------------------------------------
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org