Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary updating of joysticks and gamepads #2362

Open
Perksey opened this issue Nov 21, 2024 · 0 comments
Open

Unnecessary updating of joysticks and gamepads #2362

Perksey opened this issue Nov 21, 2024 · 0 comments
Labels
area-Input bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@Perksey
Copy link
Member

Perksey commented Nov 21, 2024

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

@Perksey Perksey added area-Input bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Nov 21, 2024
@Perksey Perksey added this to the 2.X milestone Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Input bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Todo
Development

No branches or pull requests

1 participant