omf2097 / openomf

One Must Fall 2097 Remake
http://www.openomf.org
MIT License
362 stars 35 forks source link

Gamepad doesn't work #540

Closed KenSharp closed 1 month ago

KenSharp commented 1 month ago

I have one USB gamepad attached, but the game seems to find two:

[      0][I] We currently have 508 known game controller mappings
[      0][I] No external game controller mappings file found from /usr/bin/../share/games/openomf/gamecontrollerdb.txt; skipping ...
[      0][I] Found 2 joysticks attached
[      0][I] Opened Joystick 0
[      0][I]  * Name:              HID 0566:3002
[      0][I]  * Number of Axes:    0
[      0][I]  * Number of Buttons: 21
[      0][I]  * Number of Balls:   0
[      0][I]  * Number of Hats:    0
[      0][I]  * GUID          :    03000000660500000230000010010000
[      0][I] Opened Joystick 1
[      0][I]  * Name:              USB Gamepad
[      0][I]  * Number of Axes:    4
[      0][I]  * Number of Buttons: 12
[      0][I]  * Number of Balls:   0
[      0][I]  * Number of Hats:    1
[      0][I]  * GUID          :    03000000100800000100000010010000
[      0][I]  --- BEGIN GAME LOG ---
[    488][E] Failed to open game controller: Couldn't find mapping for device (-1)
[    199][I]  --- END GAME LOG ---

Would updating SDL2 solve this?

I tried adding this and it was picked up by the game but the result is the same.

Vagabond commented 1 month ago

Does that one game pad expose 2 devices? If you unplug it, do both go away? It's certainly worth trying a newer SDL, and/or a controller db update.

KenSharp commented 1 month ago

Although Linux shows one device with lsusb, the name does suggest it might be dual?

Bus 002 Device 003: ID 0810:0001 Personal Communication Systems, Inc. Dual PSX Adaptor

If so, I have no idea what magic occurs to make this work with other games.

Vagabond commented 1 month ago

Are you using the pre-built package? CAN we ship a newer SDL?

katajakasa commented 1 month ago

On linux, we rely on the distros own libSDL2 package. It might be possible to install newer SDL2 via PPA on ubuntu, or some other mechanism on other distros. On linux we don't ship libSDL2, so not much we can do here, unfortunately.

Edit: @KenSharp You could try making your own mappings using the mapping tools (https://github.com/mdqinc/SDL_GameControllerDB/tree/master?tab=readme-ov-file#mapping-tools), then add them to the gamecontrollerdb.txt and let the openomf binary load it. Your joystick 1 ("USB Gamepad") seems like a valid device with some axes and buttons, so creating a mapping for that might work.

KenSharp commented 1 month ago

I assumed it would need to be built against a later SDL2, but I updated from 2.0.0.20 to 2.30.6 and... magic! It works!

[      0][I] Found 2 joysticks attached
[      0][I] Opened Joystick 0
[      0][I]  * Name:              USB Gamepad
[      0][I]  * Number of Axes:    4
[      0][I]  * Number of Buttons: 12
[      0][I]  * Number of Balls:   0
[      0][I]  * Number of Hats:    1
[      0][I]  * GUID          :    0300605b100800000100000010010000
[      0][I] Opened Joystick 1
[      0][I]  * Name:              HID 0566:3002
[      0][I]  * Number of Axes:    0
[      0][I]  * Number of Buttons: 21
[      0][I]  * Number of Balls:   0
[      0][I]  * Number of Hats:    0
[      0][I]  * GUID          :    03003b14660500000230000010010000

Selecting Joystick 0 works lovely, but choosing Joystick 1 causes a segfault, which is new.

Joystick 1 is actually my keyboard (USB IDs match), so I don't know what's going on there. Could be an SDL issue but I really don't anything about it.

User error. Sorry for the noise!