openbor icon indicating copy to clipboard operation
openbor copied to clipboard

gamecontroller support broken on embedded Linux (aarch64)

Open dhwz opened this issue 1 year ago • 2 comments

I'm the developer of the AmberELEC distribution (https://github.com/AmberELEC/AmberELEC) we build openbor from latest source, since a commit a few weeks ago gamecontrollers via SDL2 don't work, I've neared it down to the change of commit b8303cce992a0db93c3a465df3c943942fe322f8 to 8fb3432eb3d4cbbcc6b9e8c0a265816040fd1ff6. The first one is ok, the 2nd one doesn't respond to any button. Seems there was some hidden merge commit between so on Github most changes are invisible. Any idea what could have changed so gamecontrollers don't work anymore?

If I can help getting more information just let me know.

dhwz avatar Jan 24 '24 17:01 dhwz

@dhwz

I haven't made any control changes, but there were a lot of fixes made by @fgames9000. I would suggest bringing it up in the forum and he can check it out.

DCurrent avatar Jan 30 '24 05:01 DCurrent

@dhwz

I haven't made any control changes, but there were a lot of fixes made by @fgames9000. I would suggest bringing it up in the forum and he can check it out.

The latest controller fixes I made were pushed some years ago, currently I didn't make any controller updates. Maybe @msmalik681 can give us a hand.

fgames9000 avatar Jan 30 '24 05:01 fgames9000

I confirm that the issue still happens for Linux-ARM64 systems.

I have compiled the latest code many times, with different SET options on the linux.cmake file and even though games are loaded and rendered ok (ditto audio), SDL2's input does not work anymore.

I can help testing on a Trimui Smart Pro, @DCurrent / @msmalik681 .

Ultrahead avatar Oct 17 '25 21:10 Ultrahead

The previous version I have is OpenBoR v3.0 Build 7144, where input works, and the log output is the following ...

Total Ram:  1021739008 Bytes (   974 MB )
 Free Ram:   152014848 Bytes (   144 MB )
 Used Ram:     1285120 Bytes (     1 MB )

debug:nativeWidth, nativeHeight, bpp, Hz  1280, 720, 24, 60
OpenBoR v3.0 Build 7144 (commit hash: b8303cc), Compile Date: Nov 21 2023

Game Selected: /mnt/SDCARD/Emus/OPENBOR/../../Roms/OPENBOR/GOW.pak

Loaded mapping for X360 Controller
Loaded mapping for Keyboard
FileCaching System Init......	Enabled
Initializing video............
Reading video settings from 'data/video.txt'.

Colordepth is depreciated. All modules are displayed with a 32bit color screen.

Initialized video.............	320x240 (Mode: 0)

320x240
Loading menu.txt.............	Done!
Loading fonts................	1 2 3 4 6 Done!
Timer init...................	Done!
Initialize Sound..............	
Loading sprites..............	Done!
Loading level order..........	Done!
Loading model constants......	Done!
Loading script settings......	Done!
Loading scripts..............	Done!
Loading models...............

