special overlay button "settings" implementation
This commit is contained in:
1 parent
b7d8889180
commit
ef418be2df
4 files changed
+52
-12
No files matched your search
@@ -77,6 +77,7 @@ import UIKit
|
|||||||
@objc public static let touchPadCmds: [String] = ["LSVPAD", "RSVPAD", "LSPAD", "RSPAD", "MOUSEPAD", "DPAD", "WASDPAD", "ARROWPAD"]
|
@objc public static let touchPadCmds: [String] = ["LSVPAD", "RSVPAD", "LSPAD", "RSPAD", "MOUSEPAD", "DPAD", "WASDPAD", "ARROWPAD"]
|
||||||
@objc public static let stickTouchPads: [String] = ["LSVPAD", "RSVPAD", "LSPAD", "RSPAD"]
|
@objc public static let stickTouchPads: [String] = ["LSVPAD", "RSVPAD", "LSPAD", "RSPAD"]
|
||||||
@objc public static let nonVectorStickPads: [String] = ["LSPAD", "RSPAD"]
|
@objc public static let nonVectorStickPads: [String] = ["LSPAD", "RSPAD"]
|
||||||
|
@objc public static let specialOverlayButtonCmds: [String] = ["SETTINGS"]
|
||||||
|
|
||||||
static let keyboardButtonMappings: [String: Int16] = [
|
static let keyboardButtonMappings: [String: Int16] = [
|
||||||
// Windows Key Codes
|
// Windows Key Codes
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ import UIKit
|
|||||||
self.mousePointerMoved = false
|
self.mousePointerMoved = false
|
||||||
self.touchLockedForMoveEvent = UITouch()
|
self.touchLockedForMoveEvent = UITouch()
|
||||||
self.twoTouchesDetected = false
|
self.twoTouchesDetected = false
|
||||||
self.stickIndicatorXOffset = 120
|
self.stickIndicatorXOffset = 95
|
||||||
self.sensitivityFactor = 1.0
|
self.sensitivityFactor = 1.0
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
|
|
||||||
@@ -263,6 +263,11 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if CommandManager.specialOverlayButtonCmds.contains(self.keyString){
|
||||||
|
self.layer.borderWidth = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// self.layer.shadowColor = UIColor.clear.cgColor
|
// self.layer.shadowColor = UIColor.clear.cgColor
|
||||||
// self.layer.shadowRadius = 8
|
// self.layer.shadowRadius = 8
|
||||||
// self.layer.shadowOpacity = 0.5
|
// self.layer.shadowOpacity = 0.5
|
||||||
@@ -611,6 +616,7 @@ import UIKit
|
|||||||
CATransaction.begin()
|
CATransaction.begin()
|
||||||
CATransaction.setDisableActions(true)
|
CATransaction.setDisableActions(true)
|
||||||
// self.layer.borderWidth = 0
|
// self.layer.borderWidth = 0
|
||||||
|
buttonDownVisualEffectLayer.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)) // update position every time we press down the button
|
||||||
buttonDownVisualEffectLayer.borderWidth = self.buttonDownVisualEffectWidth // this will show the visual effect
|
buttonDownVisualEffectLayer.borderWidth = self.buttonDownVisualEffectWidth // this will show the visual effect
|
||||||
buttonDownVisualEffectLayer.borderColor = moonlightPurple
|
buttonDownVisualEffectLayer.borderColor = moonlightPurple
|
||||||
CATransaction.commit()
|
CATransaction.commit()
|
||||||
@@ -734,11 +740,11 @@ import UIKit
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !CommandManager.touchPadCmds.contains(self.keyString) {
|
if !CommandManager.touchPadCmds.contains(self.keyString) {
|
||||||
self.buttonDownVisualEffect()
|
self.buttonDownVisualEffect()
|
||||||
}
|
}
|
||||||
|
|
||||||
if CommandManager.oscButtonMappings.keys.contains(self.keyString) {
|
if CommandManager.oscButtonMappings.keys.contains(self.keyString) {
|
||||||
let buttonFlag = CommandManager.oscButtonMappings[self.keyString]
|
let buttonFlag = CommandManager.oscButtonMappings[self.keyString]
|
||||||
if buttonFlag != 0 {self.onScreenControls.pressDownControllerButton(buttonFlag!)}
|
if buttonFlag != 0 {self.onScreenControls.pressDownControllerButton(buttonFlag!)}
|
||||||
@@ -773,6 +779,15 @@ import UIKit
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func moveByTouch(touch: UITouch){
|
||||||
|
let currentLocation = touch.location(in: superview)
|
||||||
|
let offsetX = currentLocation.x - storedLocation.x
|
||||||
|
let offsetY = currentLocation.y - storedLocation.y
|
||||||
|
center = CGPoint(x: center.x + offsetX, y: center.y + offsetY)
|
||||||
|
//NSLog("x coord: %f, y coord: %f", self.frame.origin.x, self.frame.origin.y)
|
||||||
|
storedLocation = currentLocation // Update initial center for next movement
|
||||||
|
}
|
||||||
|
|
||||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
super.touchesMoved(touches, with: event)
|
super.touchesMoved(touches, with: event)
|
||||||
OnScreenButtonView.timestampOfButtonBeingDragged = self.timestamp
|
OnScreenButtonView.timestampOfButtonBeingDragged = self.timestamp
|
||||||
@@ -781,20 +796,23 @@ import UIKit
|
|||||||
if CommandManager.touchPadCmds.contains(self.keyString){
|
if CommandManager.touchPadCmds.contains(self.keyString){
|
||||||
handleTouchPadMoveEvent(touches, with: event)
|
handleTouchPadMoveEvent(touches, with: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if CommandManager.specialOverlayButtonCmds.contains(self.keyString){
|
||||||
|
if let touch = touches.first {
|
||||||
|
NSLog("touchTapTimeStamp %f", self.touchTapTimeStamp)
|
||||||
|
if CACurrentMediaTime() - self.touchTapTimeStamp > 0.3 { // temporarily relocate special buttons
|
||||||
|
self.moveByTouch(touch: touch)
|
||||||
|
self.buttonUpVisualEffect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the buttonView based on touch movement in relocation mode
|
// Move the buttonView based on touch movement in relocation mode
|
||||||
if OnScreenButtonView.editMode {
|
if OnScreenButtonView.editMode {
|
||||||
if let touch = touches.first {
|
if let touch = touches.first {
|
||||||
let currentLocation = touch.location(in: superview)
|
self.moveByTouch(touch: touch)
|
||||||
let offsetX = currentLocation.x - storedLocation.x
|
|
||||||
let offsetY = currentLocation.y - storedLocation.y
|
|
||||||
|
|
||||||
center = CGPoint(x: center.x + offsetX, y: center.y + offsetY)
|
|
||||||
//NSLog("x coord: %f, y coord: %f", self.frame.origin.x, self.frame.origin.y)
|
|
||||||
storedLocation = currentLocation // Update initial center for next movement
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if CommandManager.nonVectorStickPads.contains(self.keyString) {
|
if CommandManager.nonVectorStickPads.contains(self.keyString) {
|
||||||
self.stickBallLayer.removeFromSuperlayer()
|
self.stickBallLayer.removeFromSuperlayer()
|
||||||
self.crossMarkLayer.removeFromSuperlayer()
|
self.crossMarkLayer.removeFromSuperlayer()
|
||||||
@@ -894,6 +912,18 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !OnScreenButtonView.editMode && CommandManager.specialOverlayButtonCmds.contains(self.keyString){
|
||||||
|
if CACurrentMediaTime() - self.touchTapTimeStamp < 0.3 {
|
||||||
|
switch self.keyString {
|
||||||
|
case "SETTINGS":
|
||||||
|
NotificationCenter.default.post(name: Notification.Name("SettingsOverlayButtonPressedNotification"), object:nil) // inform layout tool controller to fetch button size factors. self will be passed as the object of the notification
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.buttonUpVisualEffect()
|
self.buttonUpVisualEffect()
|
||||||
self.l3r3Indicator.removeFromSuperlayer()
|
self.l3r3Indicator.removeFromSuperlayer()
|
||||||
|
|||||||
+4
-1
@@ -349,7 +349,9 @@
|
|||||||
bool noValidMouseButtonString = ![CommandManager.mouseButtonMappings.allKeys containsObject:cmdString];
|
bool noValidMouseButtonString = ![CommandManager.mouseButtonMappings.allKeys containsObject:cmdString];
|
||||||
bool noValidTouchPadString = ![CommandManager.touchPadCmds containsObject:cmdString];
|
bool noValidTouchPadString = ![CommandManager.touchPadCmds containsObject:cmdString];
|
||||||
bool noValidOscButtonString = ![CommandManager.oscButtonMappings.allKeys containsObject:cmdString];
|
bool noValidOscButtonString = ![CommandManager.oscButtonMappings.allKeys containsObject:cmdString];
|
||||||
if(noValidKeyboardString && noValidMouseButtonString && noValidTouchPadString && noValidOscButtonString) return;
|
bool noValidSpecialButtonString = ![CommandManager.specialOverlayButtonCmds containsObject:cmdString];
|
||||||
|
|
||||||
|
if(noValidKeyboardString && noValidMouseButtonString && noValidTouchPadString && noValidOscButtonString && noValidSpecialButtonString) return;
|
||||||
|
|
||||||
//saving & present the keyboard button:
|
//saving & present the keyboard button:
|
||||||
OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:cmdString keyLabel:keyLabel];
|
OnScreenButtonView* buttonView = [[OnScreenButtonView alloc] initWithKeyString:cmdString keyLabel:keyLabel];
|
||||||
@@ -467,6 +469,7 @@
|
|||||||
[widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self.widgetHeightSlider.value]];
|
[widgetHeightSliderLabel setText:[LocalizationHelper localizedStringForKey:@"Widget Height: %.2f", self.widgetHeightSlider.value]];
|
||||||
if(self->selectedButtonView != nil && self->buttonViewSelected){
|
if(self->selectedButtonView != nil && self->buttonViewSelected){
|
||||||
self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change
|
self->selectedButtonView.translatesAutoresizingMaskIntoConstraints = true; // this is mandatory to prevent unexpected key view location change
|
||||||
|
if([CommandManager.oscButtonMappings.allKeys containsObject:selectedButtonView.keyString]) return; // don't change custom osc button height
|
||||||
self->selectedButtonView.heightFactor = self.widgetHeightSlider.value;
|
self->selectedButtonView.heightFactor = self.widgetHeightSlider.value;
|
||||||
[self->selectedButtonView resizeButtonView];
|
[self->selectedButtonView resizeButtonView];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,6 +233,12 @@
|
|||||||
selector:@selector(sessionDisconnectedBySettingView) //quit session when exit button is press in setting view during streaming
|
selector:@selector(sessionDisconnectedBySettingView) //quit session when exit button is press in setting view during streaming
|
||||||
name:@"SessionDisconnectedBySettingsViewNotification"
|
name:@"SessionDisconnectedBySettingsViewNotification"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(expandSettingsView) // //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated.
|
||||||
|
name:@"SettingsOverlayButtonPressedNotification"
|
||||||
|
object:nil];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user