News for hackers. Stuff that matters.
Re:Fixing stutters in Papers Please on Linux by asdfasgasdgasdg on Sunday January 02, 2022 @07:46AM (#29768297)
A lot of games will automatically switch between keyboard and gamepad when a gamepad is connected. Perhaps this is some automatic background function that SDL handles.
Re:Fixing stutters in Papers Please on Linux by fleabitdev on Sunday January 02, 2022 @08:40AM (#29768619)
Windows uses a similar polling-based approach, with a warning that you shouldn't poll for new gamepads every frame for performance reasons:

https://docs.microsoft.com/en-us/windows/win32/xinput/gettin...

In general, "notifying the program when a new device has become available" seems to be a surprisingly difficult problem. I've encountered trouble with multiple device types across multiple platforms.

Re:Fixing stutters in Papers Please on Linux by Sharlin on Sunday January 02, 2022 @10:48AM (#29769634)
There’s a reason Plug’n’Play and USB were big deals back then. The concept of plugging in a new peripheral and it just working, without rebooting, was rather revolutionary. Even though the former was more aptly called “Plug’n’Pray” in the early years…
Re:Fixing stutters in Papers Please on Linux by dkersten on Sunday January 02, 2022 @08:28AM (#29768535)
SDL has an event for when a new gamepad is detected or removed: http://wiki.libsdl.org/SDL_ControllerDeviceEvent although I don’t know what it does internally in order to detect this (well, the article describes what it does).

But you can also manually enumerate devices as in the example here: http://wiki.libsdl.org/SDL_GameControllerOpen