Re: [AD] Triggers under Linux

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


> If we're lucky there's really only 2 or 3 simple cases where it differs.
I know of two problems:

1) for XInput devices, Allegro and SDL map axis and buttons
differently (the mapping is arbitary, because XInput events report
"control names" rather than indices)
2) SDL treats digital axes very differently from Allegro. First, it
has a separate index for them (Allegro keeps all axes mixed up in a
single sequence). Then, digital axes are treated more like buttons.
For example, in Allegro, D-pad would be two digital axes, and in SDL,
it's a single "hat". For example, if we were to write a mapping file
for Allegro, a section for D-pad would look like that:
    stick 3 axis 0:dpad_x
    stick 3 axis 1:dpad_y
In SDL, it looks like that:
    h0.1:dpad_up // hat 0, mask 1 maps to dpad_up
    h0.2:dpad_right  // hat 0, mask 2 maps to dpad_right etc.
    h0.4.dpad_down
    h0.8:dpad_right

2015-03-17 15:43 GMT+03:00 Elias Pschernig <elias@xxxxxxxxxx>:
> On Tue, Mar 17, 2015 at 1:20 PM, Max Savenkov <max.savenkov@xxxxxxxxxx>
> wrote:
>>
>> > if you want to know which axis is a trigger, simply go through the SDL
>> > mappings and find which two axes correspond to trigger left and trigger
>> > right.
>>
>> You'll get SDL axis index. Allegro, however, work with (stick, axis)
>> pairs. It's not clear how to translate one to another, especially
>> since SDL registers axes in different order than Allegro.
>
>
> The "stick" is just an arbitrary invention of Allegro, you can translate
> stick/axis back into the original axis like this:
>
> int blah(int stick, int axis) {
>     int x = 0;
>     for (int i = 0; i < sticks; i++) {
>         for int (j = 0; j < stick[i].axes; j++) {
>             if (i == stick && j == axis)
>                 return x;
>             x++;
>         }
>     }
> }
>
> But yes, the different order is a problem. So we would need to find out the
> "SDL axis order" for each joystick. Not impossible, but quite a bit of code
> (from SDL). Unless, maybe there is some general pattern and we don't really
> need this - i.e. if we can identify in which cases SDL and Allegro use a
> different order, then it should be rather simple to create a function
> "get_sdl_axis(int allegro_stick, int allegro_axis)". If we're lucky there's
> really only 2 or 3 simple cases where it differs.
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers




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