moonlight-embedded icon indicating copy to clipboard operation
moonlight-embedded copied to clipboard

Very high input/controller lag with connected dualshock 4 contoller on OSMC

Open duncf opened this issue 6 years ago • 3 comments

NVidia Geforce Experience version: NVIDIA GeForce GTX 950, GFE 3.13.1.30 (gs_04_05_23698325, 7.1.405.0) Moonlight Embedded version: git master Moonlight Embedded source: compile from source Moonlight Embedded running on: Raspberry Pi 3 Moonlight Embedded running on distribution: OSMC

Verbose output -verbose of Moonlight Embedded: $ moonlight stream 192.168.1.189 -app Steam -keydir /home/osmc/.cache/moonlight/d3c370b5-8363-43f6-9d56-28c4e34a9426/ -verbose Moonlight Embedded 2.4.6 (PI;ALSA;EMBEDDED) Connect to 192.168.1.189... NVIDIA GeForce GTX 950, GFE 3.13.1.30 (gs_04_05_23698325, 7.1.405.0) Platform Raspberry Pi (Broadcom) Loading mappingfile /usr/share/moonlight/gamecontrollerdb.txt No mapping available for Logitech USB Keyboard (030000006d0400001cc3000010010000) on /dev/input/event2 Detected Sony Interactive Entertainment Wireless Controller (030000004c050000cc09000011810000) on /dev/input/event5 as PS4 Controller Detected Sony Interactive Entertainment Wireless Controller Touchpad (030000004c050000cc09000011810000) on /dev/input/event3 as PS4 Controller Detected Sony Interactive Entertainment Wireless Controller Motion Sensors (030000004c050000cc09000011810000) on /dev/input/event4 as PS4 Controller Stream 1280 x 720, 60 fps, 10000 kbps Initializing platform...done Resolving host name...done Starting RTSP handshake...done Initializing control stream...done Initializing video stream...done Initializing audio stream...done Initializing input stream...done Starting control stream...done Starting video stream...done Starting audio stream...done Starting input stream...done Error: cannot keep up Error: cannot keep up

What is the expected result? Moonlight works well regardless of whether Dualshock 4 (PlayStation 4) controller is connected.

What happens instead of that? High (and increasing) input lag when the controller is connected. Notably, the mouse and keyboard are also laggy, even if the controller is completely idle, and the lag seems to increase over time.

More info The PS4 controller (CUH-ZCT2U) creates three input devices: Sony Interactive Entertainment Wireless Controller Sony Interactive Entertainment Wireless Controller Touchpad Sony Interactive Entertainment Wireless Controller Motion Sensors

From evtest, it looks like both the "... Wireless Controller" and the "... Wireless Controller Motion Sensors" devices generate events every 4 ms. moonlight-embedded seems to assume that both are independent gamepads and sends events for both to the server. The combined rate of events seems to cause lag and delays in sending the input to the server.

I have a terrible patch that causes moonlight-embedded to ignore the "... Motion Sensors" device, and that causes the lag to go away, but I'm sure there's a more elegant way to fix this.

duncf avatar Apr 22 '18 05:04 duncf

EDIT: Managed to find another thread describing how to disable any input device with "Motion Sensors" in the name.

I'm experiencing the same problem, would you be able to share how you patched moonlight-embedded?

Cheers, Francis

francisliardet avatar Jul 23 '18 08:07 francisliardet

I am experiencing the same issue with my DS4.

All of my gear is high end (except an RPI 3 XD ), I have tested it in lots of different scenarios and configurations. Overall my experience with moonlight is not all happy.

An interesting fact about DS4, if you connect via a usb cable, the streaming experience is fairly consistent, there is some lag but not a deal breaking amount for filthy casual gaming.

If you connect via bluetooth (doesnt matter if embedded or third party dongle) it starts to act up. It is worse when you make rapid inputs (i.e. fps games and such). This behavior gets worse and worse like you described.

EDIT:

I managed to lower the latency to the lowest point I had since I started experimenting with moonlight and the DS4 controller. I am using a wired Pi3 with builtin BT.

Tips I can give you with my current setup: If possible for your use case, disable WiFi completely on the RPI. Edit the config.txt with this line:

# Disable WiFi
dtoverlay=pi3-disable-wifi

Create a udev rule to disable the DS4 touchpad and motion sensors:

# Disable DS4 motion controls

# NOTES:
# cat /proc/bus/input/devices
# udevadm test <Sysfs path from cat>

SUBSYSTEM=="input", ATTRS{name}=="*Wireless Controller Motion Sensors", ENV{ID_INPUT}="", ENV{ID_INPUT_ACCELEROMETER}="", RUN+="/bin/rm %E{DEVNAME}"
SUBSYSTEM=="input", ATTRS{name}=="*Wireless Controller Touchpad", ENV{ID_INPUT}="", ENV{ID_INPUT_TOUCHPAD}="", RUN+="/bin/rm %E{DEVNAME}"

Generaly support for the DS4 is almost non existent on PC games (if you are using its BT). This is one of the reasosns why I opted to disable those features in udev rules. I am also planning to disable the DS4 hidraw input to further reduce input events sent to the Pi. I will update this thread as I discover anything new.

@francisliardet @duncf Any new information from you guys would be appreciated. @irtimmer If you are aware of these issues and possible solutions, I would greatly appreciate if you would give us some insight and update the README :)

kurac338 avatar Aug 21 '18 08:08 kurac338

I have been using the setup mentioned in my above comment since than. The gameplay has improved drastically. Partly due to me updating a couple of PC components, but on the Pi side of things due to the tweaks I commented above and recent updates to moonlight. It is now usable and seamless as it should be. Most of my complaints have been resolved, but it was a painful learning process nonetheless.

P.S. I am still looking for a way to disable hidraw input, but without success. My goal is to simply have one device detected from the DS4 (joystick / gamepad only) since I don't like rumble, touchpad and motion features. Like I said on PC's they are generally not supported natively anyway, and I doubt that they will be supported by Moonlight, Parsec, or any 3rd party software, apart from Steam.

kurac338 avatar Dec 18 '18 10:12 kurac338