Controller or joystick hotplugged: SDL device ID=0
X360 Controller (device #0, SDL ID 0) is a game controller.
Hotplugged controller set as device #0
Cacheing 'Flash' from data/chars/misc/flash.txt
Cacheing 'Flash2' from data/chars/misc/flash2.txt
Cacheing 'Flash3' from data/chars/misc/flash3.txt
Cacheing 'Block' from data/chars/misc/Block.txt
Cacheing 'Kratos' from data/chars/Kratos/Kratos.txt
Cacheing 'Loki' from data/chars/Loki/Loki.txt
Cacheing 'Thor' from data/chars/Asgard/Thor.txt
Cacheing 'Raio' from data/chars/Asgard/Raio.txt
Cacheing 'Fandral' from data/chars/Asgard/Fandral.txt
Cacheing 'Heimdall' from data/chars/Asgard/Heimdall.txt
Cacheing 'Hogun' from data/chars/Asgard/Hogun.txt
Cacheing 'Sif' from data/chars/Asgard/Sif.txt
Cacheing 'Volstagg' from data/chars/Asgard/Volstagg.txt
Cacheing 'Solda' from data/chars/Asgard/Solda.txt
Cacheing 'Cav' from data/chars/Asgard/Cav.txt
Cacheing 'Ice_giant' from data/chars/Asgard/Ice_giant.txt
Cacheing 'LokiClone' from data/chars/Loki/LokiClone.txt
Cacheing 'LokiFaca' from data/chars/Loki/LokiFaca.txt

Loaded 'Flash' from data/chars/misc/flash.txt 
Loaded 'Flash2' from data/chars/misc/flash2.txt 
Loaded 'Flash3' from data/chars/misc/flash3.txt 
Loaded 'Block' from data/chars/misc/Block.txt 
Loaded 'Kratos' from data/chars/Kratos/Kratos.txt 
Loaded 'Loki' from data/chars/Loki/Loki.txt 
Loaded 'LokiClone' from data/chars/Loki/LokiClone.txt 
Loaded 'LokiFaca' from data/chars/Loki/LokiFaca.txt 

Loading models...............	Done!
Object engine init...........	Done!
Input init...................	X360 Controller (device #0, SDL ID 0) is a game controller.
Done!
Create blending tables.......	Done!
Save settings so far........	Done!

As you can see, the controller is properly detected and input mapping is loaded.

Now, for the current version, OpenBoR v4.0 Build 7755, where input fails the log output is ...

Total Ram:  1021739008 Bytes (   974 MB )
 Free Ram:   155316224 Bytes (   148 MB )
 Used Ram:     1143296 Bytes (     1 MB )

debug:nativeWidth, nativeHeight, bpp, Hz  1280, 720, 24, 60
OpenBoR v4.0 Build 7755 (commit hash: f71c4fd), Compile Date: Oct 18 2025

Game Selected: /mnt/SDCARD/Emus/OPENBOR/../../Roms/OPENBOR/GOW.pak

FileCaching System Init.......	Enabled
Initializing video............
Reading video settings from 'data/video.txt'.

Colordepth is not supported anymore. All modules are displayed with a 32bit color screen.

Initialized video............	320x240 (Mode: 0)

Timer init...................	Done!
Initialize Sound.............	
Loading fonts................	1 2 3 4 6 Done!
Loading sprites..............	Done!
Loading level order..........	Done!
Loading model constants......	Done!
Loading script settings......	Done!
Loading scripts..............	Done!
Loading models...............

Joystick: "Unknown" connected at port: 0 at 2025-10-18 09:11:05
Caching 'Flash' from data/chars/misc/flash.txt
Caching 'Flash2' from data/chars/misc/flash2.txt
Caching 'Flash3' from data/chars/misc/flash3.txt
Caching 'Block' from data/chars/misc/Block.txt
Caching 'Kratos' from data/chars/Kratos/Kratos.txt
Caching 'Loki' from data/chars/Loki/Loki.txt
Caching 'Thor' from data/chars/Asgard/Thor.txt
Caching 'Raio' from data/chars/Asgard/Raio.txt
Caching 'Fandral' from data/chars/Asgard/Fandral.txt
Caching 'Heimdall' from data/chars/Asgard/Heimdall.txt
Caching 'Hogun' from data/chars/Asgard/Hogun.txt
Caching 'Sif' from data/chars/Asgard/Sif.txt
Caching 'Volstagg' from data/chars/Asgard/Volstagg.txt
Caching 'Solda' from data/chars/Asgard/Solda.txt
Caching 'Cav' from data/chars/Asgard/Cav.txt
Caching 'Ice_giant' from data/chars/Asgard/Ice_giant.txt
Caching 'LokiClone' from data/chars/Loki/LokiClone.txt
Caching 'LokiFaca' from data/chars/Loki/LokiFaca.txt

Loading 'Flash' from data/chars/misc/flash.txt 
 ...done!
Loading 'Flash2' from data/chars/misc/flash2.txt 
 ...done!
Loading 'Flash3' from data/chars/misc/flash3.txt 
 ...done!
Loading 'Block' from data/chars/misc/Block.txt 
 ...done!
Loading 'Kratos' from data/chars/Kratos/Kratos.txt 
 ...done!
Loading 'Loki' from data/chars/Loki/Loki.txt 
Loading 'LokiClone' from data/chars/Loki/LokiClone.txt 
 ...done!
Loading 'LokiFaca' from data/chars/Loki/LokiFaca.txt 
 ...done!
 ...done!

Loading models...............	Done!
Object engine init...........	Done!
Loading menu.txt.............	Done!
Loading translation..........	Done!
Input init...................	
1 joystick(s) found!
Unknown (Xbox 360 Controller) - 6 axes, 11 buttons, 1 hat(s), rumble support: no
Done!
Create blending tables.......	Done!
Save settings so far.........	Done!

As you can see, for the same games, the current version does not retrieve the mapping for the X360 Controller and the mapping for Keyboard. Plus the XBox360 controller is not hot-plugged.

Thoughts?

Ultrahead avatar Oct 18 '25 01:10 Ultrahead

@DCurrent @msmalik681

Ultrahead avatar Oct 18 '25 09:10 Ultrahead

@Plombo has anything changed in the controller code for openbor 4.0 ?

@Ultrahead were both tests done on the same system ?

msmalik681 avatar Oct 18 '25 12:10 msmalik681

Closed by mistake

msmalik681 avatar Oct 18 '25 12:10 msmalik681

Yes, on the same system. Trimui Smart Pro.

For all the games is the same. The new version (which doesn't work) results in:

1 joystick(s) found!
Unknown (Xbox 360 Controller) - 6 axes, 11 buttons, 1 hat(s), rumble support: no
Done!

And the old version (which works ok) in ...

Controller or joystick hotplugged: SDL device ID=0
X360 Controller (device #0, SDL ID 0) is a game controller.
Hotplugged controller set as device #0

...

Input init...................	X360 Controller (device #0, SDL ID 0) is a game controller.
Done!

Ultrahead avatar Oct 18 '25 13:10 Ultrahead

Im away for a week but leave this with me i will look into it.

msmalik681 avatar Oct 18 '25 13:10 msmalik681

Thanks.

An additional note:

In the old version, this is also logged ...

Loaded mapping for X360 Controller
Loaded mapping for Keyboard

(in the new one, either it does not happened or it is not logged)

Ultrahead avatar Oct 18 '25 13:10 Ultrahead

It seems the logic that handles the detection of XBox360 controller has been moved to Android devices, only.

The TSP is a retro-gaming console with built-in joystick/gampad controller and TinaLinux as OS.

EDIT: in the newest code, there is no traces of printf sentences using Loaded mapping for ..., Controller or joystick hotplugged ... and so on so forth.

Maybe line 247 of control.c should give you a hint ... // new PC joystick code - forget about SDL joystick events, just do a state check

Ultrahead avatar Oct 18 '25 18:10 Ultrahead

According to what I saw in the code, the build 7144 contains an input rework made by Plombo that detects Xbox controllers natively using Xinput. However, it was temporarily reverted here (January/2023, look at the control.c file) until some issues were fixed.

In short, the current code is basically the legacy version from v3 with a few fixes applied years ago. If you compare the builds 7034 and 7755 you will see that almost everything is the same.

fgames9000 avatar Oct 25 '25 01:10 fgames9000

Im away for a week but leave this with me i will look into it.

@msmalik681 any luck?

Ultrahead avatar Oct 28 '25 22:10 Ultrahead

Back on the 1st

msmalik681 avatar Oct 29 '25 04:10 msmalik681

@msmalik681 do we need to reopen this issue? Or create a new one? So as to keep a trackrecord of the issue?

Ultrahead avatar Nov 03 '25 16:11 Ultrahead

Any idea about the issue @msmalik681 ?

Ultrahead avatar Nov 06 '25 12:11 Ultrahead

It needs to be reopened. @Ultrahead can you test on the windows version to confirm if this is only happening on linux.

msmalik681 avatar Nov 06 '25 13:11 msmalik681

Tested on Windows. It perfectly works. Input is properly recognized.

Ultrahead avatar Nov 06 '25 17:11 Ultrahead

Do you need me to test anything else?

Ultrahead avatar Nov 08 '25 03:11 Ultrahead

I modified the code on control.c file in the ./engine/sdl/ folder so that it prints when a button is held down and released, and I can confirm that buttons are properly detected:

Updating Joystick 0 state ... 
Button down: controller 0, button 0
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button up: controller 0, button 0
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button down: controller 0, button 2
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button up: controller 0, button 2
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button down: controller 0, button 3
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button up: controller 0, button 3
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button down: controller 0, button 1
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Button up: controller 0, button 1
Updating Joystick 0 state ... 

So, the thing is that for some reason that info is either not passed or not processed by the games' logic.

Ultrahead avatar Nov 10 '25 17:11 Ultrahead

I dont have a 360 controller to test with. I will try to find my ps2 controller and test with that.

msmalik681 avatar Nov 10 '25 17:11 msmalik681

Ditto with Axis and Hot motion. It is detected ...

Updating Joystick 0 state ... 
Joystick Axis Motion detected
Joystick Axis Motion detected
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Joystick Hat Motion detected
Updating Joystick 0 state ... 
Updating Joystick 0 state ... 
Joystick Hat Motion detected
Updating Joystick 0 state ... 

Ultrahead avatar Nov 10 '25 17:11 Ultrahead

Ah, grabbed an xbox controller and tested on Windows11. It doesn't work either.

The controller does work. Last time I checked that I said it worked fine, I was testing only with the keyboard.

Ultrahead avatar Nov 10 '25 17:11 Ultrahead

I don't have a ps2 controller to test with @msmalik681, so I hope you can repro the issue with it.

Ultrahead avatar Nov 10 '25 17:11 Ultrahead

Any luck testing with the PS2 controller, @msmalik681 ?

Ultrahead avatar Nov 10 '25 22:11 Ultrahead