Giter Site home page Giter Site logo

Comments (7)

mmmaisel avatar mmmaisel commented on August 15, 2024 1

I can reproduce this issue with the testgamecontroller app on the Steam Deck with Gnome and both Wayland and X11.
In my test, I got an input latency of about 1 second.

I also patched the SDL_hidapi_steamdeck driver so it tries to drain the buffer, see this branch. However, this did not fix the issue so I guess there is something else causing the issue outside of the driver.

from sdl.

slouken avatar slouken commented on August 15, 2024

@mmmaisel, can you take a look?

from sdl.

mmmaisel avatar mmmaisel commented on August 15, 2024

I had a quick look at the source code without doing some real tests and noted the following things:

  • Once initialized, the HIDAPI driver only talks to the device when the function HIDAPI_DriverSteamDeck_UpdateDevice is called by SDL.
  • The driver itself is independent of vsync and other graphics code. Actually, it does not even know if vsync is enabled or not.

With this information, I have the following untested theory:

There is some synchronization issue that delays the calls to HIDAPI_DriverSteamDeck_UpdateDevice when synchronizing to the screen which takes about 16 ms at 60 Hz. In the meantime, the HIDAPI fills data in a buffer much faster every 1-4 milliseconds so the next call to the HIDAPI_DriverSteamDeck_UpdateDevice processes some outdated data. Depending on the HIDAPI buffer size, the accumulated outdated data then causes input lag of about half a second.

When the HIDAPI driver is disabled by the SDL_SetHint, a kernel driver is used instead which always present up to date data to userspace when asked without buffering old values.

from sdl.

mmmaisel avatar mmmaisel commented on August 15, 2024

@jorio, Can you please try if my steamdeck-drain-buffer branch fixes your problem?

In my tests with the testgamecontroller utility, it fixes the latency issue on the Steam Deck.

from sdl.

slouken avatar slouken commented on August 15, 2024

Oh yes, reading from the controller should definitely be done in a loop, like is done with all the other HIDAPI controllers.

from sdl.

slouken avatar slouken commented on August 15, 2024

That explains why it's related to framerate, since it's only reading one report every time through the frame loop.

from sdl.

jorio avatar jorio commented on August 15, 2024

@mmmaisel Sorry - it took me a while to get around to testing this. Can confirm that I can't perceive any more input lag. Thanks a lot!

from sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.