joaorb64 / joycond-cemuhook

Support for cemuhook's UDP protocol for joycond devices
MIT License
143 stars 18 forks source link

Lose input for like 10 seconds frequently #17

Closed paperstiger closed 3 years ago

paperstiger commented 3 years ago

This package is a great tool for using dolphin on linux and I got it working for skyward sword, well, in most of the time. One issue that's bothering me is in about every 30 seconds (a rough estimate) the emulator is not receiving any input from my controller (for both button pressing and gyro input) for about 15 seconds. This problem just repeats. What could be going on here? I'm building dolphin from source if it helps to debug.

joaorb64 commented 3 years ago

Does this happen only when using joycond-cemuhook (mapping everything to the DSU device on Dolphin) or does it also happen with default joycond/hid_nintendo? Maybe a way of debugging it could be having a terminal window running evtest on the controller to see if the logging stops at those times...?

paperstiger commented 3 years ago

Could you please explain how I could debug it? Like how to run evtest on the controller? I am not quite familiar with how the system is working now.

joaorb64 commented 3 years ago

I'm sorry for not explaining it before. My first suspicion would be that it's a problem related to the lower-level systems. If you open a terminal and run evtest, it should list your controller along with other devices, and ask which one you'd like to test. It'll log every input coming from the controller. As the analog sticks are very sensitive, it'll kind of spam its readings on the console window.

If at any point this logging stops, the problem should be coming from those lower level systems: joycond? hid_nintendo? bluetooth adapter/driver?

If it doesn't, it's a problem in joycond-cemuhook itself.

paperstiger commented 3 years ago

It keeps printing stuff and now my issue is it's in games it seems that the left analog is kept pressed so Link keeps walking forward. All my other inputs do not work or are laggy.

paperstiger commented 3 years ago

More on this, I print the integer data in your code and it freezes frequently so I suspect it's your issue. I ctrl-C it when it freezes and the error message seems to indicate some dead lock exists.

paperstiger commented 3 years ago

OK. By lots of debugging I figured it out. It turns out sometimes reading battery status takes too long. So I just comment that function and hard code the battery value.

joaorb64 commented 3 years ago

Oh, wow. I didn't know reading the battery status had that kind of impact in the code. And to be honest, most emulators don't even use this information... I could consider removing it completely or try a better implementation. Thanks for the debugging work, I'll take a look at it as soon as I can!

joaorb64 commented 3 years ago

Fixed with https://github.com/joaorb64/joycond-cemuhook/commit/e9dda77e168b74f2fc4dd30467dfa6cd48e0e7ad. Could you test it for me? I transfered the battery level checking to another thread and made it run just once every 30s.