core: joystick support on native platforms #884

Open
opened 2023-07-28 04:07:59 +00:00 by emidoots · 1 comment
emidoots commented 2023-07-28 04:07:59 +00:00 (Migrated from github.com)

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) returns true or something. But may need more consideration.
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)` returns `true` or something. But may need more consideration.
emidoots commented 2023-07-29 19:02:18 +00:00 (Migrated from github.com)

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

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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#884
No description provided.