ikemen-engine / Ikemen-GO

An open-source fighting game engine that supports MUGEN resources.
https://ikemen-engine.github.io
Other
715 stars 125 forks source link

Joystick Input not working properly in Steam deck (SteamOS) #1609

Closed leonkasovan closed 1 month ago

leonkasovan commented 8 months ago

Describe the bug

Using nightly-build or stable 0.99.0 Ikemen Go (native linux) in Steam deck using SteamOS, joystick not working properly. DPAD Up and DPAD Down mixed. Left thumb joystick also not working. L2 and R2 button also not working. I run Ikemen_Go_Linux via shortcut created in Library -> Add non steam game.

I've tried to fix the code in input.go by separating code to input_steamdeck.go like this:

//go:build steamdeck
package main

func JoystickState(joy, button int) bool {
    if joy < 0 {
        return sys.keyState[Key(button)]
    }
    if joy >= input.GetMaxJoystickCount() {
        return false
    }
    var axes []float32
    if button >= 0 {
        // Query button state
        btns := input.GetJoystickButtons(joy)
        if button >= len(btns) {
            return false
        }
        switch button {
        case 10:    // Up: check axis and d.pad(hat)
            axes = input.GetJoystickAxes(joy)
            return (axes[1] < -0.5)|| (btns[11] != 0)
        case 11:    // Right: check axis and d.pad(hat)
            axes = input.GetJoystickAxes(joy)
            return (axes[0] > 0.5) || (btns[12] != 0)
        case 12:    // Down: check axis and d.pad(hat)
            axes = input.GetJoystickAxes(joy)
            return (axes[1] > 0.5) || (btns[13] != 0)
        case 13:    // Left: check axis and d.pad(hat)
            axes = input.GetJoystickAxes(joy)
            return (axes[0] < -0.5) || (btns[14] != 0)
        default:    // Other (normal) button
            return btns[button] != 0
        }
    } else {
        axes = input.GetJoystickAxes(joy)
        if len(axes) < 6 {
            return false
        }
        switch button {
        case -12:
            return (axes[2] > -0.5)
        case -10:
            return (axes[5] > -0.5)
        default:
            return false
        }
    }
}

I test it and the result is now working. Is there more elegan why to solve this?

To Reproduce

  1. Download Ikemen-Go (for Linux) from stable or night build
  2. Extract to /home/deck/Applications
  3. Create shortcut
  4. Play

Expected behavior

The Joystick in steamdeck work properly.

Screenshots / Video

No response

Engine Version (or source code date)

v.0.99.00 nightly build

Operating system

Other (mention in description)

Extra context or search terms

No response

two4teezee commented 3 months ago

This fix would work. A good workaround is to create an action set for Ikemen. In desktop mode, you can hold start to cycle through action sets. You can also create a new action set. Bind all of the buttons to keyboard strokes, and you can map those flawlessly. A bit of a kludge but... Ikemen Go on the Steam Deck is amazing.

K4thos commented 1 month ago

The change is worth considering, but I'd like to first test how it will behave once the SDL gamepad auto mapping feature is in place. Either way, I'm closing this one in favor of #674 since it has already been reported.