Re: [AD] Triggers under Linux

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


On Sun, Mar 15, 2015 at 9:51 PM, SiegeLord <slabode@xxxxxxxxxx> wrote:
On 03/15/2015 11:24 AM, Max Savenkov wrote:
> I have a question about the some code in ljoynu.c. Why doesn't Allegro
> consider Triggers to be single-axis? Gamepad documentation at
> https://www.kernel.org/doc/Documentation/input/gamepad.txt tells us that:
>
> "Triggers: Trigger buttons can be available as digital or analog buttons
> or both. User- space must correctly deal with any situation and choose
> the most appropriate mode. Upper trigger buttons are reported as BTN_TR
> or ABS_HAT1X (right) and BTN_TL or ABS_HAT1Y (left). Lower trigger
> buttons are reported as BTN_TR2 or ABS_HAT2X (right/ZR) and BTN_TL2 or
> ABS_HAT2Y (left/ZL). If only one trigger-button combination is present
> (upper+lower), they are reported as "right" triggers (BTN_TR/ABS_HAT1X).
> (ABS trigger values start at 0, pressure is reported as positive values)"
>
> Allegro's treatment of Triggers leads to some very unpleasant effects,
> like sticks' ordering being all messed up. Also, Trigger button should
> have a range of 0.0f..1.0f (as per docs: "ABS trigger values start at 0,
> pressure is reported as positive values"), but currently provide values
> from -1.0f to 1.0f.
>
> Therefore, I propose to add a special case to fill_joystick_axes which
> would handle analogue AND digital triggers (BTN_TR,BTN_TR2, BTN_TL,
> BTN_TL2, ABS_HAT1X, ABS_HAT2X, ABS_HAT1Y, ABS_HAT2Y), and write them
> down as a single-axis sticks.
>

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:

http://www.liballeg.org/a5docs/refman/joystick.html#allegro_joystick_state

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/