Problem with analog stick on Linux

Hello,
I’m having a bug report with the analog stick from this code.
I can’t test it since I don’t have a joystick with an analog stick, could anyone help me on that and tell me if there is something obviously wrong with this code ?
Thanks…

If the player moves the joystick really fast from left to right (or right to left) or if he does left->up->right then you might not get any event with value in the deadzone. This means that both button_left and button_right have a value of 1 at the same time.
To fix this you need to reset the opposite direction like you did with hat motion event:

if ((e.jaxis.axis == 0) || (e.jaxis.axis == 2))
     {
        if ((axis[0] == 1) || (axis[2] == 1))
        {
           mrboom_update_input(button_right, getPlayerFromJoystickPort(e.jaxis.which), 1, false);
           mrboom_update_input(button_left, getPlayerFromJoystickPort(e.jaxis.which), 0, false);
        }
        else if ((axis[0] == -1) || (axis[2] == -1))
        {
           mrboom_update_input(button_left, getPlayerFromJoystickPort(e.jaxis.which), 1, false);
           mrboom_update_input(button_right, getPlayerFromJoystickPort(e.jaxis.which), 0, false);
        }
        else
        {
           mrboom_update_input(button_left, getPlayerFromJoystickPort(e.jaxis.which), 0, false);
           mrboom_update_input(button_right, getPlayerFromJoystickPort(e.jaxis.which), 0, false);
        }
}

and the same thing for up and down.

Also, with a xbox controller on Linux, axis 2 is the left trigger which has a rest position of -32767. So if you get report that character is moving even when player does not touch his joystick you will know where the problem is.

@es5804 Thanks for your input

@es5804 Any clue what’s the recommended JOYSTICK_DEAD_ZONE value ?

I use 15% (4915) deadzone as default, but some old or cheap joystick may need more. The best is to have an option in your menu.
However because you use the joystick as a logical input I think 8000 is fine.