Skip to content

Unnecessary updating of joysticks and gamepads #2362

Open
@Perksey

Description

@Perksey

Summary

GLFW does not expose callbacks for joysticks and gamepads, meaning that in order to get updates from these devices, Silk.NET must get the state from GLFW every Update and manually diff the state retrieved to raise the necessary events. This causes something of an efficiency penalty (we've had a report of excessive temperatures, but most reports are profiling related) but is ultimately unavoidable. However, one of the most seemingly expensive parts of this is that we're updating all 16 gamepads/joysticks, even the disconnected ones! And interestingly GLFW does actually have a callback for joystick connection/disconnection.

I would like to propose that we change the backend to only Update when we have received a callback indicating that the joystick is connected (i.e. cache the result, and also within that callback we should also cache the result of glfwJoystickIsGamepad). This should massively reduce the amount of complaints we get with this logic.

Steps to reproduce

  • Platform: any
  • Framework Version: modern .NET desktop
  • API: Windowing
  • API Version: SDL
  1. Open a window with no input context
  2. Observe performance metrics/profiling/temperature
  3. Open a window that creates an input context
  4. Observe lower performance metrics/profiling/temperature

Comments

This was identified originally in discussion with @Chriz-G in Discord. I think they indicated they might be working on a fix. Further report received from @HolographicWings

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions