daid / EmptyEpsilon

Open source bridge simulator. Build with the SeriousProton engine.
https://daid.github.io/EmptyEpsilon/
GNU General Public License v2.0
521 stars 173 forks source link

Joystick events not detected under netboot #1987

Open fiskn opened 1 year ago

fiskn commented 1 year ago

It appears that with the current systemd service included with the netboot script that launches startx with the EE binary as a parameter. This seems to means that joysticks although detected do not register events inside EE and so cannot be used.

I can fix this behaviour by instead changing the service to simply just call the EE binary direct, which auto launches X anyway ie ExecStart=/root/EmptyEpsilon/EmptyEpsilon

I suspect this may have something to do with X and window focus so events are not being forwarded to SDL correctly, but I'm not sure if my "fix" is the correct way or just a lucky workaround?

daid commented 1 year ago

Odd and interesting. It might have something to do with startup order? Maybe X is started this way before joystick drivers are loaded?

I didn't know X could auto start like that. Any idea how that works? Is it something that systemd does? Or SDL2?

fiskn commented 1 year ago

I'm not 100% sure at the moment what is happening, I can see in the EE startup logs that the joystick is detected, just that the events are not captured either in game or on the hot key binding screen.

After doing lots of searching the only thing I could see that might have been related was that by default SDL won't capture joystick events, so wasn't sure if the way X was starting meant the EE "window" was not in focus, or something odd like that.

It was purely by accident that I noticed I could launch EE without starting X, as I was trying to view the EE startup logs from a remote SSH session and when I ran the binary, the local screen suddenly loaded up EE and the joystick was working. I then tried running the startx cmd from the same SSH session and the joystick was not working again.

daid commented 1 year ago

Oh, I think I know how X11 auto starts. That is most likely systemd socket activation magic.

I am confused about the joysticks, I thought SDL2 just goes to the input event system of linux for that.

fiskn commented 1 year ago

I think this was the thread that made me think it was a focus issue: https://github.com/libsdl-org/SDL/issues/1393

No idea if it is a focus issue, but it seemed to be a likely reason. Although no idea what not running with startx allows it to work. Also mouse and keyboard are fine, which confuses matters.

daid commented 1 year ago

That mentions pretty old SDL2 versions, I don't think the netboot is on a version that old (even if it is on old stuff)

fiskn commented 1 year ago

Sorry, should have been more clear, I didn't necessarily think the bug was the issue, but that maybe there was some confusion about window focus, effectively there being no window manager involved. And also if the SDL hint for background joystick events were of any use

I might try rebuilding SP with the hint for background joystick events: https://wiki.libsdl.org/SDL2/SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS

gwaland commented 1 year ago

I wonder if this is related to the issue I was having with my touch screens. Just for laughs you might try starting icewm and then starting empty epsilon and see if the issue is still there when there's a window manager present.

I'll try your fix in my configuration soon since I have another game this saturday.

fiskn commented 1 year ago

So it looks like when I'm directly running the EE binary X isn't actually in use, at least I can't see it running anywhere, not sure if SDL is using its KMS direct screen driver.

Anyway, this doesn't really matter anymore as after I re-compiled SeriousProton including the SDL hint for background joystick events, it seems to have fixed the problem when running under X.

daid commented 1 year ago

Oh, I tought the KMS driver was not enabled by default in SDL2. That might actually give slightly better performance then with X11.

fiskn commented 1 year ago

Oh, I tought the KMS driver was not enabled by default in SDL2. That might actually give slightly better performance then with X11.

It possibly does, but I spent several hours trying to work out how to calibrate a touchscreen when not running under X and then gave up.

Would you like a PR for the SDL hint?