LizardByte / Sunshine

Self-hosted game stream host for Moonlight.
http://app.lizardbyte.dev/Sunshine/
GNU General Public License v3.0
20.02k stars 963 forks source link

Mousewheel or Middle mouse btn doesn't work in some games #1873

Closed cardil closed 5 months ago

cardil commented 12 months ago

Is there an existing issue for this?

Is your issue described in the documentation?

Is your issue present in the nightly release?

Describe the Bug

In some games, the mouse wheel doesn't work (in my case: Witcher 3, Black Mesa, Fallout 3). In some of those, the middle mouse button also doesn't work (Witcher 3). The Left and Right buttons work as expected.

Also, in other games, the mouse wheel works as expected. I've tested: Age of Wonders 3, Cities Skylines, Cyberpunk 2077 (works although only when scrolling v. fast), Master of Orion, Two Point Hospital, War For The Overworld.

Evidence:

Expected Behavior

The mouse scroll and the middle mouse button should work in every game.

Additional Context

Uninstalling the Sunshine, and enabling streaming via GeForce Experience, resolves the described issues in all affected games.

The issue doesn't affect the desktop or web browsers when accessed via Sunshine.

Host Operating System

Windows

Operating System Version

Windows 10 Pro (22H2, build 19045.3693)

Architecture

64 bit

Sunshine commit or version

0.21.0.336062d467d5f48ba56d05a523c212f791421108

Package

Windows - installer

GPU Type

Nvidia

GPU Model

GeForce GTX 1060 6GB

GPU Driver/Mesa Version

546.17

Capture Method (Linux Only)

No response

Config

min_log_level = 2
back_button_timeout = 2000
fps = [10,30,60]
nvenc_preset = 2
resolutions = [
    352x240,
    480x360,
    858x480,
    1280x720,
    1920x1080
]

Apps

{
    "env": {
        "PATH": "$(PATH);$(ProgramFiles(x86))\\Steam"
    },
    "apps": [
        {
            "name": "Desktop",
            "image-path": "desktop.png"
        },
        {
            "name": "Steam",
            "detached": [
                "steam steam:\/\/open\/bigpicture"
            ],
            "image-path": "steam.png",
            "exclude-global-prep-cmd": "false",
            "elevated": "false",
            "auto-detach": "true"
        },
        {
            "name": "Playnite",
            "output": "",
            "cmd": "D:\/programy\/Playnite\/Playnite.FullscreenApp.exe --startfullscreen --hidesplashscreen",
            "exclude-global-prep-cmd": "false",
            "elevated": "false",
            "auto-detach": "true",
            "image-path": "playnite.png"
        }
    ]
}

Relevant log output

Nothing relevant found in the log output.

Attaching full for for completness: https://gist.github.com/cardil/6ab7d5466e57d1982803108441877853

Bobbar commented 11 months ago

Do you have a mouse physically plugged into the host? I had the same problems with Witcher and solved it by connecting a mouse to the host.

cardil commented 11 months ago

@Bobbar Do you have a mouse physically plugged into the host? I had the same problems with Witcher and solved it by connecting a mouse to the host.

No mouse at the host. I'll definitely try this walk-around...

cardil commented 11 months ago

I did some further debugging, and I saw some strange behavior. When the mouse scrolling, moonlight/sunshine sends multiple scroll packets (even for minimal mouse scroll) - 5 to be exact:

[2023:12:02:22:19:55]: Debug: --begin mouse scroll packet--
scrollAmt1 [-60]
--end mouse scroll packet--
[2023:12:02:22:19:55]: Debug: --begin mouse scroll packet--
scrollAmt1 [-15]
--end mouse scroll packet--
[2023:12:02:22:19:55]: Debug: --begin mouse scroll packet--
scrollAmt1 [-15]
--end mouse scroll packet--
[2023:12:02:22:19:55]: Debug: --begin mouse scroll packet--
scrollAmt1 [-15]
--end mouse scroll packet--
[2023:12:02:22:19:55]: Debug: --begin mouse scroll packet--
scrollAmt1 [-15]
--end mouse scroll packet--

In contrast, when the LMM is pressed, only one packet is sent (here is a long click and release example):

[2023:12:02:22:19:49]: Debug: --begin mouse button packet--
action [00000008]
button [01]
--end mouse button packet--
[2023:12:02:22:19:52]: Debug: --begin mouse button packet--
action [00000009]
button [01]
--end mouse button packet--

