Accessing All of a Joystick's Axis/Axes? [¿Solved?]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Tobias314
Posts: 10
Joined: Thu Oct 20, 2011 6:27 pm

Accessing All of a Joystick's Axis/Axes? [¿Solved?]

Post by Tobias314 »

How do I go about accessing the other analog input from a joystick beyond the (seemingly) first 4? I'm attempting to make use of analog triggers on a Dualshock and an Xbox controller, but I'm having issues getting anything but the analog sticks to read. Irrlicht reports 27 axes on the Dualshock. My joystick utility (jstest-gtk) shows 18 of them are functional. L2 & R2 (the analog triggers) are Axis 12 & 13.

Any help would be much appreciated!
Last edited by Tobias314 on Thu Jan 09, 2014 11:22 pm, edited 1 time in total.
Tobias314
Posts: 10
Joined: Thu Oct 20, 2011 6:27 pm

Re: Accessing All of a Joystick's Axis/Axes?

Post by Tobias314 »

I've attempted to edit IEventReceiver.h to add more than 6 axis, by adding more axis to the enums thus incrementing NUMBER_OF_AXES. However I'm having issues compiling irrlicht 1.8.1 (with or without said additions). It seems 1.8.1 has been updated since it was in my Distro's repos.

Would that edit be all that's required for support for these other axis? I see SJoystickEvent reference many places, but NUMBER_OF_AXES seems to be the important variable.

I'm currently looking at an SDL event receiver, but would prefer to using Irrlicht's built-in capabilities.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Accessing All of a Joystick's Axis/Axes?

Post by CuteAlien »

Sorry, you have to try that on your own I guess. Joystick support was written by Bitplane and he's no longer active and it seems no one else took over that part yet. So there's no expert for this here currently. I suspect increasing the define might be fine although it will make the SEvent structure then even more fat. I wonder if joystick really belongs in there.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Tobias314
Posts: 10
Joined: Thu Oct 20, 2011 6:27 pm

Re: Accessing All of a Joystick's Axis/Axes?

Post by Tobias314 »

Thanks for the reply! I solved my issue (on linux anyway).

I ended up parsing /dev/input/js* directly. It gives great results, and seemingly has no limitations beyond what the system will support. All 18 usable axes are available from the class, including motion controls. I'll be looking for similar functionality in Windows at some point in the future, then I can create a cross-platform solution that (hopefully) can take full advantage of any joysticks. (I have no plans for OSX, but it seems like it could be similar to the Linux solution)

I'll gladly share code if anyone is interested. (Especially when I have something cross-platform)
devonsoft
Posts: 8
Joined: Thu Oct 04, 2012 2:01 am

Re: Accessing All of a Joystick's Axis/Axes? [¿Solved?]

Post by devonsoft »

I also recommend upping the number of AXES. For Octodad: Dadliest Catch we needed d-pad support and for most dual analog style gamepads (PS4, 360 etc.) it comes in as AXIS 6 and 7 on linux (if starting at 0), and hat on other platforms.

The following seemed to work fine, but having a nice name for the other axes would be nice, AXIS_S, AXIS_T, or maybe AXIS_6, AXIS_7, although if you just upped the max a lot bigger maybe unneccessary to name them.
enum
{
NUMBER_OF_BUTTONS = 32,

AXIS_X = 0, // e.g. analog stick 1 left to right
AXIS_Y, // e.g. analog stick 1 top to bottom
AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right
AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom
AXIS_U,
AXIS_V,
NUMBER_OF_AXES = 8 // linux can have two extra axes for dpad
};
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

Re: Accessing All of a Joystick's Axis/Axes? [¿Solved?]

Post by AReichl »

What about including SDL2 into Irrlicht? (SFML is easier but for "system-specific" tasks SDL2 wins)
SDL2 runs on nearly every platform and would take away a lot of burden from the core developers to concentrate on grafics.
Only initialise the input-system (and maybe some core functionality as threads) and MAYBE also the (simple) sound system, which would add nicely to Irrlicht (if you need more, ...).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Accessing All of a Joystick's Axis/Axes? [¿Solved?]

Post by CuteAlien »

I don't think we would gain much from adding SDL2 directly to Irrlicht. Either we write then an interface to it or there's no advantage to just tell people about that lib. I used SDL myself in my projects in the past for joystick input - there's really not much to wrap - it's pretty simply to link and use.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Accessing All of a Joystick's Axis/Axes? [¿Solved?]

Post by CuteAlien »

Old topic which I just accidentally run into. But noticed we didn't increase axes numbers back then... set them now in svn trunk r5034 to 18. If that's not sufficient for real cases please tell.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply