Add menu entries for pointer velocity tweak
This commit is contained in:
1 parent
6c5cd094c3
commit
427873116b
12 files changed
+189
-77
No files matched your search
@@ -17,11 +17,13 @@
|
||||
framerate:(NSInteger)framerate
|
||||
height:(NSInteger)height
|
||||
width:(NSInteger)width
|
||||
audioConfig:(NSInteger)audioConfig
|
||||
audioConfig:(NSInteger)audioConfig
|
||||
onscreenControls:(NSInteger)onscreenControls
|
||||
keyboardToggleFingers:(NSInteger)keyboardToggleFingers
|
||||
swipeExitScreenEdge:(NSInteger)swipeExitScreenEdge
|
||||
swipeToExitDistance:(CGFloat)swipeToExitDistance
|
||||
pointerVelocityModeDivider:(CGFloat)pointerVelocityModeDivider
|
||||
touchPointerVelocityFactor:(CGFloat)touchPointerVelocityFactor
|
||||
liftStreamViewForKeyboard:(BOOL)liftStreamViewForKeyboard
|
||||
showKeyboardToolbar:(BOOL)showKeyboardToolbar
|
||||
optimizeGames:(BOOL)optimizeGames
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
keyboardToggleFingers:(NSInteger)keyboardToggleFingers
|
||||
swipeExitScreenEdge:(NSInteger)swipeExitScreenEdge
|
||||
swipeToExitDistance:(CGFloat)swipeToExitDistance
|
||||
pointerVelocityModeDivider:(CGFloat)pointerVelocityModeDivider
|
||||
touchPointerVelocityFactor:(CGFloat)touchPointerVelocityFactor
|
||||
liftStreamViewForKeyboard:(BOOL)liftStreamViewForKeyboard
|
||||
showKeyboardToolbar:(BOOL)showKeyboardToolbar
|
||||
optimizeGames:(BOOL)optimizeGames
|
||||
@@ -85,6 +87,8 @@
|
||||
settingsToSave.keyboardToggleFingers = [NSNumber numberWithInteger:(uint16_t)keyboardToggleFingers];
|
||||
settingsToSave.swipeExitScreenEdge = [NSNumber numberWithInteger:(uint32_t)swipeExitScreenEdge];
|
||||
settingsToSave.swipeToExitDistance = [NSNumber numberWithFloat:swipeToExitDistance];
|
||||
settingsToSave.pointerVelocityModeDivider = [NSNumber numberWithFloat:pointerVelocityModeDivider];
|
||||
settingsToSave.touchPointerVelocityFactor = [NSNumber numberWithFloat:touchPointerVelocityFactor];
|
||||
settingsToSave.liftStreamViewForKeyboard = liftStreamViewForKeyboard;
|
||||
settingsToSave.showKeyboardToolbar = showKeyboardToolbar;
|
||||
settingsToSave.optimizeGames = optimizeGames;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
@property (nonatomic, retain) NSNumber * keyboardToggleFingers;
|
||||
@property (nonatomic, retain) NSNumber * swipeExitScreenEdge;
|
||||
@property (nonatomic, retain) NSNumber * swipeToExitDistance;
|
||||
@property (nonatomic, retain) NSNumber * touchPointerVelocityFactor;
|
||||
@property (nonatomic, retain) NSNumber * pointerVelocityModeDivider;
|
||||
@property (nonatomic, retain) NSString * uniqueId;
|
||||
@property (nonatomic) enum {
|
||||
CODEC_PREF_AUTO,
|
||||
|
||||
@@ -90,6 +90,8 @@
|
||||
self.swipeToExitDistance = settings.swipeToExitDistance;
|
||||
self.liftStreamViewForKeyboard = settings.liftStreamViewForKeyboard;
|
||||
self.showKeyboardToolbar = settings.showKeyboardToolbar;
|
||||
self.touchPointerVelocityFactor = settings.touchPointerVelocityFactor;
|
||||
self.pointerVelocityModeDivider = settings.pointerVelocityModeDivider;
|
||||
#endif
|
||||
self.uniqueId = settings.uniqueId;
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (void)populatePointerId:(UITouch*)touch;
|
||||
+ (void)removePointerId:(UITouch*)touch;
|
||||
+ (uint32_t) retrievePointerIdFromDict:(UITouch*)touch;
|
||||
|
||||
+ (void)setPointerVelocityDivider:(CGFloat)dividerLocation;
|
||||
+ (void)setPointerVelocityFactor:(CGFloat)velocityFactor;
|
||||
+ (void)populatePointerObjIntoDict:(UITouch*)touch;
|
||||
+ (void)removePointerObjFromDict:(UITouch*)touch;
|
||||
+ (void)updatePointerObjInDict:(UITouch *)touch;
|
||||
|
||||
@@ -34,6 +34,15 @@ StreamView *streamView;
|
||||
CGFloat velocityY;
|
||||
}
|
||||
|
||||
+ (void)setPointerVelocityDivider:(CGFloat)dividerLocation{
|
||||
pointerVelocityDivider = dividerLocation;
|
||||
}
|
||||
|
||||
+ (void)setPointerVelocityFactor:(CGFloat)velocityFactor{
|
||||
pointerVelocityFactor = velocityFactor;
|
||||
}
|
||||
|
||||
|
||||
- (instancetype)initWith:(UITouch *)touch{
|
||||
self = [self init];
|
||||
self->initialPoint = [touch locationInView:streamView];
|
||||
@@ -59,7 +68,7 @@ StreamView *streamView;
|
||||
pointerIdDict = [NSMutableDictionary dictionary];
|
||||
pointerIdSet = [NSMutableSet set];
|
||||
pointerDict = [NSMutableDictionary dictionary];
|
||||
pointerVelocityDividerLocation = CGRectGetHeight([[UIScreen mainScreen] bounds]) *pointerVelocityDivider;
|
||||
pointerVelocityDividerLocation = CGRectGetHeight([[UIScreen mainScreen] bounds]) * pointerVelocityDivider;
|
||||
}
|
||||
|
||||
+ (void)populatePointerObjIntoDict:(UITouch*)touch{
|
||||
@@ -81,11 +90,9 @@ StreamView *streamView;
|
||||
|
||||
|
||||
+ (CGPoint)selectCoordsFor:(UITouch *)touch{
|
||||
if (pointerVelocityFactor != 1.0f){
|
||||
TouchPointer *pointer = [pointerDict objectForKey:@((uint64_t)touch)];
|
||||
if((pointer -> initialPoint).x > pointerVelocityDividerLocation){
|
||||
return pointer->latestRelativePoint;
|
||||
}
|
||||
TouchPointer *pointer = [pointerDict objectForKey:@((uint64_t)touch)];
|
||||
if((pointer -> initialPoint).x > pointerVelocityDividerLocation){ //if first contact coords locates on the right side of divider.
|
||||
return pointer->latestRelativePoint;
|
||||
}
|
||||
return [touch locationInView:streamView];
|
||||
}
|
||||
|
||||
@@ -57,12 +57,14 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
||||
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
||||
config:(StreamConfiguration*)streamConfig {
|
||||
[TouchPointer initContextWith:self];
|
||||
|
||||
self->interactionDelegate = interactionDelegate;
|
||||
self->streamAspectRatio = (float)streamConfig.width / (float)streamConfig.height;
|
||||
|
||||
settings = [[[DataManager alloc] init] getSettings];
|
||||
[TouchPointer initContextWith:self];
|
||||
[TouchPointer setPointerVelocityDivider:settings.pointerVelocityModeDivider.floatValue];
|
||||
[TouchPointer setPointerVelocityFactor:settings.touchPointerVelocityFactor.floatValue];
|
||||
|
||||
keysDown = [[NSMutableSet alloc] init];
|
||||
keyInputField = [[KeyboardInputField alloc] initWithFrame:CGRectZero];
|
||||
@@ -333,7 +335,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
|
||||
- (void)sendTouchEvent:(UITouch*)event touchType:(uint8_t)touchType{
|
||||
CGPoint targetCoords;
|
||||
if(true) targetCoords = [TouchPointer selectCoordsFor:event];
|
||||
if(settings.pointerVelocityModeDivider.floatValue != 1.0) targetCoords = [TouchPointer selectCoordsFor:event]; // coordinates of touch pointer replaced to relative ones here.
|
||||
else targetCoords = [event locationInView:self];
|
||||
CGPoint location = [self adjustCoordinatesForVideoArea:targetCoords];
|
||||
CGSize videoSize = [self getVideoAreaSize];
|
||||
@@ -343,6 +345,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
|
||||
- (void)handleUITouch:(UITouch*)event index:(int)index{
|
||||
uint8_t type;
|
||||
BOOL pointerVelocityScaleEnabled = (settings.pointerVelocityModeDivider.floatValue != 1.0); // when the divider is 1.0, means 0% of screen shall pass velocity-scaled pointer to sunshine.
|
||||
|
||||
// NSLog(@"handleUITouch %ld,%d",(long)event.phase,(uint32_t)event);
|
||||
//#define LI_TOUCH_EVENT_HOVER 0x00
|
||||
//#define LI_TOUCH_EVENT_DOWN 0x01
|
||||
@@ -368,12 +372,12 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
case UITouchPhaseBegan://开始触摸
|
||||
type = LI_TOUCH_EVENT_DOWN;
|
||||
[TouchPointer populatePointerId:event]; //获取并记录pointerId
|
||||
if(true) [TouchPointer populatePointerObjIntoDict:event];
|
||||
if(pointerVelocityScaleEnabled) [TouchPointer populatePointerObjIntoDict:event];
|
||||
break;
|
||||
case UITouchPhaseMoved://移动
|
||||
case UITouchPhaseStationary:
|
||||
type = LI_TOUCH_EVENT_MOVE;
|
||||
if(true) [TouchPointer updatePointerObjInDict:event];
|
||||
if(pointerVelocityScaleEnabled) [TouchPointer updatePointerObjInDict:event];
|
||||
break;
|
||||
case UITouchPhaseRegionEntered://停留
|
||||
case UITouchPhaseRegionMoved://停留
|
||||
@@ -383,13 +387,13 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
type = LI_TOUCH_EVENT_CANCEL;
|
||||
[self sendTouchEvent:event touchType:type]; //先发送,再删除
|
||||
[TouchPointer removePointerId:event]; //删除pointerId
|
||||
if(true) [TouchPointer removePointerObjFromDict:event];
|
||||
if(pointerVelocityScaleEnabled) [TouchPointer removePointerObjFromDict:event];
|
||||
return;
|
||||
case UITouchPhaseEnded://触摸结束
|
||||
type = LI_TOUCH_EVENT_UP;
|
||||
[self sendTouchEvent:event touchType:type]; //先发送,再删除
|
||||
[TouchPointer removePointerId:event]; //删除pointerId
|
||||
if(true) [TouchPointer removePointerObjFromDict:event];
|
||||
if(pointerVelocityScaleEnabled) [TouchPointer removePointerObjFromDict:event];
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -35,14 +35,16 @@
|
||||
<attribute name="onscreenControls" attributeType="Integer 32" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="optimizeGames" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="playAudioOnPC" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="pointerVelocityModeDivider" optional="YES" attributeType="Float" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="preferredCodec" attributeType="Integer 32" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="showKeyboardToolbar" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="statsOverlay" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="swapABXYButtons" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="swipeExitScreenEdge" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="swipeToExitDistance" optional="YES" attributeType="Float" defaultValueString="0.5" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="touchPointerVelocityFactor" optional="YES" attributeType="Float" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="uniqueId" attributeType="String" syncable="YES"/>
|
||||
<attribute name="useFramePacing" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="useFramePacing" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="width" attributeType="Integer 32" defaultValueString="1280" usesScalarValueType="NO" syncable="YES"/>
|
||||
</entity>
|
||||
</model>
|
||||
@@ -34,6 +34,12 @@
|
||||
@property (strong, nonatomic) IBOutlet UISegmentedControl *swipeExitScreenEdgeSelector;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *swipeToExitDistanceUILabel;
|
||||
@property (strong, nonatomic) IBOutlet UISlider *swipeToExitDistanceSlider;
|
||||
@property (strong, nonatomic) IBOutlet UISlider *pointerVelocityModeDividerSlider;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *pointerVelocityModeDividerUILabel;
|
||||
@property (strong, nonatomic) IBOutlet UISlider *touchPointerVelocityFactorSlider;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *touchPointerVelocityFactorUILabel;
|
||||
|
||||
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
|
||||
@@ -275,6 +275,22 @@ BOOL isCustomResolution(CGSize res) {
|
||||
[self.swipeToExitDistanceSlider setValue:(CGFloat)currentSettings.swipeToExitDistance.floatValue animated:YES]; // Load old setting.
|
||||
[self.swipeToExitDistanceUILabel setText:[NSString stringWithFormat:@"Swipe & Exit Distance: %.2f * screen-width", self.swipeToExitDistanceSlider.value]]; // Initiate label display
|
||||
[self.swipeToExitDistanceSlider addTarget:self action:@selector(swipeToExitDistanceSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved.
|
||||
|
||||
[self.pointerVelocityModeDividerSlider setValue:currentSettings.pointerVelocityModeDivider.floatValue * 100 animated:YES]; // Load old setting.
|
||||
[self.pointerVelocityModeDividerUILabel setText:[NSString stringWithFormat:@"Touch Pointer Velocity: Scaled on %d%% of Right Screen", 100 - (uint8_t)self.pointerVelocityModeDividerSlider.value]]; // Initiate label display
|
||||
[self.pointerVelocityModeDividerSlider addTarget:self action:@selector(pointerVelocityModeDividerSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved.
|
||||
|
||||
[self.touchPointerVelocityFactorSlider setValue:currentSettings.touchPointerVelocityFactor.floatValue * 100 animated:YES]; // Load old setting.
|
||||
[self.touchPointerVelocityFactorUILabel setText:[NSString stringWithFormat:@"Touch Pointer Velocity Factor: %d%%", (uint16_t)self.touchPointerVelocityFactorSlider.value]]; // Initiate label display
|
||||
[self.touchPointerVelocityFactorSlider addTarget:self action:@selector(touchPointerVelocityFactorSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved.
|
||||
}
|
||||
|
||||
- (void) pointerVelocityModeDividerSliderMoved {
|
||||
[self.pointerVelocityModeDividerUILabel setText:[NSString stringWithFormat:@"Touch Pointer Velocity: Scaled on %d%% of Right Screen", 100 - (uint8_t)self.pointerVelocityModeDividerSlider.value]];
|
||||
}
|
||||
|
||||
- (void) touchPointerVelocityFactorSliderMoved {
|
||||
[self.touchPointerVelocityFactorUILabel setText:[NSString stringWithFormat:@"Touch Pointer Velocity Factor: %d%%", (uint16_t)self.touchPointerVelocityFactorSlider.value]]; // Initiate label display
|
||||
}
|
||||
|
||||
- (uint32_t) getScreenEdgeFromSelector {
|
||||
@@ -300,6 +316,8 @@ BOOL isCustomResolution(CGSize res) {
|
||||
- (void) touchModeChanged {
|
||||
// Disable on-screen controls in absolute touch mode
|
||||
[self.onscreenControlSelector setEnabled:[self.touchModeSelector selectedSegmentIndex] == 0];
|
||||
[self.pointerVelocityModeDividerSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == 1]; // pointer velocity scaling works only in native touch mode.
|
||||
[self.touchPointerVelocityFactorSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == 1]; // pointer velocity scaling works only in native touch mode.
|
||||
}
|
||||
|
||||
- (void) updateBitrate {
|
||||
@@ -573,6 +591,8 @@ BOOL isCustomResolution(CGSize res) {
|
||||
// NSLog(@"saveSettings keyboardToggleFingers %d", (uint16_t)keyboardToggleFingers);
|
||||
CGFloat swipeToExitDistance = self.swipeToExitDistanceSlider.value;
|
||||
uint32_t swipeExitScreenEdge = [self getScreenEdgeFromSelector];
|
||||
CGFloat pointerVelocityModeDivider = (CGFloat)(uint8_t)self.pointerVelocityModeDividerSlider.value/100;
|
||||
CGFloat touchPointerVelocityFactor =(CGFloat)(uint16_t)self.touchPointerVelocityFactorSlider.value/100;
|
||||
BOOL liftStreamViewForKeyboard = [self.liftStreamViewForKeyboardSelector selectedSegmentIndex] == 1;
|
||||
BOOL showKeyboardToolbar = [self.showKeyboardToolbarSelector selectedSegmentIndex] == 1;
|
||||
BOOL optimizeGames = [self.optimizeSettingsSelector selectedSegmentIndex] == 1;
|
||||
@@ -594,6 +614,8 @@ BOOL isCustomResolution(CGSize res) {
|
||||
keyboardToggleFingers:keyboardToggleFingers
|
||||
swipeExitScreenEdge:swipeExitScreenEdge
|
||||
swipeToExitDistance:swipeToExitDistance
|
||||
pointerVelocityModeDivider:pointerVelocityModeDivider
|
||||
touchPointerVelocityFactor:touchPointerVelocityFactor
|
||||
liftStreamViewForKeyboard:liftStreamViewForKeyboard
|
||||
showKeyboardToolbar:showKeyboardToolbar
|
||||
optimizeGames:optimizeGames
|
||||
|
||||
Reference in new issue
Block a user