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

Adding Mouse Sensitivity Setting in Moonlight?

Open somerandomperson123 opened this issue 6 years ago • 17 comments

I had a previous post regarding this - https://github.com/moonlight-stream/moonlight-qt/issues/116

but that seemed to go off topic to discussing mouse acceleration/mouse input.

What I'm wondering about is the possibility of Moonlight itself having a sensitivity option that modifies mouse sensitivity?

Perhaps this is only an issue that affects me. My problem is that I run Moonlight on PC with a lower DPI mouse and a lower resolution monitor compared to my home PC (host).

somerandomperson123 avatar Nov 07 '18 08:11 somerandomperson123

I would also appreciate that in settings.

JuniorJPDJ avatar Nov 18 '18 16:11 JuniorJPDJ

Same problem for me. For now i've managed the problem using a mouse with switchable DPI on the client pc, so, when i take the host control, I switch to higher DPI and voilàt

Zibbibbo avatar Dec 08 '18 20:12 Zibbibbo

Yes, that would be really useful, hopefully that option would be added

Ravstin avatar Feb 12 '19 17:02 Ravstin

I would appreciate moonlight just not changing my mouse settings every time.

installgentoo avatar Jun 29 '20 18:06 installgentoo

@installgentoo It's not something we can control. See moonlight-stream/nvidia-gamestream-issues#41

cgutman avatar Jun 29 '20 18:06 cgutman

@cgutman I understand that enhanced mouse pointer precision changes by Geforce Experience can't be prevented by moonlight. Instead, after the client connects Is it possible to change the Windows host's enhanced pointer precision in order to mitigate issue moonlight-stream/moonlight-qt#116? In addition, mouse speed could be set at this time to accommodate @somerandomperson123's issue with differences in cursor input between client and host.

For example, in moonlight settings there could be a host mouse sensitivity slider and enhanced pointer precision checkbox. If the option to use such settings is enabled then moonlight sets those settings on the PC after the client connects. An additional option may be needed to return the host PC's mouse settings to a different setting after the client disconnects.

In my research I found this stackoverflow exchange discussing how to change mouse speed in C++, and this post discussing how to change the enhanced pointer precision setting in C++.

All the above is about such a feature is possible, but not if it's desirable. Would it be desirable to incorporate such a feature? There appears to be only two issues regarding mouse speed moonlight-stream/moonlight-qt#33 moonlight-stream/moonlight-qt#125, and four regarding enhanced mouse pointer precision moonlight-stream/moonlight-qt#480 moonlight-stream/nvidia-gamestream-issues#41 moonlight-stream/moonlight-qt#314 moonlight-stream/moonlight-qt#258.

If it is desirable to add such a feature, how could the UI be setup so the feature is as simple and intuitive as possible? And, what would happen if the host closes moonlight, or moonlight crashes, before the client disconnects? Would the mouse settings remain at the modified ones? Is that acceptable?

DeadBranches avatar Jan 27 '21 14:01 DeadBranches

@SalvatoryMalamar just add a "set host mouse settings" checkbox and then user's responsible for resetting them back.

User can then also just set moonlight mouse settings to whatever he has on his desktop in the first place, and you won't have to reset settings every time.

installgentoo avatar Jan 27 '21 23:01 installgentoo

@SalvatoryMalamar Signed up to say that feature would help me big time! Streaming from my 1920x1080 PC to a Shield TV 65"4k, my DS4 controller with the mouse emulation on is completely out of whack! High sensitivity and acceleration make it nearly impossible to change the host settings without using the host settings manually.

StuartMinkus avatar Jan 28 '21 05:01 StuartMinkus

I would also love that function. I mean, I can fix it with a bat to disable it, but that shouldn't be an issue to begin with.

Tsubajashi avatar May 30 '21 21:05 Tsubajashi

Check that fix :

Even with the box ticked, no acceleration !

http://donewmouseaccel.blogspot.com/2010/03/markc-windows-7-mouse-acceleration-fix.html?m=1

I never use it so I don't care, it's a workaround for old games that enable mouse acceleration...

mrwiwi avatar Aug 13 '21 15:08 mrwiwi

You can edit "C:\Program Files\NVIDIA Corporation\NvStreamSrv\nvstreamer.exe" directly to disable it calling SystemParametersInfoA to set mouse acceleration.

Just replace the bytes "FF 15 7F 62 0A 00" with "B8 01 00 00 00 90" using a hex editor like HxD.

Tested on GeForce Experience 3.24.0.123, nvstreamer.exe file version 7.1.3048.4816.

Since these are relative offsets, they may not change with versions, but the steps to reproduce are to just analyze the executable and search for all instances of the referenced function. On this version, it was the third last instance, then just replace it with the same bytes for it to spoof the return success flag.

moonlight-stream/moonlight-qt#513

EDIT: GeForce Experience 3.24.0.126, nvstreamer.exe 7.1.3069.1119. Replace the bytes "FF 15 FF 60 0A 00" with "B8 01 00 00 00 90"

GeForce Experience 3.24.0.127, nvstreamer.exe 7.1.3110.6651. Replace the bytes "FF 15 4F 60 0A 00" with "B8 01 00 00 00 90"

