- button down action for MOUSEPAD
This commit is contained in:
1 parent
594906c121
commit
9063331d38
12 files changed
+450
-26
No files matched your search
@@ -366,6 +366,7 @@ static CGRect streamViewBounds;
|
||||
buttonState.backgroundAlpha = widgetView.backgroundAlpha;
|
||||
buttonState.borderWidth = widgetView.borderWidth;
|
||||
buttonState.vibrationStyle = widgetView.vibrationStyle;
|
||||
buttonState.mouseButtonAction = widgetView.mouseButtonAction;
|
||||
buttonState.sensitivityFactor = widgetView.sensitivityFactor;
|
||||
buttonState.stickIndicatorOffset = widgetView.stickIndicatorOffset;
|
||||
buttonState.widgetShape = widgetView.shape;
|
||||
|
||||
@@ -38,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, assign) CGFloat oscLayerSizeFactor; // for OnScreenController CALayer
|
||||
@property (nonatomic, assign) CGFloat backgroundAlpha; // for OnScreenController CALayer
|
||||
@property (nonatomic, assign) uint8_t vibrationStyle; // for OnScreenController CALayer
|
||||
@property (nonatomic, assign) uint8_t mouseButtonAction; // for OnScreenController CALayer
|
||||
|
||||
// @property (nonatomic, assign) BOOL hasValidPosition;
|
||||
|
||||
@@ -46,6 +47,14 @@ typedef NS_ENUM(NSInteger, OnScreenButtonType) {
|
||||
CustomOnScreenWidget
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, MouseButtonAction) {
|
||||
hovering,
|
||||
leftButtonDown,
|
||||
middleButtonDown,
|
||||
rightButtonDown,
|
||||
};
|
||||
|
||||
|
||||
- (id) initWithButtonName:(NSString*)name buttonType:(uint8_t)buttonType andPosition:(CGPoint)position;
|
||||
|
||||
+ (BOOL) supportsSecureCoding;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
[encoder encodeObject:self.alias forKey:@"alias"];
|
||||
[encoder encodeInt:self.buttonType forKey:@"buttonType"];
|
||||
[encoder encodeInt:self.vibrationStyle forKey:@"vibrationStyle"];
|
||||
[encoder encodeInt:self.mouseButtonAction forKey:@"mouseButtonAction"];
|
||||
[encoder encodeCGPoint:self.position forKey:@"position"];
|
||||
[encoder encodeBool:self.isHidden forKey:@"isHidden"];
|
||||
[encoder encodeFloat:self.widthFactor forKey:@"widthFactor"];
|
||||
@@ -53,6 +54,7 @@
|
||||
self.alias = [decoder decodeObjectForKey:@"alias"];
|
||||
self.buttonType = [decoder decodeIntForKey:@"buttonType"];
|
||||
self.vibrationStyle = [decoder decodeIntForKey:@"vibrationStyle"];
|
||||
self.mouseButtonAction = [decoder decodeIntForKey:@"mouseButtonAction"];
|
||||
self.position = [decoder decodeCGPointForKey:@"position"];
|
||||
self.isHidden = [decoder decodeBoolForKey:@"isHidden"];
|
||||
self.widthFactor = [decoder decodeFloatForKey:@"widthFactor"];
|
||||
|
||||
@@ -19,19 +19,19 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
@objc public weak var guidelineDelegate: OnScreenWidgetGuidelineUpdateDelegate?
|
||||
|
||||
@objc protocol OnScreenWidgetGuidelineUpdateDelegate: AnyObject {
|
||||
func updateGuidelinesForOnScreenWidget(_ sender: Any)
|
||||
}
|
||||
@objc public weak var guidelineDelegate: OnScreenWidgetGuidelineUpdateDelegate?
|
||||
|
||||
|
||||
enum WidgetTypeEnum: UInt8 {
|
||||
case uninitialized = 0
|
||||
case button = 1
|
||||
case touchPad = 2
|
||||
@objc enum WidgetTypeEnum: UInt8 {
|
||||
case uninitialized
|
||||
case button
|
||||
case touchPad
|
||||
}
|
||||
|
||||
private var widgetType: WidgetTypeEnum = WidgetTypeEnum.uninitialized
|
||||
@objc public var widgetType: WidgetTypeEnum = WidgetTypeEnum.uninitialized
|
||||
|
||||
@objc static public var editMode: Bool = false
|
||||
@objc public var buttonLabel: String
|
||||
@@ -54,7 +54,7 @@ import UIKit
|
||||
@objc public var storedCenter: CGPoint = .zero // location from persisted data
|
||||
@objc public var initialCenter: CGPoint = .zero // location from persisted data
|
||||
@objc public var layoutChanges: [CGPoint] = []
|
||||
|
||||
@objc public var mouseButtonAction: MouseButtonAction = .hovering;
|
||||
|
||||
private let appWindow: UIView
|
||||
|
||||
@@ -1034,6 +1034,21 @@ import UIKit
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
if self.widgetType == WidgetTypeEnum.touchPad && self.touchPadString == "MOUSEPAD" && allCapturedTouchesCount == 1 && !twoTouchesDetected {
|
||||
switch mouseButtonAction{
|
||||
case .leftButtonDown:
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_PRESS), BUTTON_LEFT)
|
||||
case .middleButtonDown:
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_PRESS), BUTTON_MIDDLE)
|
||||
case .rightButtonDown:
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_PRESS), BUTTON_RIGHT)
|
||||
case .hovering:
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1178,14 +1193,28 @@ import UIKit
|
||||
|
||||
// deal with pure MOUSPAD first
|
||||
if !OnScreenWidgetView.editMode && self.widgetType == WidgetTypeEnum.touchPad && self.touchPadString == "MOUSEPAD" && allCapturedTouchesCount == 1 && !twoTouchesDetected {
|
||||
if !mousePointerMoved && !quickDoubleTapDetected {self.sendLongMouseLeftButtonClickEvent()} // deal with single tap(click)
|
||||
if quickDoubleTapDetected { //deal with quick double tap
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), BUTTON_LEFT) //must release the button anyway, because the button is likely being held down since the long click turned into a dragging event.
|
||||
if !mousePointerMoved {self.sendShortMouseLeftButtonClickEvent()}
|
||||
quickDoubleTapDetected = false
|
||||
}
|
||||
mousePointerMoved = false // reset this flag
|
||||
|
||||
switch mouseButtonAction{
|
||||
case .leftButtonDown:
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), BUTTON_LEFT)
|
||||
case .middleButtonDown:
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), BUTTON_MIDDLE)
|
||||
case .rightButtonDown:
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), BUTTON_RIGHT)
|
||||
case .hovering:
|
||||
if !mousePointerMoved && !quickDoubleTapDetected {self.sendLongMouseLeftButtonClickEvent()} // deal with single tap(click)
|
||||
if quickDoubleTapDetected { //deal with quick double tap
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_RELEASE), BUTTON_LEFT) //must release the button anyway, because the button is likely being held down since the long click turned into a dragging event.
|
||||
if !mousePointerMoved {self.sendShortMouseLeftButtonClickEvent()}
|
||||
quickDoubleTapDetected = false
|
||||
}
|
||||
mousePointerMoved = false // reset this flag
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if !OnScreenWidgetView.editMode && self.widgetType == WidgetTypeEnum.touchPad && self.touchPadString == "MOUSEPAD" && twoTouchesDetected && touches.count == allCapturedTouchesCount { // need to enable multi-touch first
|
||||
// touches.count == allCapturedTouchesCount means allfingers are lifting
|
||||
self.sendMouseRightButtonClickEvent()
|
||||
|
||||
@@ -403,6 +403,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
widgetView.heightFactor = buttonState.heightFactor;
|
||||
widgetView.borderWidth = buttonState.borderWidth;
|
||||
[widgetView setVibrationWithStyle:buttonState.vibrationStyle];
|
||||
widgetView.mouseButtonAction = buttonState.mouseButtonAction;
|
||||
widgetView.sensitivityFactor = buttonState.sensitivityFactor;
|
||||
widgetView.stickIndicatorOffset = buttonState.stickIndicatorOffset;
|
||||
widgetView.minStickOffset = buttonState.minStickOffset;
|
||||
|
||||
Reference in new issue
Block a user