supertuxkart-sourceforge-migration / stk-migration-test2

0 stars 0 forks source link

Gamepad problems when using gamepad in menu #410

Open supertuxkart-sourceforge-migration opened 10 years ago

supertuxkart-sourceforge-migration commented 10 years ago

Author: hikerstk

When I use my gamepad in menu and in game, then acceleration (mapped to a button) does not work. But if I use keyboard/mouse to navigate through the menu, and then the gamepad in race, it works as expected.

My gamepad constantly reports (--gamepad-debug): axis{0-3}: -1 axis{4,5}: 0

So I guess a driver issue is causing that the first 4 axis are reported to be constantly pressed. A very quick debugging session showed that the button for acceleration is handled properly and m_accel in the kart control structure is set, but apparently later (I guess when handling axis 0-5) is getting set to 0 again.

That's with r9712 on Windows.

Strangely enough on Mac the same gamepad shows a different problem: it accepts acceleration, but if I turn left and then straight again, the acceleration is lost, and I must press acceleration again. Not sure if this is the same issue (e.g. difference between Mac and Windows might be the order in which the events are being delivered).

Migrated-From: https://sourceforge.net/apps/trac/supertuxkart/ticket/410

supertuxkart-sourceforge-migration commented 10 years ago

Author: hikerstk After a bit more debugging I've remembered that irrlicht sends only one event per joystick, so forget this order of event things :)

I have the following configuration for acceleration:

<action name="accel" id="2" event="3" character="0" />

In the following stack trace (processAndMapInput) resetAxisDirection is called for the axis 2 (i.e. input_manager, line 648: axis_id=2), since value is -1 (as written above, this gamepad has -1 for the first 4 axis) - line 179 sets prevAxisDirection to negative, the if test in 201 is true (since -1 is smaller than the deadzone) --> previous direction is negative, now it's within the deadzone, so at line 214 resetAxisDirection is executed.

    supertuxkart_d.exe!GamePadDevice::resetAxisDirection(const int axis=2, Input::AxisDirection direction=AD_NEGATIVE, StateManager::ActivePlayer * player=0x04cc3080)  Line 141    C++
>   supertuxkart_d.exe!GamePadDevice::processAndMapInput(Input::InputType type=IT_STICKMOTION, const int id=2, const int value=-1, InputManager::InputDriverMode mode=INGAME, StateManager::ActivePlayer * player=0x04cc3080, PlayerAction * action=0x0012f1e8)  Line 214 + 0x12 bytes  C++
    supertuxkart_d.exe!DeviceManager::mapGamepadInput(Input::InputType type=IT_STICKMOTION, int deviceID=0, int btnID=2, int axisDir=2, int value=-1, InputManager::InputDriverMode mode=INGAME, StateManager::ActivePlayer * * player=0x0012f1f4, PlayerAction * action=0x0012f1e8)  Line 319 + 0x25 bytes C++
    supertuxkart_d.exe!DeviceManager::translateInput(Input::InputType type=IT_STICKMOTION, int deviceID=0, int btnID=2, int axisDir=2, int value=-1, InputManager::InputDriverMode mode=INGAME, StateManager::ActivePlayer * * player=0x0012f1f4, PlayerAction * action=0x0012f1e8)  Line 366 + 0x28 bytes  C++
    supertuxkart_d.exe!InputManager::dispatchInput(Input::InputType type=IT_STICKMOTION, int deviceID=0, int button=2, Input::AxisDirection axisDirection=AD_NEUTRAL, int value=-1)  Line 411 + 0x2e bytes  C++
    supertuxkart_d.exe!InputManager::input(const irr::SEvent & event={...})  Line 662   C++

Then the test in input_device.cpp, line 214 is true for n=2 (which is the acceleration binding): the axis is 2 (as written above); the binding for acceleration has id=2, the binding for acceleration has direction=AD_NEGATIVE, which is the direction set in input_device.cpp, line 214 --> the axis 2 reset event triggers a reset of the button 2 --> resetting the acceleration to 0.

Not sure how to fix this - e.g. perhaps the reset should not be called since the -1 value should not set the prevAxisDirection to negative; or the test for the binding should be more precise (make sure to distinguish between button and axis events).

I'll assign this to auria, since you did the input handling code ;)

Not sure if this could explain many of the problems about joysticks we have seen, or if this is just an issue with this cheap gamepad (or an unusual assignment of keys and axis).

supertuxkart-sourceforge-migration commented 10 years ago

Author: auria Hi Joerg,

I have trouble following you :(

"--> the axis 2 reset event triggers a reset of the button 2 --> resetting the acceleration to 0."

can you clarify what this means, and exactly where in the code this is? And also what is the problem about this. If your axis has a value of -1 then you are indeed in the deadzone so it's OK to reset acceleration to 0 as far as i can tell.

supertuxkart-sourceforge-migration commented 10 years ago

Author: auria Ok had a chat with Joerg on IRC : the problem is that acceleration is a button, not an axis, so having axis 2 reset acceleration, which is not even on an axis, is a problem

supertuxkart-sourceforge-migration commented 10 years ago

Author: auria Expected to be fixed in r9743, please test and report back :)

supertuxkart-sourceforge-migration commented 10 years ago

Author: hikerstk Fixed on both platforms: windows and Mac now working fine.

Thanks a lot! Joerg