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

Fix input delay #345

Merged
merged 1 commit into from
May 17, 2020
Merged

Fix input delay #345

merged 1 commit into from
May 17, 2020

Conversation

RobertBorg
Copy link
Contributor

@RobertBorg RobertBorg commented May 15, 2020

fixes #344 by reading (and discarding) all but the latest available HID data. it appears to be bufffered somewhere.

TODO

  • [ ] Handle Timestamp for motion data better

@Davidobot
Copy link
Owner

Looks good. I'll test and merge when I find some time. What do you mean by "handle the timestamp" better for motion data?

@RobertBorg
Copy link
Contributor Author

Looks good. I'll test and merge when I find some time. What do you mean by "handle the timestamp" better for motion data?

I figured as you're basing the timestamp on a byte that is wrapping around it's possible that we'll get incorrect timestamps if we discard enough packets to get a wrap around. it's also possible there is only a surplus of data initially. Anyhow i've done some testing with motion data and it seems to be working well enough for my purposes. I only recently started meddling with Cemu so i'd love if someone tested this with a little broader scope.

@LionsAd
Copy link

LionsAd commented May 15, 2020

I can confirm that most likely #106 introduced the USB input lag problems.

While the fix looks good (we keep the async reading) we need to ensure that we don’t regress #106 again at the same time - but maybe the timeout reading was not needed in the first place.

Btw. @Davidobot The best controller implementation that is OSS for joycons, pro controller, DS4, etc. can be found in #chromium/chromium. Just search for Nintendo or DS4.

It’s Google typical that they rather create it in a monster code base than to provide it as a small reusable library that everyone could profit from.

Oh well - at least it is open source. I presume they use that for the Stadia Browser implementation and hence it’s quite professional including correct lighting, charging grip, etc.

Edit: I found this by accident as I tried html5 gameplay tester and suddenly my joycons were linked and had the blue light on ...

@Davidobot
Copy link
Owner

@LionsAd I assume you're referring to this: https://github.com/chromium/chromium/blob/ccd149af47315e4c6f2fc45d55be1b271f39062c/device/gamepad/nintendo_controller.cc

It's definitely something. I don't have the time and motivation to rewrite this library from scratch, but we'll see if I can salvage anything from this.

@LionsAd
Copy link

LionsAd commented May 15, 2020

Oh - for sure did not want to imply you need to rewrite anything, but sometimes it’s great if one is able to look at other implementations.

@LionsAd
Copy link

LionsAd commented May 17, 2020

I used the test build and can confirm this fixes the input delay for pro controller via USB.

@Davidobot Davidobot merged commit cd65936 into Davidobot:master May 17, 2020
@Davidobot
Copy link
Owner

@RobertBorg
#353 > potentially related to removing the timeout setting in the hdi read?

@RobertBorg
Copy link
Contributor Author

@RobertBorg
#353 > potentially related to removing the timeout setting in the hdi read?

I'm skeptical but i'll look into it. I'm working on extracting a OutputController concept from JoyCon so we don't need to have this GodClass with everything. I'm also adding diffing to ensure that we don't send updates more often than we need to. Hopefully this will allow us to process data fast enough so that we don't need to discard data any longer.

@Davidobot
Copy link
Owner

#355 also potentially related

RobertBorg added a commit to RobertBorg/BetterJoy that referenced this pull request May 19, 2020
Davidobot pushed a commit that referenced this pull request May 20, 2020
* extract xboxc360ontroller

* extracts DualShock4Controller

* Revert "ensures we get the latest available HID data (#345)"

This reverts commit cd65936.

* Revert "fixes cpu busy spinning when there is no hid data available (#356)"

This reverts commit c4f5bbd.
d3xMachina pushed a commit to d3xMachina/BetterJoy that referenced this pull request Nov 19, 2021
d3xMachina pushed a commit to d3xMachina/BetterJoy that referenced this pull request Nov 19, 2021
* extract xboxc360ontroller

* extracts DualShock4Controller

* Revert "ensures we get the latest available HID data (Davidobot#345)"

This reverts commit cd65936.

* Revert "fixes cpu busy spinning when there is no hid data available (Davidobot#356)"

This reverts commit c4f5bbd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking issue for controller input lag
3 participants