2 ms·
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 h
by asdfasgasdgasdg 5y ago
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.
- dkersten 5y agoSDL has an event for when a new gamepad is detected or removed: http://wiki.libsdl.org/SDL_ControllerDeviceEvent 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 http://wiki.libsdl.org/SDL_GameControllerOpen
- fleabitdev 5y agoWindows 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/getting-started-with-xinput#getting-controller-state 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.
- Sharlin 5y agoThere’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…