make on-screen buttons available for absolute touch
This commit is contained in:
1 parent
0a47becdc6
commit
f5c03f8045
4 files changed
+36
-23
No files matched your search
@@ -26,7 +26,9 @@
|
|||||||
|
|
||||||
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
||||||
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
||||||
config:(StreamConfiguration*)streamConfig;
|
config:(StreamConfiguration*)streamConfig
|
||||||
|
streamFrameTopLayerView:(UIView* )topLayerView
|
||||||
|
;
|
||||||
- (void) showOnScreenControls;
|
- (void) showOnScreenControls;
|
||||||
- (void) setOnScreenControls;
|
- (void) setOnScreenControls;
|
||||||
- (void) disableOnScreenControls;
|
- (void) disableOnScreenControls;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||||
|
|
||||||
@implementation StreamView {
|
@implementation StreamView {
|
||||||
|
UIView* streamFrameTopLayerView;
|
||||||
TemporarySettings* settings;
|
TemporarySettings* settings;
|
||||||
|
|
||||||
OnScreenControls* onScreenControls;
|
OnScreenControls* onScreenControls;
|
||||||
@@ -65,9 +66,10 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
|
|
||||||
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
||||||
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
|
||||||
config:(StreamConfiguration*)streamConfig {
|
config:(StreamConfiguration*)streamConfig
|
||||||
|
streamFrameTopLayerView:(UIView* )topLayerView{
|
||||||
|
|
||||||
|
self->streamFrameTopLayerView = topLayerView;
|
||||||
self->interactionDelegate = interactionDelegate;
|
self->interactionDelegate = interactionDelegate;
|
||||||
self->streamAspectRatio = (float)streamConfig.width / (float)streamConfig.height;
|
self->streamAspectRatio = (float)streamConfig.width / (float)streamConfig.height;
|
||||||
|
|
||||||
@@ -96,8 +98,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
selector:@selector(keyboardWillHide:)
|
selector:@selector(keyboardWillHide:)
|
||||||
name:UIKeyboardWillHideNotification
|
name:UIKeyboardWillHideNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
if(settings.touchMode.intValue == PURE_NATIVE_TOUCH) [self addGestureRecognizer:keyboardToggleRecognizer]; //keep legacy approach in pure native mode
|
if(settings.touchMode.intValue == PURE_NATIVE_TOUCH) [self addGestureRecognizer:keyboardToggleRecognizer]; //keep legacy approach in pure native mode
|
||||||
else [self.superview addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes
|
else [self->streamFrameTopLayerView addGestureRecognizer:keyboardToggleRecognizer]; //add to the superview in other modes
|
||||||
|
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
@@ -315,10 +317,16 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we'll enable on screen buttons, and disable on screen controllers for absolute touch
|
||||||
- (bool) isOscEnabled{
|
- (bool) isOscEnabled{
|
||||||
return (settings.touchMode.intValue == RELATIVE_TOUCH || settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && settings.onscreenControls.intValue != OnScreenControlsLevelOff;
|
return (settings.touchMode.intValue == RELATIVE_TOUCH || settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && settings.onscreenControls.intValue != OnScreenControlsLevelOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we'll enable on screen buttons, and disable on screen controllers for absolute touch
|
||||||
|
- (bool) isOnScreenButtonEnabled{
|
||||||
|
return (settings.touchMode.intValue == RELATIVE_TOUCH || settings.touchMode.intValue == REGULAR_NATIVE_TOUCH || settings.touchMode.intValue == ABSOLUTE_TOUCH) && settings.onscreenControls.intValue == OnScreenControlsLevelCustom;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) reloadOnScreenControlsRealtimeWith:(ControllerSupport*)controllerSupport
|
- (void) reloadOnScreenControlsRealtimeWith:(ControllerSupport*)controllerSupport
|
||||||
andConfig:(StreamConfiguration*)streamConfig {
|
andConfig:(StreamConfiguration*)streamConfig {
|
||||||
[self reloadOnScreenControlsWith:controllerSupport andConfig:streamConfig];
|
[self reloadOnScreenControlsWith:controllerSupport andConfig:streamConfig];
|
||||||
@@ -337,12 +345,12 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
RelativeTouchHandler* relativeTouchHandler = (RelativeTouchHandler *)touchHandler;
|
RelativeTouchHandler* relativeTouchHandler = (RelativeTouchHandler *)touchHandler;
|
||||||
onScreenControls.mouseRightClickTapRecognizer = relativeTouchHandler.mouseRightClickTapRecognizer;
|
onScreenControls.mouseRightClickTapRecognizer = relativeTouchHandler.mouseRightClickTapRecognizer;
|
||||||
} */
|
} */
|
||||||
[onScreenControls setLevel:(OnScreenControlsLevel)settings.onscreenControls.intValue];
|
if([self isOscEnabled]) [onScreenControls setLevel:(OnScreenControlsLevel)settings.onscreenControls.intValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) clearOnScreenKeyboardButtons{
|
- (void) clearOnScreenKeyboardButtons{
|
||||||
for (UIView *subview in self.superview.subviews) {
|
for (UIView *subview in self->streamFrameTopLayerView.subviews) {
|
||||||
// 检查子视图是否是特定类型的实例
|
// 检查子视图是否是特定类型的实例
|
||||||
if ([subview isKindOfClass:[OnScreenButtonView class]]) {
|
if ([subview isKindOfClass:[OnScreenButtonView class]]) {
|
||||||
// 如果是,就添加到将要被移除的数组中
|
// 如果是,就添加到将要被移除的数组中
|
||||||
@@ -358,9 +366,9 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
// remove all keyboard button views first
|
// remove all keyboard button views first
|
||||||
[self clearOnScreenKeyboardButtons];
|
[self clearOnScreenKeyboardButtons];
|
||||||
|
|
||||||
bool customOscEnabled = (settings.touchMode.intValue == RELATIVE_TOUCH || settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && settings.onscreenControls.intValue == OnScreenControlsLevelCustom;
|
// bool customOscEnabled = [self isOscEnabled] && settings.onscreenControls.intValue == OnScreenControlsLevelCustom;
|
||||||
|
|
||||||
if(!customOscEnabled) return; //returns if we're not in custom osc mode
|
if(![self isOnScreenButtonEnabled]) return;
|
||||||
|
|
||||||
OSCProfilesManager* profilesManager = [OSCProfilesManager sharedManager];
|
OSCProfilesManager* profilesManager = [OSCProfilesManager sharedManager];
|
||||||
OSCProfile *oscProfile = [profilesManager getSelectedProfile]; //returns the currently selected OSCProfile
|
OSCProfile *oscProfile = [profilesManager getSelectedProfile]; //returns the currently selected OSCProfile
|
||||||
@@ -372,7 +380,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:buttonState.name keyLabel:buttonState.alias]; //reconstruct buttonView
|
OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:buttonState.name keyLabel:buttonState.alias]; //reconstruct buttonView
|
||||||
buttonView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
|
buttonView.translatesAutoresizingMaskIntoConstraints = NO; // weird but this is mandatory, or you will find no key views added to the right place
|
||||||
// Add the buttonView to the view controller's view
|
// Add the buttonView to the view controller's view
|
||||||
[self.superview addSubview:buttonView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
|
[self->streamFrameTopLayerView addSubview:buttonView]; // add keyboard button to the stream frame view. must add it to the target view before setting location.
|
||||||
[buttonView setKeyLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
|
[buttonView setKeyLocationWithXOffset:buttonState.position.x yOffset:buttonState.position.y];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -582,8 +582,9 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- (bool) isOnScreenControllerOrButtonEnabled{
|
||||||
|
return ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == ABSOLUTE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -600,8 +601,7 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool oscEnabled = ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff;
|
bool customOscEnabled = [self isOnScreenControllerOrButtonEnabled] && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
|
||||||
bool customOscEnabled = oscEnabled && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
|
|
||||||
// [self widget:self.keyboardToggleFingerNumSlider setEnabled:!customOscEnabled];
|
// [self widget:self.keyboardToggleFingerNumSlider setEnabled:!customOscEnabled];
|
||||||
if(customOscEnabled && !justEnteredSettingsViewDoNotOpenOscLayoutTool) {
|
if(customOscEnabled && !justEnteredSettingsViewDoNotOpenOscLayoutTool) {
|
||||||
// [self.keyboardToggleFingerNumSlider setValue:3.0];
|
// [self.keyboardToggleFingerNumSlider setValue:3.0];
|
||||||
@@ -682,9 +682,8 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
|
|
||||||
- (void) touchModeChanged {
|
- (void) touchModeChanged {
|
||||||
// Disable On-Screen Controls & Buttons in non-relative touch mode
|
// Disable On-Screen Controls & Buttons in non-relative touch mode
|
||||||
bool oscEnabled = ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff;
|
bool oscSelectorEnabled = [self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == ABSOLUTE_TOUCH;
|
||||||
bool oscSelectorEnabled = [self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH;
|
bool customOscEnabled = [self isOnScreenControllerOrButtonEnabled] && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
|
||||||
bool customOscEnabled = oscEnabled && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
|
|
||||||
bool isNativeTouch = [self.touchModeSelector selectedSegmentIndex] == PURE_NATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH;
|
bool isNativeTouch = [self.touchModeSelector selectedSegmentIndex] == PURE_NATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH;
|
||||||
|
|
||||||
[self.onscreenControlSelector setEnabled:oscSelectorEnabled];
|
[self.onscreenControlSelector setEnabled:oscSelectorEnabled];
|
||||||
@@ -898,8 +897,8 @@ BOOL isCustomResolution(CGSize res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) keyboardToggleFingerNumSliderMoved{
|
- (void) keyboardToggleFingerNumSliderMoved{
|
||||||
bool oscEnabled = ([self.touchModeSelector selectedSegmentIndex] == RELATIVE_TOUCH || [self.touchModeSelector selectedSegmentIndex] == REGULAR_NATIVE_TOUCH) && [self.onscreenControlSelector selectedSegmentIndex] != OnScreenControlsLevelOff;
|
// bool oscEnabled = [self isOnScreenControllerOrButtonEnabled];
|
||||||
bool customOscEnabled = oscEnabled && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
|
bool customOscEnabled = [self isOnScreenControllerOrButtonEnabled] && [self.onscreenControlSelector selectedSegmentIndex] == OnScreenControlsLevelCustom;
|
||||||
|
|
||||||
CGFloat sliderValue = self.keyboardToggleFingerNumSlider.value;
|
CGFloat sliderValue = self.keyboardToggleFingerNumSlider.value;
|
||||||
if(customOscEnabled){
|
if(customOscEnabled){
|
||||||
|
|||||||
@@ -62,14 +62,18 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (bool)isOscLayoutToolEnabled{
|
||||||
|
return (_settings.touchMode.intValue == RELATIVE_TOUCH || _settings.touchMode.intValue == REGULAR_NATIVE_TOUCH || _settings.touchMode.intValue == ABSOLUTE_TOUCH) && _settings.onscreenControls.intValue == OnScreenControlsLevelCustom;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)configOscLayoutTool{
|
- (void)configOscLayoutTool{
|
||||||
if((_settings.touchMode.intValue == RELATIVE_TOUCH || _settings.touchMode.intValue == REGULAR_NATIVE_TOUCH) && _settings.onscreenControls.intValue == OnScreenControlsLevelCustom){
|
if([self isOscLayoutToolEnabled]){
|
||||||
_oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)];
|
_oscLayoutTapRecoginizer = [[CustomTapGestureRecognizer alloc] initWithTarget:self action:@selector(layoutOSC)];
|
||||||
_oscLayoutTapRecoginizer.numberOfTouchesRequired = _settings.oscLayoutToolFingers.intValue; //tap a predefined number of fingers to open osc layout tool
|
_oscLayoutTapRecoginizer.numberOfTouchesRequired = _settings.oscLayoutToolFingers.intValue; //tap a predefined number of fingers to open osc layout tool
|
||||||
_oscLayoutTapRecoginizer.tapDownTimeThreshold = 0.2;
|
_oscLayoutTapRecoginizer.tapDownTimeThreshold = 0.2;
|
||||||
_oscLayoutTapRecoginizer.delaysTouchesBegan = NO;
|
_oscLayoutTapRecoginizer.delaysTouchesBegan = NO;
|
||||||
_oscLayoutTapRecoginizer.delaysTouchesEnded = NO;
|
_oscLayoutTapRecoginizer.delaysTouchesEnded = NO;
|
||||||
|
if(_settings.touchMode.intValue == ABSOLUTE_TOUCH) _oscLayoutTapRecoginizer.immediateTriggering = true; // make immediate triggering on for absolute touch mode
|
||||||
|
|
||||||
[self.view addGestureRecognizer:_oscLayoutTapRecoginizer]; //
|
[self.view addGestureRecognizer:_oscLayoutTapRecoginizer]; //
|
||||||
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
|
/* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */
|
||||||
@@ -112,7 +116,7 @@
|
|||||||
[self.view addGestureRecognizer:_slideToCmdToolRecognizer];
|
[self.view addGestureRecognizer:_slideToCmdToolRecognizer];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)configZoomGesture{
|
- (void)configZoomGestureAndAddStreamView{
|
||||||
if (_settings.touchMode.intValue == ABSOLUTE_TOUCH) {
|
if (_settings.touchMode.intValue == ABSOLUTE_TOUCH) {
|
||||||
_scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
|
_scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
@@ -148,12 +152,12 @@
|
|||||||
_settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here.
|
_settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here.
|
||||||
[self configOscLayoutTool];
|
[self configOscLayoutTool];
|
||||||
[self configSwipeGestures];
|
[self configSwipeGestures];
|
||||||
[self configZoomGesture];
|
[self configZoomGestureAndAddStreamView];
|
||||||
[self->_streamView disableOnScreenControls]; //don't know why but this must be called outside the streamview class, just put it here. execute in streamview class cause hang
|
[self->_streamView disableOnScreenControls]; //don't know why but this must be called outside the streamview class, just put it here. execute in streamview class cause hang
|
||||||
[self.mainFrameViewcontroller reloadStreamConfig]; // reload streamconfig
|
[self.mainFrameViewcontroller reloadStreamConfig]; // reload streamconfig
|
||||||
|
|
||||||
_controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig delegate:self]; // reload controllerSupport obj, this is mandatory for OSC reload,especially when the stream view is launched without OSC
|
_controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig delegate:self]; // reload controllerSupport obj, this is mandatory for OSC reload,especially when the stream view is launched without OSC
|
||||||
[_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig]; //reinitiate setupStreamView process.
|
[_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig streamFrameTopLayerView:self.view]; //reinitiate setupStreamView process.
|
||||||
[self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport
|
[self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport
|
||||||
andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here.
|
andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here.
|
||||||
[self->_streamView reloadOnScreenKeyboardButtons]; //reload keyboard buttons here. the keyboard button view will be added to the streamframe view instead streamview, the highest layer, which saves a lot of reengineering
|
[self->_streamView reloadOnScreenKeyboardButtons]; //reload keyboard buttons here. the keyboard button view will be added to the streamframe view instead streamview, the highest layer, which saves a lot of reengineering
|
||||||
|
|||||||
Reference in new issue
Block a user