minor change
This commit is contained in:
1 parent
e7fd911fb8
commit
b85a1e9c07
2 files changed
+11
-12
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
// NativeTouchHandler.m
|
// NativeTouchHandler.m
|
||||||
// Moonlight
|
// Moonlight
|
||||||
//
|
//
|
||||||
// Created by Admin on 2024/6/16.
|
// Created by ZWM on 2024/6/16.
|
||||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
@@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
@implementation NativeTouchHandler {
|
@implementation NativeTouchHandler {
|
||||||
StreamView* streamView;
|
StreamView* streamView;
|
||||||
bool activateCoordSelector;
|
TemporarySettings* currentSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (id)initWith:(StreamView*)view and:(TemporarySettings*)settings{
|
- (id)initWith:(StreamView*)view and:(TemporarySettings*)settings{
|
||||||
self = [self init];
|
self = [self init];
|
||||||
self->streamView = view;
|
self->streamView = view;
|
||||||
activateCoordSelector = (settings.pointerVelocityModeDivider.floatValue != 1.0);
|
self->currentSettings = settings;
|
||||||
[NativeTouchPointer setPointerVelocityDivider:settings.pointerVelocityModeDivider.floatValue];
|
[NativeTouchPointer setPointerVelocityDivider:settings.pointerVelocityModeDivider.floatValue];
|
||||||
[NativeTouchPointer setPointerVelocityFactor:settings.touchPointerVelocityFactor.floatValue];
|
[NativeTouchPointer setPointerVelocityFactor:settings.touchPointerVelocityFactor.floatValue];
|
||||||
[NativeTouchPointer initContextWith:streamView];
|
[NativeTouchPointer initContextWith:streamView];
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
- (void)sendTouchEvent:(UITouch*)event touchType:(uint8_t)touchType{
|
- (void)sendTouchEvent:(UITouch*)event touchType:(uint8_t)touchType{
|
||||||
CGPoint targetCoords;
|
CGPoint targetCoords;
|
||||||
if(activateCoordSelector && event.phase == UITouchPhaseMoved) targetCoords = [NativeTouchPointer selectCoordsFor:event]; // coordinates of touch pointer replaced to relative ones here.
|
if(currentSettings.pointerVelocityModeDivider.floatValue != 1.0 && event.phase == UITouchPhaseMoved) targetCoords = [NativeTouchPointer selectCoordsFor:event]; // coordinates of touch pointer replaced to relative ones here.
|
||||||
else targetCoords = [event locationInView:streamView];
|
else targetCoords = [event locationInView:streamView];
|
||||||
CGPoint location = [streamView adjustCoordinatesForVideoArea:targetCoords];
|
CGPoint location = [streamView adjustCoordinatesForVideoArea:targetCoords];
|
||||||
CGSize videoSize = [streamView getVideoAreaSize];
|
CGSize videoSize = [streamView getVideoAreaSize];
|
||||||
@@ -83,24 +83,24 @@
|
|||||||
case UITouchPhaseBegan://开始触摸
|
case UITouchPhaseBegan://开始触摸
|
||||||
type = LI_TOUCH_EVENT_DOWN;
|
type = LI_TOUCH_EVENT_DOWN;
|
||||||
[NativeTouchPointer populatePointerId:event]; //获取并记录pointerId
|
[NativeTouchPointer populatePointerId:event]; //获取并记录pointerId
|
||||||
if(activateCoordSelector) [NativeTouchPointer populatePointerObjIntoDict:event];
|
if(currentSettings.pointerVelocityModeDivider.floatValue != 1.0) [NativeTouchPointer populatePointerObjIntoDict:event];
|
||||||
break;
|
break;
|
||||||
case UITouchPhaseMoved://移动
|
case UITouchPhaseMoved://移动
|
||||||
case UITouchPhaseStationary:
|
case UITouchPhaseStationary:
|
||||||
type = LI_TOUCH_EVENT_MOVE;
|
type = LI_TOUCH_EVENT_MOVE;
|
||||||
if(activateCoordSelector) [NativeTouchPointer updatePointerObjInDict:event];
|
if(currentSettings.pointerVelocityModeDivider.floatValue != 1.0) [NativeTouchPointer updatePointerObjInDict:event];
|
||||||
break;
|
break;
|
||||||
case UITouchPhaseEnded://触摸结束
|
case UITouchPhaseEnded://触摸结束
|
||||||
type = LI_TOUCH_EVENT_UP;
|
type = LI_TOUCH_EVENT_UP;
|
||||||
[self sendTouchEvent:event touchType:type]; //先发送,再删除
|
[self sendTouchEvent:event touchType:type]; //先发送,再删除
|
||||||
[NativeTouchPointer removePointerId:event]; //删除pointerId
|
[NativeTouchPointer removePointerId:event]; //删除pointerId
|
||||||
if(activateCoordSelector) [NativeTouchPointer removePointerObjFromDict:event];
|
if(currentSettings.pointerVelocityModeDivider.floatValue != 1.0) [NativeTouchPointer removePointerObjFromDict:event];
|
||||||
return;
|
return;
|
||||||
case UITouchPhaseCancelled://触摸取消
|
case UITouchPhaseCancelled://触摸取消
|
||||||
type = LI_TOUCH_EVENT_CANCEL;
|
type = LI_TOUCH_EVENT_CANCEL;
|
||||||
[self sendTouchEvent:event touchType:type]; //先发送,再删除
|
[self sendTouchEvent:event touchType:type]; //先发送,再删除
|
||||||
[NativeTouchPointer removePointerId:event]; //删除pointerId
|
[NativeTouchPointer removePointerId:event]; //删除pointerId
|
||||||
if(activateCoordSelector) [NativeTouchPointer removePointerObjFromDict:event];
|
if(currentSettings.pointerVelocityModeDivider.floatValue != 1.0) [NativeTouchPointer removePointerObjFromDict:event];
|
||||||
return;
|
return;
|
||||||
case UITouchPhaseRegionEntered://停留
|
case UITouchPhaseRegionEntered://停留
|
||||||
case UITouchPhaseRegionMoved://停留
|
case UITouchPhaseRegionMoved://停留
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
[self.framerateSelector setSelectedSegmentIndex:framerate];
|
[self.framerateSelector setSelectedSegmentIndex:framerate];
|
||||||
[self.framerateSelector addTarget:self action:@selector(updateBitrate) forControlEvents:UIControlEventValueChanged];
|
[self.framerateSelector addTarget:self action:@selector(updateBitrate) forControlEvents:UIControlEventValueChanged];
|
||||||
[self.onscreenControlSelector setSelectedSegmentIndex:onscreenControls];
|
[self.onscreenControlSelector setSelectedSegmentIndex:onscreenControls];
|
||||||
[self.onscreenControlSelector setEnabled:[self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH_MODE];//initialize controller UI widget
|
[self.onscreenControlSelector setEnabled: currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE];//enable/disable controller UI widget for the first time.
|
||||||
[self.bitrateSlider setMinimumValue:0];
|
[self.bitrateSlider setMinimumValue:0];
|
||||||
[self.bitrateSlider setMaximumValue:(sizeof(bitrateTable) / sizeof(*bitrateTable)) - 1];
|
[self.bitrateSlider setMaximumValue:(sizeof(bitrateTable) / sizeof(*bitrateTable)) - 1];
|
||||||
[self.bitrateSlider setValue:[self getSliderValueForBitrate:_bitrate] animated:YES];
|
[self.bitrateSlider setValue:[self getSliderValueForBitrate:_bitrate] animated:YES];
|
||||||
@@ -303,13 +303,12 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
[self.pointerVelocityModeDividerSlider setValue:currentSettings.pointerVelocityModeDivider.floatValue * 100 animated:YES]; // Load old setting.
|
[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.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.pointerVelocityModeDividerSlider addTarget:self action:@selector(pointerVelocityModeDividerSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved.
|
||||||
[self.pointerVelocityModeDividerSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode.
|
[self.pointerVelocityModeDividerSlider setEnabled: currentSettings.touchMode.intValue == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode.
|
||||||
|
|
||||||
[self.touchPointerVelocityFactorSlider setValue:currentSettings.touchPointerVelocityFactor.floatValue * 100 animated:YES]; // Load old setting.
|
[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.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.
|
[self.touchPointerVelocityFactorSlider addTarget:self action:@selector(touchPointerVelocityFactorSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved.
|
||||||
[self.touchPointerVelocityFactorSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode.
|
[self.touchPointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) pointerVelocityModeDividerSliderMoved {
|
- (void) pointerVelocityModeDividerSliderMoved {
|
||||||
|
|||||||
Reference in new issue
Block a user