[osg-users] Joystick support in OSG

Jan Ciger jan.ciger at gmail.com
Mon Nov 2 00:51:43 PST 2015


Hello,


On Mon, Nov 2, 2015 at 9:35 AM, Elias Tarasov <elias.tarasov at gmail.com> wrote:
> Hi!
>
> Which is the best way of supporting joystick's input in modern OSG?
> OSG Cookbook says it's a Directinput 3rdParty lib, but looking into OSG trunk code it seems that last update was done 5 years ago. SDL was updated 5 month ago, but that comment in the last commit
>
>
>>
>> OpenSceneGraph\src\osgPlugins\sdl\JoystickDevice.cpp(42): error C2664: 'const char *SDL_JoystickName(SDL_Joystick *)' : cannot convert argument 1 from 'int' to 'SDL_Joystick *'
>> due to changes in the SDL api.
>>
>> Tested with Visual Studio Express 2013; SDL 2.0.1"
>>
>
>
> makes me uncertain about that choice.
>
> Could anybody please provide more consistent info?

That code looks like it was written for the older pre 2.x SDL and
nobody has updated it yet.

You can either try to update that one (the SDL 1.x -> 2.x transition
is fairly simple) or simply use SDL 2.0 and handle the input outside
of OSG. The plugin doesn't do much anyway - just reads the device and
sends OSG events.

Alternatively, depending on what do you need the joystick for, you can
use also VRPN/OSVR - that will get you device independence (e.g. you
could emulate a joystick with something else or swap the devices at
runtime). Overkill for a simple application, but if you are building
some sort of virtual reality system then VRPN/OSVR are likely the
tools to go for.

J.



More information about the osg-users mailing list