core: joystick support on native platforms
joystick support was added in https://github.com/hexops/mach-core/pull/12 but as part of the multi-threaded rendering support https://github.com/hexops/mach-core/pull/15 I had to disable it.
To bring it back, we need to adjust the API:
- Rename
Joystick->Gamepad - Change the "I can immediately poll for joystick information" style API to "I would like to request to use the joystick API" -> "now I can use it" style API.
- Because using joysticks means the main thread will need to poll that information, and store it in-memory for retrieval by the e.g. render thread - which is not free.
- And because it seems likely browsers (in the future) and other platforms may require permission to access controllers.
- Note: This can be as simple as all polling methods currently returning some "zero value" until
gamepadReady(id)returnstrueor something. But may need more consideration.
Another excellent reason to switch to a request-based API:
https://github.com/glfw/glfw/issues/1284
foxxne ran into this on Windows, where initialization was taking ~45s and just displaying a white screen until then. Didn't realize that the application was not broken. Just randomly occurred on their system, was working fine before.
If we switch to a request-based API, then at least once you 'request' joystick access we can document it may take a while (and may block the main thread) if your system is broken (fun!)
Symptoms: unresponsive white window, Windows 11 Suspected cause: recently updated iCue (corsairs thing) Workaround: reboot