moonlight-stream / moonlight-ios

GameStream client for iOS/tvOS
GNU General Public License v3.0
1.04k stars 261 forks source link

Add support for changing the sensitivity of relative mouse mode #563

Open Nnubes256 opened 1 year ago

Nnubes256 commented 1 year ago

Fixes #42.

This PR introduces support on the iOS and tvOS apps for changing the mouse sensitivity within relative mouse ("Touchpad") mode. It does this by multiplying the delta movement sent to the host by a fixed factor which can be configured by the user in Settings.

On iOS, the setting provided is a slider with non-lineal behavior. While it has a multiplier range of 0.0 to 6.0, the default value of 1.0 stays in the middle; thus, the left side comprehends a range of [0.0, 1.0) and the right side uses a different range of [1.0, 6.0]. The option of having 0x sensibility is explicitely provided in order to unlock usecases in which locking the mouse cursor in a fixed place is desired.

In addition to that, the slider has a soft detent on the default 1.0x setting, which allows to quickly reset the setting to a default state. This is accompanied by haptic feedback for better UX.

On tvOS, due to the lack of a slider control support in Settings.bundle, a multi-input is provided instead that roughly covers the iOS's slider range.

A Core Data migration and accompanying glue code is provided for persisting the setting change.

Screenshots

iOS

New setting (default value) ![TouchpadSensibility_iOS_Default](https://github.com/moonlight-stream/moonlight-ios/assets/4301869/b989d412-ca71-41da-b88b-531803e54636)
New setting (changed value) ![TouchpadSensibility_iOS_Changed](https://github.com/moonlight-stream/moonlight-ios/assets/4301869/c0f866e8-72ca-4cd5-b396-34020f4dad8e)

tvOS

New setting (default value) ![TouchpadSensibility_tvOS_SettingsItem](https://github.com/moonlight-stream/moonlight-ios/assets/4301869/237b2387-771f-4688-84b4-b77d3699fd5c)
Available options ![TouchpadSensibility_tvOS_SettingsItemOptions_1](https://github.com/moonlight-stream/moonlight-ios/assets/4301869/273f7cd1-7122-4c4e-a67a-1fa02453c503) ![TouchpadSensibility_tvOS_SettingsItemOptions_2](https://github.com/moonlight-stream/moonlight-ios/assets/4301869/1f9e4605-6451-4f62-aacf-8022513be3c7)
whitingj commented 2 months ago

This is awesome work and just what I was looking for. Using trackpad mode on an iPad is not a pleasant experience. The mouse moves way too slow.

@cgutman Sorry to ping you but is there any chance you could review this PR and merge?

I took a look at the code and the changes to RelativeTouchHandler.m are minimal and exactly what I would expect, which is basically deltaX * sensitivityMultiplier. All the other changes are just to update the UI with the setting and storing that setting in the data model. IMO the code looks good.