This could easily explain bad behavior in Black Mesa game, maybe others too.

cgutman commented 11 months ago

@cardil What's your client device (and client device's mouse)?

Moonlight will send high resolution scroll events to Sunshine if they are provided by the client OS and the mouse hardware, so you can see multiple scroll events for one "click" of the scroll wheel. A single click of the scroll wheel is defined as 120 units (WHEEL_DELTA), so the high resolution scroll events you note there all add up to a single click of the wheel, as expected.

Some applications (particularly old ones) may not correctly handle high resolution scroll events and incorrectly assume that they should scroll for every event instead of accumulating 120 units before scrolling. I wouldn't expect the behavior of these apps with Sunshine to be any different from physically connecting a mouse with a high resolution scroll wheel directly to the host though.

cardil commented 11 months ago

@cgutman Thanks for the information.

I'm using Logitech M705, and yes, I can see multiple events for every click in my local mouse events:

# libinput debug-events --device /dev/input/event10 | grep -v MOTION
-event10  DEVICE_ADDED            Logitech M705                     seat0 default group1  cap:p left scroll-nat scroll-button

 event10  POINTER_SCROLL_WHEEL    +6.930s   vert 7.50/60.0* horiz 0.00/0.0 (wheel)
 event10  POINTER_SCROLL_WHEEL    +6.938s   vert 1.88/15.0* horiz 0.00/0.0 (wheel)
 event10  POINTER_SCROLL_WHEEL    +6.954s   vert 1.88/15.0* horiz 0.00/0.0 (wheel)
 event10  POINTER_SCROLL_WHEEL    +6.962s   vert 1.88/15.0* horiz 0.00/0.0 (wheel)
 event10  POINTER_SCROLL_WHEEL    +6.970s   vert 1.88/15.0* horiz 0.00/0.0 (wheel)

The same event values could be seen in this log (first one valued 60, followed up by 4 times 15 summing to 120 - the click value).

I checked using this codepen on the same mouse on Firefox gives me singular events for mouse scroll (in Chrome I see many).

Using a different mouse (Lenovo) gives only singular events, all valued 120. With that other mice, the HL Black Mesa issue is no more present. Other issues, still exist.

Strangely, using the codepen on a remote host via moonlight and sunshine, gives multiple events for both browsers. However, it looks the values are scaled up (I see 72 instead of 60, and 18 instead of 15 in Firefox, and 62.5 and 15.625 in Chrome).

I'm thinking that it might be feasible to build a debouncer in Sunshine to merge the remote mouse scroll events into singular values, but that seems to resolve just a single issue (the Black Mesa one). IDK, is that a good idea...

Bobbar commented 11 months ago

If I may chime in...

I've personally not been a fan of the recent high-res scrolling changes (or high-res scrolling in general).

It makes some games and apps feel sluggish to me. I just prefer a more "notchy" feel.

Would it be much trouble to just add a toggle to bypass the high-res scrolling entirely and return the previous behavior?

ottelo9 commented 9 months ago

I have big problems with my mouse wheel in the game Snowrunner with Moonlight QT (5.0.1 Win10) + Sunshine (v0.21.0). I have no connected controllers (host + client) and disabled everything controller related inside moonlight and sunshine settings.

I start the Stream and start Snowrunner. I can play for few minutes and zoom in/out the ingame map without problems. After few minutes the zoom (or the mouse wheel) is not working properly anymore. I can only zoom completly in or out, no Intermediate steps. If I slowly scroll my mouse wheel nothings happens.

Then I tried the nightly Sunshine build (last week Feb 2024) and disabled the high res scrolling. But with no success and the streams starts hanging/lagging, too. So I went back to Nvidia Gamestream, because with it I have no such problems.

cardil commented 8 months ago

The #1960 resolved my issue with the Black Mesa game (disabling the high-resolution scroll events).

It didn't fix the issues with Fallout 3 or Wither 3.

Seculation: Maybe the issues are related to how the virtual mouse drivers act?!

LizardByte-bot commented 5 months ago

It seems this issue hasn't had any activity in the past 90 days. If it's still something you'd like addressed, please let us know by leaving a comment. Otherwise, to help keep our backlog tidy, we'll be closing this issue in 10 days. Thanks!

LizardByte-bot commented 5 months ago

This issue was closed because it has been stalled for 10 days with no activity.