Re: [AD] Triggers under Linux

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, Mar 15, 2015 at 10:38 PM, Max Savenkov <max.savenkov@xxxxxxxxxx> wrote:
Well, I'm not an expert either, but on Windows at least the behaviour is different (I'm going to check MacOS X next). I'm thinking the code is wrong here, because currently this is the way my gamepad is represented under Linux:

Left stick - stick 0, axis 0 and 1
Right stick - stick 1, axis 1 and stick 2 axis 0 (<---- here, it starts to go wrong!)
Left trigger - stick 1, axis 0 ( <--- trigger's axis is mixed with right stick's axis!)
Right trigger - stick 2, axis 1 ( <--- trigger's axis is mixed with right stick's axis!)
D-Pad - stick 3, axis 0 and 1 ( <---- here, things are OK again)

Ideally, I'd like to see something like this:
Left stick - stick 0, axis 0 and 1
Right stick - stick 1, axis 0 and 1
Left trigger - stick 2, axis 0
Right trigger - stick 3, axis 0
D-Pad - stick 4, axis 0 and 1

Yes, I'm seeing the same here for an xbox360 controller.
 
Now, as for axis ranges. For "normal" axes, we need range to be from -1 to 1, with 0 the neutral position, to denote up/down, left/right movement. But for throttle-like axes (which include triggers), we need axis with range of 0..1. It works this way under Windows, and under Linux too, as long as Linux Joystick API reports stick to be one of ones mentioned in is_single_axis_throttle.

> Shouldn't we make a trigger a *button* instead of an *axis* maybe?

When trigger is digital, it's a button already, I believe. But when it's analogue, we'd better keep it as an axis.

Why? To me the different range (0..1 instead of -1..1) would be a very strong reason not to keep it as an axis. It also isn't an "axis", it's a trigger *button*.
 

> Otherwise how do we know in code whether we are dealing with a normal axis or a trigger axis.

Interesting point. I was dealing with this myself with my mapping code. I see two options:
1) Do not mark triggers in any special way. It's just an axis that can go from 0 to 1. It can't ever be <0, but so what?
2) Add a flag for trigger, to mark it as such, so user can query for it

For my current purposes, I do not need to know if axis is a trigger :)

Well, I didn't actually look into code, so there may be some problems with mapping it to buttons instead of axes, but otherwise it seems to solve all the issues nicely.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/