predprey2 avatar Dec 02 '21 03:12 predprey2

I found this PowerShell snippet somewhere on Stack Overflow. Running this in PowerShell will disable Enhanced Pointer Precision. This is not permanent, it's equivalent to unchecking the "Enhance Pointer Precision" box in main.cpl.

I used PS2EXE module in PowerShell 5 to make an exe out of it. I've confirmed that the exe does work when executed.

Just need some way to trigger it on connection. Task Scheduler didn't seem to work for me, because I couldn't find any event to link the trigger to in Event Viewer. Maybe someone else can get it to work. Please post back if so.

$code=@' [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, int[] pvParam, uint fWinIni); '@ Add-Type $code -name Win32 -NameSpace System [System.Win32]::SystemParametersInfo(4,0,0,2)

sivan-koren avatar Mar 22 '22 20:03 sivan-koren

You can edit "C:\Program Files\NVIDIA Corporation\NvStreamSrv\nvstreamer.exe" directly to disable it calling SystemParametersInfoA to set mouse acceleration.

Just replace the bytes "FF 15 7F 62 0A 00" with "B8 01 00 00 00 90" using a hex editor like HxD.

Tested on GeForce Experience 3.24.0.123, nvstreamer.exe file version 7.1.3048.4816.

Since these are relative offsets, they may not change with versions, but the steps to reproduce are to just analyze the executable and search for all instances of the referenced function. On this version, it was the third last instance, then just replace it with the same bytes for it to spoof the return success flag.

moonlight-stream/moonlight-qt#513

EDIT: GeForce Experience 3.24.0.126, nvstreamer.exe 7.1.3069.1119. Replace the bytes "FF 15 FF 60 0A 00" with "B8 01 00 00 00 90"

'FF 15 FF 60 0A 00' is no longer avaliable in Geforce Experience 3.25.1.27 (nvstreamer.exe 7.1.3110.6651)

Whats the new bytes should be replaced now? Or, whats the easiest way to find it?

Autliety avatar Apr 25 '22 13:04 Autliety

You can edit "C:\Program Files\NVIDIA Corporation\NvStreamSrv\nvstreamer.exe" directly to disable it calling SystemParametersInfoA to set mouse acceleration. Just replace the bytes "FF 15 7F 62 0A 00" with "B8 01 00 00 00 90" using a hex editor like HxD. Tested on GeForce Experience 3.24.0.123, nvstreamer.exe file version 7.1.3048.4816. Since these are relative offsets, they may not change with versions, but the steps to reproduce are to just analyze the executable and search for all instances of the referenced function. On this version, it was the third last instance, then just replace it with the same bytes for it to spoof the return success flag. moonlight-stream/moonlight-qt#513 EDIT: GeForce Experience 3.24.0.126, nvstreamer.exe 7.1.3069.1119. Replace the bytes "FF 15 FF 60 0A 00" with "B8 01 00 00 00 90"

'FF 15 FF 60 0A 00' is no longer avaliable in Geforce Experience 3.25.1.27 (nvstreamer.exe 7.1.3110.6651)

Whats the new bytes should be replaced now? Or, whats the easiest way to find it?

'FF 15 FF 60 0A 00' worked for me in latest nvstreamer.exe 7.1.3110.6651.

However, HxD would not find this hex string for me when I tried it. I had to use Hextor before I successfully found it. Make sure to tick "HEX" in hextor's 'Find' tool. There was only one occurence of this hex string & replacing it with 'B8 01 00 00 00 90' (as mentioned by predprey2) worked perfectly for me & sorted the problem.

samtowers avatar May 12 '22 16:05 samtowers

You can edit "C:\Program Files\NVIDIA Corporation\NvStreamSrv\nvstreamer.exe" directly to disable it calling SystemParametersInfoA to set mouse acceleration. Just replace the bytes "FF 15 7F 62 0A 00" with "B8 01 00 00 00 90" using a hex editor like HxD. Tested on GeForce Experience 3.24.0.123, nvstreamer.exe file version 7.1.3048.4816. Since these are relative offsets, they may not change with versions, but the steps to reproduce are to just analyze the executable and search for all instances of the referenced function. On this version, it was the third last instance, then just replace it with the same bytes for it to spoof the return success flag. moonlight-stream/moonlight-qt#513 EDIT: GeForce Experience 3.24.0.126, nvstreamer.exe 7.1.3069.1119. Replace the bytes "FF 15 FF 60 0A 00" with "B8 01 00 00 00 90"

'FF 15 FF 60 0A 00' is no longer avaliable in Geforce Experience 3.25.1.27 (nvstreamer.exe 7.1.3110.6651) Whats the new bytes should be replaced now? Or, whats the easiest way to find it?

'FF 15 FF 60 0A 00' worked for me in latest nvstreamer.exe 7.1.3110.6651.

However, HxD would not find this hex string for me when I tried it. I had to use Hextor before I successfully found it. Make sure to tick "HEX" in hextor's 'Find' tool. There was only one occurence of this hex string & replacing it with 'B8 01 00 00 00 90' (as mentioned by predprey2) worked perfectly for me & sorted the problem.

