Skip to content

Commit

Permalink
display(iOS): configurable cursor speed multiplier
Browse files Browse the repository at this point in the history
Resolves #2522
  • Loading branch information
osy committed Feb 26, 2022
1 parent 30c4bef commit 13e06e4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Platform/iOS/Display/VMCursor.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#import "VMDisplayMetalViewController+Touch.h"
#import "CSDisplayMetal.h"

@interface VMCursor ()

@property (nonatomic, readonly) CGFloat cursorSpeedMultiplier;

@end

@implementation VMCursor {
CGPoint _start;
CGPoint _lastCenter;
Expand All @@ -30,6 +36,17 @@ @implementation VMCursor {

@synthesize transform;


- (CGFloat)cursorSpeedMultiplier {
NSInteger multiplier = [[NSUserDefaults standardUserDefaults] integerForKey:@"DragCursorSpeed"];
CGFloat fraction = multiplier / 100.0f;
if (fraction > 0) {
return fraction;
} else {
return 1.0f;
}
}

- (id)init {
if (self = [super init]) {
self.bounds = CGRectMake(0, 0, 1, 1);
Expand Down Expand Up @@ -58,7 +75,8 @@ - (CGPoint)center {

- (void)setCenter:(CGPoint)center {
if (_controller.serverModeCursor) {
CGPoint diff = CGPointMake(center.x - _lastCenter.x, center.y - _lastCenter.y);
CGPoint diff = CGPointMake((center.x - _lastCenter.x) * self.cursorSpeedMultiplier,
(center.y - _lastCenter.y) * self.cursorSpeedMultiplier);
[_controller moveMouseRelative:diff];
} else {
[_controller moveMouseAbsolute:center];
Expand Down
18 changes: 18 additions & 0 deletions Platform/iOS/Settings.bundle/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,24 @@
<integer>2</integer>
</array>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Cursor - Drag Speed</string>
</dict>
<dict>
<key>Type</key>
<string>PSSliderSpecifier</string>
<key>Key</key>
<string>DragCursorSpeed</string>
<key>DefaultValue</key>
<integer>100</integer>
<key>MinimumValue</key>
<integer>1</integer>
<key>MaximumValue</key>
<integer>100</integer>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
Expand Down

0 comments on commit 13e06e4

Please sign in to comment.