Re: [AD] Triggers under Linux

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


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.


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