Strange. I am also unable to find that pattern in the nvstreamer.exe. I just tried this with Hextor 0.13, on nvstreamer.exe 7.1.3110.6651, checking the HEX box in the find dialog, and got "search pattern not found." As a test to confirm that Hextor is finding other patterns, I searched for 01 FA E6 0C 00 8F 84 0A and did find a result.

sivan-koren avatar May 12 '22 17:05 sivan-koren

Strange. I am also unable to find that pattern in the nvstreamer.exe. I just tried this with Hextor 0.13, on nvstreamer.exe 7.1.3110.6651, checking the HEX box in the find dialog, and got "search pattern not found." As a test to confirm that Hextor is finding other patterns, I searched for 01 FA E6 0C 00 8F 84 0A and did find a result.

I found it at address 25D650 (on the left):

image

The highlighted hex shows 'B8 01 00 00 00 90' as I've already replaced it. Previously this was 'FF 15 FF 60 0A 00'.

samtowers avatar May 12 '22 17:05 samtowers

UPDATE: This doesn't work!

I find a very similar string at that address, but the 3rd byte is 4F not FF.

The solution may be to search and change FF 15 4F 60 0A 00 to B8 01 00 00 00 90.

Not tested. Screenshot below for the address on my nvstreamer.exe. Screenshot 2022-05-12 115903

sivan-koren avatar May 12 '22 18:05 sivan-koren

UPDATE: This doesn't work!

I find a very similar string at that address, but the 3rd byte is 4F not FF.

The solution may be to search and change FF 15 4F 60 0A 00 to B8 01 00 00 00 90.

Not tested. Screenshot below for the address on my nvstreamer.exe. Screenshot 2022-05-12 115903

GeForce Experience 3.26.0.131, nvstreamer.exe 7.1.3164.8965. Replace the bytes "FF 15 1A DE 1A 00" with "B8 01 00 00 00 90"

predprey2 avatar Sep 30 '22 14:09 predprey2

I think this patching method is very useful, rather than waiting for nvidia to add this option and fix. Thanks!

I wonder, is there any way to ida pro/make a patcher to find relevant code segments, and replace/patch the bytes to MOV EAX NOP directly? (Assuming there's anther new version which changes it)

29988122 avatar Feb 05 '23 09:02 29988122

I think this patching method is very useful, rather than waiting for nvidia to add this option and fix. Thanks!

I wonder, is there any way to ida pro/make a patcher to find relevant code segments, and replace/patch the bytes to MOV EAX NOP directly? (Assuming there's anther new version which changes it)

Probably can look into Zydis disassembler to find specific structure offsets at runtime to target the subroutines that calls the mouse sensitivity WinAPI functions. This should be more stable than machine code. The injection method would be by hijacking one of the commonly WinAPI loaded libraries, placing the DLL in the same folder as nvstreamer.exe or nvcontainer.exe. The DLL would then proxy the original functions in that library while searching for the code signature and injecting the NOPs.

Don't think nvidia will be "fixing" this. It's sort of a feature, not a bug, because mouse acceleration can help somewhat at high resolutions so moving the mouse doesn't require as much swipes. Only possibility would be to add an option to disable the toggling of mouse acceleration, but it would look clunky and obtuse in GFE. But even that possibility is close to none now, considering that nvidia is going to stop maintaining gamestream, so sooner or later the feature might even be taken off GFE, like what happened to 3dvision.

predprey2 avatar Feb 05 '23 10:02 predprey2

Thank you, predprey2, for the very extensive reply! I think your thoughts of suggesting me to tackle via "different layers than machine code" is very inspiring to me. It's a very learning-worthy instruction, and I can't thank you more about it! : DDD

On the other hand, it's sad to see nvidia soon dropping support to gamestream. It's a very useful way to wireless stream desktop to TVs with Android, and with higher quality than steamlink.

Hope that we'll have a brighter future to Sunshine, and kudos to the moonlight team for it - it's not easy feat.

29988122 avatar Feb 10 '23 07:02 29988122

GeForce Experience 3.26.0.131, nvstreamer.exe 7.1.3164.8965. Replace the bytes "FF 15 1A DE 1A 00" with "B8 01 00 00 00 90"

Not avalible in GeForce Experience 3.27.0.112, nvstreamer.exe 7.1.3219.3813

Autliety avatar Feb 13 '23 10:02 Autliety

It stop working when I update yesterday

Michael7711 avatar Feb 16 '23 19:02 Michael7711

I've disabled updates by blocking them in the hosts file. This seems like a reasonable solution where updates will be disabling the function of Moonlight altogether soon anyway. Until Sunshine is improved...

On Thu, Feb 16, 2023, 12:00 PM Michael7711 @.***> wrote:

It stop working when I update yesterday

— Reply to this email directly, view it on GitHub https://github.com/moonlight-stream/moonlight-qt/issues/128#issuecomment-1433573983, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGVZZK2YUFKBHN55JFZPGTWXZ2MBANCNFSM4GCIBIIQ . You are receiving this because you commented.Message ID: @.***>

sivan-koren avatar Feb 16 '23 19:02 sivan-koren