Re: [AD] Triggers under Linux

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


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

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.

> 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 :)

16.03.2015 0:24, Elias Pschernig пишет:
On Sun, Mar 15, 2015 at 9:51 PM, SiegeLord <slabode@xxxxxxxxxx> wrote:
I'm open to any changes in behavior of this code as long as they're
configurable via allegro5.cfg if it means things work in a better/more
correct way. I am not at all an expert in this code so I can't judge
what's better, but I can defer to your experience in the matter if you
think things are done incorrectly. Do the other platforms do this
correctly and/or similarly incorrectly?

I note that the semantics of the ALLEGRO_JOYSTICK_STATE's axis field
aren't really documented, so perhaps making an axis that ranges from 0
to 1 is just fine.

Looking at this:
Shouldn't we make a trigger a *button* instead of an *axis* maybe? And change the range of buttons to be from 0 to 1 (instead of 32767, which looks to me like just some oversight - there's no reason having axis going from -1 to 1 but buttons from 0 to 32767.

Other than that, I'd say it is important that each axis has the same range, or that there is some extra information to be queried for each axis. Otherwise how do we know in code whether we are dealing with a normal axis or a trigger axis.




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