in-stream gyro switch stage 1
This commit is contained in:
@@ -1217,7 +1217,7 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="z5Q-bW-WQ8" userLabel="widgetPanelStack" customClass="WidgetPanelStackView">
|
||||
<rect key="frame" x="325" y="156" width="650" height="308.5"/>
|
||||
<rect key="frame" x="325" y="156" width="650" height="348.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Profile:" textAlignment="center" lineBreakMode="tailTruncation" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iel-xl-xd9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="650" height="37"/>
|
||||
@@ -1330,7 +1330,7 @@
|
||||
</slider>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="80D-qe-E5D" userLabel="sensitivityFactorStack">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="80D-qe-E5D" userLabel="sensitivityFactorXStack">
|
||||
<rect key="frame" x="0.0" y="237.5" width="650" height="30"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="test" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vJs-pg-hHe" userLabel="sensitivityFactorLabel">
|
||||
@@ -1349,8 +1349,27 @@
|
||||
</slider>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CT5-Ap-Gh0" userLabel="sensitivityFactorYStack">
|
||||
<rect key="frame" x="0.0" y="277.5" width="650" height="30"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="test" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NZO-BM-nef" userLabel="sensitivityFactorYLabel">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="160" id="PVs-bg-tFM"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<slider clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="8" translatesAutoresizingMaskIntoConstraints="NO" id="2Wo-9z-DtK">
|
||||
<rect key="frame" x="158" y="0.0" width="494" height="31"/>
|
||||
<color key="tintColor" red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="maximumTrackTintColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</slider>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GMQ-EQ-Hum" userLabel="mouseDownButtonStack">
|
||||
<rect key="frame" x="0.0" y="277.5" width="650" height="31"/>
|
||||
<rect key="frame" x="0.0" y="317.5" width="650" height="31"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Down Button" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c1r-Hf-b7t" userLabel="mouseDownButtonLabel">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="31"/>
|
||||
@@ -1404,9 +1423,12 @@
|
||||
<outlet property="mouseButtonDownSelector" destination="H8S-aI-EBo" id="em1-fK-Cpb"/>
|
||||
<outlet property="mouseDownButtonStack" destination="GMQ-EQ-Hum" id="sxb-40-3NI"/>
|
||||
<outlet property="saveButton" destination="uda-zt-xrG" id="FyB-WY-rri"/>
|
||||
<outlet property="sensitivityLabel" destination="vJs-pg-hHe" id="RRw-Zq-LUa"/>
|
||||
<outlet property="sensitivitySlider" destination="DiG-XX-r8c" id="fz5-Et-1WV"/>
|
||||
<outlet property="sensitivityStack" destination="80D-qe-E5D" id="Qx6-UY-Hhj"/>
|
||||
<outlet property="sensitivityXLabel" destination="vJs-pg-hHe" id="RRw-Zq-LUa"/>
|
||||
<outlet property="sensitivityXSlider" destination="DiG-XX-r8c" id="fz5-Et-1WV"/>
|
||||
<outlet property="sensitivityXStack" destination="80D-qe-E5D" id="Qx6-UY-Hhj"/>
|
||||
<outlet property="sensitivityYLabel" destination="NZO-BM-nef" id="baU-O4-Qp7"/>
|
||||
<outlet property="sensitivityYSlider" destination="2Wo-9z-DtK" id="Hw1-JZ-vir"/>
|
||||
<outlet property="sensitivityYStack" destination="CT5-Ap-Gh0" id="qY9-G9-b7r"/>
|
||||
<outlet property="stickIndicatorOffsetLabel" destination="tG7-oX-P9b" id="jBx-ii-091"/>
|
||||
<outlet property="stickIndicatorOffsetSlider" destination="aPX-7o-N3l" id="gLv-c3-3JG"/>
|
||||
<outlet property="stickIndicatorOffsetStack" destination="zfD-bd-GEN" id="oeb-Vk-2mw"/>
|
||||
@@ -1430,7 +1452,7 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dev-Ck-vTF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2699.2805755395684" y="1067.6033057851239"/>
|
||||
<point key="canvasLocation" x="2760" y="987"/>
|
||||
</scene>
|
||||
<!--Profiles Table View Controller-->
|
||||
<scene sceneID="W0E-wz-n2b">
|
||||
@@ -1523,19 +1545,19 @@
|
||||
<image name="tray.full.fill" catalog="system" width="128" height="88"/>
|
||||
<image name="video.and.waveform" catalog="system" width="128" height="94"/>
|
||||
<systemColor name="linkColor">
|
||||
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemBrownColor">
|
||||
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemGray3Color">
|
||||
<color red="0.7803921568627451" green="0.7803921568627451" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.78039215689999997" green="0.78039215689999997" blue="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemTealColor">
|
||||
<color red="0.18823529411764706" green="0.69019607843137254" blue="0.7803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -321,7 +321,7 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" spacing="7" translatesAutoresizingMaskIntoConstraints="NO" id="BVp-3O-vZ7" userLabel="widgetPanelStack" customClass="WidgetPanelStackView">
|
||||
<rect key="frame" x="325" y="226" width="550" height="244.5"/>
|
||||
<rect key="frame" x="325" y="226" width="550" height="271.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Profile:" textAlignment="center" lineBreakMode="tailTruncation" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f46-Pt-0Pv">
|
||||
<rect key="frame" x="0.0" y="0.0" width="550" height="28"/>
|
||||
@@ -446,7 +446,7 @@
|
||||
<constraint firstAttribute="height" constant="20" id="V72-IS-Ggi"/>
|
||||
</constraints>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fem-TG-vr3" userLabel="sensitivityFactorStack">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fem-TG-vr3" userLabel="sensitivityFactorXStack">
|
||||
<rect key="frame" x="0.0" y="170.5" width="550" height="20"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="test" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dJh-Ck-ugh" userLabel="sensitivityFactorLabel">
|
||||
@@ -468,8 +468,30 @@
|
||||
<constraint firstAttribute="height" constant="20" id="ZTP-tC-Uia"/>
|
||||
</constraints>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gsG-6n-BAb" userLabel="vibrationStyleStack">
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="50h-xK-Lq0" userLabel="sensitivityFactorYStack">
|
||||
<rect key="frame" x="0.0" y="197.5" width="550" height="20"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="test" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="R9C-JW-nkF" userLabel="sensitivityFactorYLabel">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="20"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="160" id="MQ6-xc-8mf"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<slider clearsContextBeforeDrawing="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="8" translatesAutoresizingMaskIntoConstraints="NO" id="W7r-eN-vZJ">
|
||||
<rect key="frame" x="158" y="0.0" width="394" height="21"/>
|
||||
<color key="tintColor" red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="maximumTrackTintColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</slider>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="20" id="0xk-WB-usH"/>
|
||||
</constraints>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gsG-6n-BAb" userLabel="vibrationStyleStack">
|
||||
<rect key="frame" x="0.0" y="224.5" width="550" height="20"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Vibration Style" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u3w-Se-xzH" userLabel="sensitivityFactorLabel">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="20"/>
|
||||
@@ -500,7 +522,7 @@
|
||||
</constraints>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lEZ-1a-89J" userLabel="mouseButtonDownStack">
|
||||
<rect key="frame" x="0.0" y="224.5" width="550" height="20"/>
|
||||
<rect key="frame" x="0.0" y="251.5" width="550" height="20"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Button Down" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ozU-7C-qKE" userLabel="uilabel">
|
||||
<rect key="frame" x="0.0" y="0.0" width="160" height="20"/>
|
||||
@@ -550,9 +572,12 @@
|
||||
<outlet property="loadConfigTipLabel" destination="9Gg-66-UdB" id="cMS-ly-En0"/>
|
||||
<outlet property="mouseButtonDownSelector" destination="tE5-Bm-4OB" id="9fh-99-8pu"/>
|
||||
<outlet property="mouseDownButtonStack" destination="lEZ-1a-89J" id="R6t-gC-kcD"/>
|
||||
<outlet property="sensitivityLabel" destination="dJh-Ck-ugh" id="vso-QW-vxX"/>
|
||||
<outlet property="sensitivitySlider" destination="Vqk-gH-0xO" id="CVC-XX-0LQ"/>
|
||||
<outlet property="sensitivityStack" destination="fem-TG-vr3" id="O9M-Ip-ZlT"/>
|
||||
<outlet property="sensitivityXLabel" destination="dJh-Ck-ugh" id="vso-QW-vxX"/>
|
||||
<outlet property="sensitivityXSlider" destination="Vqk-gH-0xO" id="CVC-XX-0LQ"/>
|
||||
<outlet property="sensitivityXStack" destination="fem-TG-vr3" id="O9M-Ip-ZlT"/>
|
||||
<outlet property="sensitivityYLabel" destination="R9C-JW-nkF" id="80R-jo-bcA"/>
|
||||
<outlet property="sensitivityYSlider" destination="W7r-eN-vZJ" id="xGy-E1-87k"/>
|
||||
<outlet property="sensitivityYStack" destination="50h-xK-Lq0" id="eOh-7i-9mS"/>
|
||||
<outlet property="stickIndicatorOffsetLabel" destination="fcy-zp-LGa" id="lZP-Uv-mMH"/>
|
||||
<outlet property="stickIndicatorOffsetSlider" destination="DCr-vG-gM7" id="aYH-VM-p5l"/>
|
||||
<outlet property="stickIndicatorOffsetStack" destination="Ejp-Jq-phL" id="HNM-4A-VmN"/>
|
||||
@@ -1496,16 +1521,16 @@
|
||||
<image name="trash.fill" catalog="system" width="117" height="128"/>
|
||||
<image name="tray.full.fill" catalog="system" width="128" height="88"/>
|
||||
<systemColor name="linkColor">
|
||||
<color red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemBrownColor">
|
||||
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemGray2Color">
|
||||
<color red="0.68235294120000001" green="0.68235294120000001" blue="0.69803921570000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemTealColor">
|
||||
<color red="0.18823529410000001" green="0.69019607839999997" blue="0.78039215689999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.18823529411764706" green="0.69019607843137254" blue="0.7803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -53,13 +53,13 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
@property (nonatomic) NSTimer* _Nullable batteryTimer;
|
||||
@property (nonatomic) GCDeviceBatteryState lastBatteryState;
|
||||
@property (nonatomic) GCDeviceBatteryState lastBatteryState; // to be wrapped for compatibility
|
||||
@property (nonatomic) float lastBatteryLevel;
|
||||
|
||||
@property (nonatomic) BOOL reportedArrival;
|
||||
@property (nonatomic) Controller* _Nullable mergedWithController;
|
||||
|
||||
@property(nonatomic, assign) uint8_t motionType;
|
||||
@property(nonatomic, strong) NSMutableSet* _Nullable motionTypes;
|
||||
@property(nonatomic, assign) uint16_t reportRateHz;
|
||||
@property(nonatomic, assign) uint16_t controllerNumber;
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
|
||||
@protocol ControllerSupportDelegate <NSObject>
|
||||
|
||||
- (void) gamepadPresenceChanged;
|
||||
- (void) mousePresenceChanged;
|
||||
- (void) streamExitRequested;
|
||||
- (void)gamepadPresenceChanged;
|
||||
- (void)mousePresenceChanged;
|
||||
- (void)streamExitRequested;
|
||||
- (void)automaticallyStartSendingBuiltinGyroEvents;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+181
-175
@@ -36,6 +36,7 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
NSLock *_controllerStreamLock;
|
||||
NSMutableDictionary *_controllers;
|
||||
id<ControllerSupportDelegate> _delegate;
|
||||
StreamConfiguration* streamConfig;
|
||||
|
||||
float accumulatedDeltaX;
|
||||
float accumulatedDeltaY;
|
||||
@@ -94,83 +95,78 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
|
||||
-(void)updateTimerStateForController:(Controller* )controller{
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
|
||||
NSLog(@"device gyro codes, gyroMode: %d", _gyroMode);
|
||||
|
||||
|
||||
if(_gyroMode == GyroModeOff){
|
||||
[self stopTimerForController:controller];
|
||||
return;
|
||||
}
|
||||
|
||||
if(_gyroMode != AlwaysController && controller.controllerNumber < 2){
|
||||
NSLog(@"device gyro codes");
|
||||
|
||||
#if !TARGET_OS_TV //tvOS has no device motion
|
||||
if(controller.gamepad.motion == nil || _gyroMode == AlwaysDevice){
|
||||
//Player has no controller *or* no motion for controller 1 *or* wants to override controller 1 motion with device motion
|
||||
if(!controller.motionManager) {
|
||||
controller.motionManager = [[CMMotionManager alloc] init];
|
||||
}
|
||||
for(NSNumber* motionTypeObj in controller.motionTypes){
|
||||
uint8_t motionType = motionTypeObj.intValue;
|
||||
|
||||
if(_gyroMode != AlwaysController && controller.controllerNumber < 2){
|
||||
|
||||
NSLog(@"device gyro codes 2, motionType: %d", controller.motionType);
|
||||
|
||||
switch (controller.motionType) {
|
||||
case LI_MOTION_TYPE_ACCEL:
|
||||
[controller.accelTimer invalidate];
|
||||
controller.accelTimer = nil;
|
||||
|
||||
// Reset the last motion sample
|
||||
CMAcceleration emptyDeviceAccelSample = {};
|
||||
controller.lastDeviceAccelSample = emptyDeviceAccelSample;
|
||||
|
||||
{dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
NSLog(@"device gyro codes 3");
|
||||
|
||||
controller.accelTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / controller.reportRateHz repeats:YES block:^(NSTimer *timer) {
|
||||
// Don't send duplicate samples
|
||||
CMAcceleration lastDeviceAccelSample = controller.lastDeviceAccelSample;
|
||||
CMAcceleration deviceAccelSample = controller.motionManager.deviceMotion.userAcceleration;
|
||||
//userAcceleration does not contain gravity, add gravity to x, y and z values:
|
||||
deviceAccelSample.x += controller.motionManager.deviceMotion.gravity.x;
|
||||
deviceAccelSample.y += controller.motionManager.deviceMotion.gravity.y;
|
||||
deviceAccelSample.z += controller.motionManager.deviceMotion.gravity.z;
|
||||
#if !TARGET_OS_TV //tvOS has no device motion
|
||||
if(controller.gamepad.motion == nil || _gyroMode == AlwaysDevice){
|
||||
//Player has no controller *or* no motion for controller 1 *or* wants to override controller 1 motion with device motion
|
||||
if(!controller.motionManager) {
|
||||
controller.motionManager = [[CMMotionManager alloc] init];
|
||||
}
|
||||
|
||||
NSLog(@"device gyro mode, motionType: %d", motionType);
|
||||
|
||||
switch (motionType) {
|
||||
case LI_MOTION_TYPE_ACCEL:
|
||||
[controller.accelTimer invalidate];
|
||||
controller.accelTimer = nil;
|
||||
// Reset the last motion sample
|
||||
CMAcceleration emptyDeviceAccelSample = {};
|
||||
controller.lastDeviceAccelSample = emptyDeviceAccelSample;
|
||||
|
||||
if (memcmp(&deviceAccelSample, &lastDeviceAccelSample, sizeof(deviceAccelSample)) == 0) {
|
||||
return;
|
||||
}
|
||||
controller.lastDeviceAccelSample = deviceAccelSample;
|
||||
{dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSLog(@"setup device built-in gyro accelTimer");
|
||||
controller.accelTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / controller.reportRateHz repeats:YES block:^(NSTimer *timer) {
|
||||
// Don't send duplicate samples
|
||||
CMAcceleration lastDeviceAccelSample = controller.lastDeviceAccelSample;
|
||||
CMAcceleration deviceAccelSample = controller.motionManager.deviceMotion.userAcceleration;
|
||||
//userAcceleration does not contain gravity, add gravity to x, y and z values:
|
||||
deviceAccelSample.x += controller.motionManager.deviceMotion.gravity.x;
|
||||
deviceAccelSample.y += controller.motionManager.deviceMotion.gravity.y;
|
||||
deviceAccelSample.z += controller.motionManager.deviceMotion.gravity.z;
|
||||
|
||||
if (memcmp(&deviceAccelSample, &lastDeviceAccelSample, sizeof(deviceAccelSample)) == 0) {
|
||||
return;
|
||||
}
|
||||
controller.lastDeviceAccelSample = deviceAccelSample;
|
||||
|
||||
// Convert g to m/s^2
|
||||
if(UIApplication.sharedApplication.windows.firstObject.windowScene.interfaceOrientation == 4){ //check for landscape left or landscape right
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_ACCEL,
|
||||
deviceAccelSample.y * -9.80665f,
|
||||
deviceAccelSample.z * -9.80665f,
|
||||
deviceAccelSample.x * -9.80665f);
|
||||
}
|
||||
else{
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_ACCEL,
|
||||
deviceAccelSample.y * +9.80665f,
|
||||
deviceAccelSample.z * -9.80665f,
|
||||
deviceAccelSample.x * +9.80665f);
|
||||
}
|
||||
}];
|
||||
});}
|
||||
break;
|
||||
case LI_MOTION_TYPE_GYRO:
|
||||
[controller.gyroTimer invalidate];
|
||||
controller.gyroTimer = nil;
|
||||
|
||||
// Convert g to m/s^2
|
||||
NSLog(@"gyro input no.1 %f", CACurrentMediaTime());
|
||||
if(UIApplication.sharedApplication.windows.firstObject.windowScene.interfaceOrientation == 4){ //check for landscape left or landscape right
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_ACCEL,
|
||||
deviceAccelSample.y * -9.80665f,
|
||||
deviceAccelSample.z * -9.80665f,
|
||||
deviceAccelSample.x * -9.80665f);
|
||||
}
|
||||
else{
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_ACCEL,
|
||||
deviceAccelSample.y * +9.80665f,
|
||||
deviceAccelSample.z * -9.80665f,
|
||||
deviceAccelSample.x * +9.80665f);
|
||||
}
|
||||
}];
|
||||
});}
|
||||
break;
|
||||
case LI_MOTION_TYPE_GYRO:
|
||||
[controller.gyroTimer invalidate];
|
||||
controller.gyroTimer = nil;
|
||||
|
||||
// Reset the last motion sample
|
||||
CMRotationRate emptyDeviceGyroSample = {};
|
||||
controller.lastDeviceGyroSample = emptyDeviceGyroSample;
|
||||
|
||||
[controller.motionManager startDeviceMotionUpdates];
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
// Reset the last motion sample
|
||||
CMRotationRate emptyDeviceGyroSample = {};
|
||||
controller.lastDeviceGyroSample = emptyDeviceGyroSample;
|
||||
[controller.motionManager startDeviceMotionUpdates];
|
||||
|
||||
NSLog(@"setup device built-in gyro gyroTimer");
|
||||
controller.gyroTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / controller.reportRateHz repeats:YES block:^(NSTimer *timer) {
|
||||
|
||||
// Don't send duplicate samples
|
||||
@@ -182,7 +178,6 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
controller.lastDeviceGyroSample = deviceGyroSample;
|
||||
|
||||
// Convert rad/s to deg/s
|
||||
NSLog(@"gyro input no.2 %f", CACurrentMediaTime());
|
||||
if(UIApplication.sharedApplication.windows.firstObject.windowScene.interfaceOrientation == 4){//check for landscape left or landscape right
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_GYRO,
|
||||
@@ -199,25 +194,23 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
|
||||
}];
|
||||
});
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else{
|
||||
switch (controller.motionType) {
|
||||
case LI_MOTION_TYPE_ACCEL:
|
||||
[controller.accelTimer invalidate];
|
||||
controller.accelTimer = nil;
|
||||
|
||||
if (controller.reportRateHz && controller.gamepad.motion.hasGravityAndUserAcceleration) {
|
||||
// Reset the last motion sample
|
||||
GCAcceleration emptyAccelSample = {};
|
||||
controller.lastAccelSample = emptyAccelSample;
|
||||
#endif
|
||||
else{
|
||||
switch (motionType) {
|
||||
case LI_MOTION_TYPE_ACCEL:
|
||||
[controller.accelTimer invalidate];
|
||||
controller.accelTimer = nil;
|
||||
NSLog(@"LI_MOTION_TYPE_ACCEL: setup controller gyro accelTimer");
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
if (controller.reportRateHz && controller.gamepad.motion.hasGravityAndUserAcceleration) {
|
||||
// Reset the last motion sample
|
||||
GCAcceleration emptyAccelSample = {};
|
||||
controller.lastAccelSample = emptyAccelSample;
|
||||
NSLog(@"setup controller gyro accelTimer");
|
||||
controller.accelTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / controller.reportRateHz repeats:YES block:^(NSTimer *timer) {
|
||||
// Don't send duplicate samples
|
||||
GCAcceleration lastAccelSample = controller.lastAccelSample;
|
||||
@@ -228,27 +221,24 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
controller.lastAccelSample = accelSample;
|
||||
|
||||
// Convert g to m/s^2
|
||||
NSLog(@"gyro input no.3 %f", CACurrentMediaTime());
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_ACCEL,
|
||||
accelSample.x * -9.80665f,
|
||||
accelSample.y * -9.80665f,
|
||||
accelSample.z * -9.80665f);
|
||||
}];
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case LI_MOTION_TYPE_GYRO:
|
||||
[controller.gyroTimer invalidate];
|
||||
controller.gyroTimer = nil;
|
||||
|
||||
if (controller.reportRateHz && controller.gamepad.motion.hasRotationRate) {
|
||||
// Reset the last motion sample
|
||||
GCRotationRate emptyGyroSample = {};
|
||||
controller.lastGyroSample = emptyGyroSample;
|
||||
}
|
||||
break;
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
case LI_MOTION_TYPE_GYRO:
|
||||
[controller.gyroTimer invalidate];
|
||||
controller.gyroTimer = nil;
|
||||
|
||||
if (controller.reportRateHz && controller.gamepad.motion.hasRotationRate) {
|
||||
// Reset the last motion sample
|
||||
GCRotationRate emptyGyroSample = {};
|
||||
controller.lastGyroSample = emptyGyroSample;
|
||||
NSLog(@"setup controller gyro gyroTimer");
|
||||
controller.gyroTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / controller.reportRateHz repeats:YES block:^(NSTimer *timer) {
|
||||
// Don't send duplicate samples
|
||||
GCRotationRate lastGyroSample = controller.lastGyroSample;
|
||||
@@ -259,16 +249,15 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
controller.lastGyroSample = gyroSample;
|
||||
|
||||
// Convert rad/s to deg/s
|
||||
NSLog(@"gyro input no.4 %f", CACurrentMediaTime());
|
||||
LiSendControllerMotionEvent((uint8_t)controller.controllerNumber,
|
||||
LI_MOTION_TYPE_GYRO,
|
||||
gyroSample.x * 57.2957795f,
|
||||
gyroSample.z * 57.2957795f,
|
||||
gyroSample.y * -57.2957795f);
|
||||
}];
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,13 +274,18 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
// No connected controller for this player, use the _oscController instead
|
||||
controller = _oscController;
|
||||
}
|
||||
|
||||
if(!controller.motionTypes){
|
||||
controller.motionTypes = [[NSMutableSet alloc] init];
|
||||
}
|
||||
[controller.motionTypes addObject:@(motionType)];
|
||||
|
||||
controller.motionType = motionType;
|
||||
controller.reportRateHz = reportRateHz;
|
||||
controller.controllerNumber = controllerNumber;
|
||||
NSLog(@"device gyro codes 0, %d, og: %d, %@", controller.motionType, motionType, controller);
|
||||
NSLog(@"device gyro codes, %@, add motion type: %d, %@", controller.motionTypes, motionType, controller);
|
||||
|
||||
[self updateTimerStateForController:controller];
|
||||
if(controller != _oscController) [self updateTimerStateForController:controller];
|
||||
// built-in gyro will be fired somewhere else
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1219,84 +1213,20 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
|
||||
-(void)updateConfig:(StreamConfiguration*)streamConfig delegate:(id<ControllerSupportDelegate>)delegate {
|
||||
|
||||
_multiController = streamConfig.multiController;
|
||||
_swapABXYButtons = streamConfig.swapABXYButtons;
|
||||
_gyroMode = streamConfig.gyroMode;
|
||||
_delegate = delegate;
|
||||
|
||||
_oscController = [[Controller alloc] init];
|
||||
if(!_oscController) _oscController = [[Controller alloc] init];
|
||||
_oscController.playerIndex = 0;
|
||||
|
||||
DataManager* dataMan = [[DataManager alloc] init];
|
||||
_oscEnabled = (OnScreenControlsLevel)[[dataMan getSettings].onscreenControls integerValue] != OnScreenControlsLevelOff;
|
||||
_oscEnabled = true;
|
||||
|
||||
Log(LOG_I, @"Number of supported controllers connected: %d", [ControllerSupport getGamepadCount]);
|
||||
Log(LOG_I, @"Multi-controller: %d", _multiController);
|
||||
|
||||
_captureMouse = (streamConfig.localMousePointerMode == 0);
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
for (GCMouse* mouse in [GCMouse mice]) {
|
||||
[self registerMouseCallbacks:mouse];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
_mouseConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Mouse connected!");
|
||||
|
||||
GCMouse* mouse = note.object;
|
||||
|
||||
// Register for mouse events
|
||||
[self registerMouseCallbacks: mouse];
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
|
||||
// Notify the delegate
|
||||
[self->_delegate mousePresenceChanged];
|
||||
}];
|
||||
_mouseDisconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Mouse disconnected!");
|
||||
|
||||
GCMouse* mouse = note.object;
|
||||
|
||||
// Unregister for mouse events
|
||||
[self unregisterMouseCallbacks: mouse];
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
|
||||
// Notify the delegate
|
||||
[self->_delegate mousePresenceChanged];
|
||||
}];
|
||||
_keyboardConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCKeyboardDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Keyboard connected!");
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
}];
|
||||
_keyboardDisconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCKeyboardDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Keyboard disconnected!");
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
}];
|
||||
NSLog(@"device gyro codes,update gyroMode: %d, controller count: %lu", _gyroMode, (unsigned long)_controllers.count);
|
||||
for(Controller* controller in _controllers) [self updateTimerStateForController:controller];
|
||||
}
|
||||
}
|
||||
|
||||
-(id)initWithConfig:(StreamConfiguration*)streamConfig delegate:(id<ControllerSupportDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
_controllerNumbers = 0;
|
||||
|
||||
_controllerStreamLock = [[NSLock alloc] init];
|
||||
_controllers = [[NSMutableDictionary alloc] init];
|
||||
|
||||
for (GCController* controller in [GCController controllers]) {
|
||||
if ([ControllerSupport isSupportedGamepad:controller]) {
|
||||
[self assignController:controller];
|
||||
@@ -1307,6 +1237,13 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
}
|
||||
|
||||
_captureMouse = (streamConfig.localMousePointerMode == 0);
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
for (GCMouse* mouse in [GCMouse mice]) {
|
||||
[self registerMouseCallbacks:mouse];
|
||||
}
|
||||
}
|
||||
|
||||
_controllerConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Controller connected!");
|
||||
|
||||
@@ -1375,15 +1312,84 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
}];
|
||||
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
_mouseConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Mouse connected!");
|
||||
|
||||
GCMouse* mouse = note.object;
|
||||
|
||||
// Register for mouse events
|
||||
[self registerMouseCallbacks: mouse];
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
|
||||
// Notify the delegate
|
||||
[self->_delegate mousePresenceChanged];
|
||||
}];
|
||||
_mouseDisconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCMouseDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Mouse disconnected!");
|
||||
|
||||
GCMouse* mouse = note.object;
|
||||
|
||||
// Unregister for mouse events
|
||||
[self unregisterMouseCallbacks: mouse];
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
|
||||
// Notify the delegate
|
||||
[self->_delegate mousePresenceChanged];
|
||||
}];
|
||||
_keyboardConnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCKeyboardDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Keyboard connected!");
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
}];
|
||||
_keyboardDisconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCKeyboardDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
Log(LOG_I, @"Keyboard disconnected!");
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
}];
|
||||
NSLog(@"device gyro codes,update gyroMode: %d, controller count: %lu", _gyroMode, (unsigned long)_controllers.count);
|
||||
|
||||
for(Controller* controller in _controllers) [self updateTimerStateForController:controller];
|
||||
if(_controllers.count == 0) [self updateTimerStateForController:_oscController];
|
||||
}
|
||||
}
|
||||
|
||||
-(id)initWithConfig:(StreamConfiguration*)streamConfig delegate:(id<ControllerSupportDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
_delegate = delegate;
|
||||
_controllerStreamLock = [[NSLock alloc] init];
|
||||
_controllers = [[NSMutableDictionary alloc] init];
|
||||
_controllerNumbers = 0;
|
||||
[self updateConfig:streamConfig delegate:delegate];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) connectionEstablished
|
||||
{
|
||||
for (Controller* controller in [_controllers allValues]) {
|
||||
-(void) connectionEstablished{
|
||||
for (Controller* controller in [_controllers allValues]){
|
||||
// Report the controller arrival to the host if we haven't done so yet
|
||||
[self reportControllerArrival:controller];
|
||||
[self updateTimerStateForController:controller];
|
||||
}
|
||||
//return;
|
||||
if(_controllers.count ==0 && (_gyroMode == GyroModeAuto || _gyroMode == AlwaysDevice)){
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)),
|
||||
dispatch_get_main_queue(), ^{
|
||||
[self setButtonFlag:self->_oscController flags:A_FLAG];
|
||||
[self updateFinished:self->_oscController];
|
||||
[self clearButtonFlag:self->_oscController flags:A_FLAG];
|
||||
[self updateFinished:self->_oscController];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)),
|
||||
dispatch_get_main_queue(), ^{
|
||||
[self->_delegate automaticallyStartSendingBuiltinGyroEvents]; // this will discontine any control events sent to the remote side for a instant. anyway it works out as signature describes
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -367,7 +367,8 @@ static CGRect streamViewBounds;
|
||||
buttonState.borderWidth = widgetView.borderWidth;
|
||||
buttonState.vibrationStyle = widgetView.vibrationStyle;
|
||||
buttonState.mouseButtonAction = widgetView.mouseButtonAction;
|
||||
buttonState.sensitivityFactor = widgetView.sensitivityFactor;
|
||||
buttonState.sensitivityFactorX = widgetView.sensitivityFactorX;
|
||||
buttonState.sensitivityFactorY = widgetView.sensitivityFactorY;
|
||||
buttonState.stickIndicatorOffset = widgetView.stickIndicatorOffset;
|
||||
buttonState.widgetShape = widgetView.shape;
|
||||
buttonState.minStickOffset = widgetView.minStickOffset;
|
||||
|
||||
@@ -30,7 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, assign) CGFloat widthFactor; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat heightFactor; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat borderWidth; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat sensitivityFactor; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat sensitivityFactorX; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat sensitivityFactorY; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat stickIndicatorOffset; // for OnScreenWidgetView
|
||||
@property (nonatomic, assign) CGFloat minStickOffset; // for OnScreenWidgetView
|
||||
@property NSString* widgetShape; // for OnScreenWidgetView
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
[encoder encodeBool:self.isHidden forKey:@"isHidden"];
|
||||
[encoder encodeFloat:self.widthFactor forKey:@"widthFactor"];
|
||||
[encoder encodeFloat:self.heightFactor forKey:@"heightFactor"];
|
||||
[encoder encodeFloat:self.sensitivityFactor forKey:@"velocityFactor"];
|
||||
[encoder encodeFloat:self.sensitivityFactorX forKey:@"sensitivityFactorX"];
|
||||
[encoder encodeFloat:self.sensitivityFactorY forKey:@"sensitivityFactorY"];
|
||||
[encoder encodeFloat:self.stickIndicatorOffset forKey:@"stickIndicatorOffset"];
|
||||
[encoder encodeFloat:self.oscLayerSizeFactor forKey:@"oscLayerSizeFactor"];
|
||||
[encoder encodeFloat:self.backgroundAlpha forKey:@"backgroundAlpha"];
|
||||
@@ -59,7 +60,8 @@
|
||||
self.isHidden = [decoder decodeBoolForKey:@"isHidden"];
|
||||
self.widthFactor = [decoder decodeFloatForKey:@"widthFactor"];
|
||||
self.heightFactor = [decoder decodeFloatForKey:@"heightFactor"];
|
||||
self.sensitivityFactor = [decoder decodeFloatForKey:@"velocityFactor"];
|
||||
self.sensitivityFactorX = [decoder decodeFloatForKey:@"sensitivityFactorX"];
|
||||
self.sensitivityFactorY = [decoder decodeFloatForKey:@"sensitivityFactorY"];
|
||||
self.stickIndicatorOffset = [decoder decodeFloatForKey:@"stickIndicatorOffset"];
|
||||
self.oscLayerSizeFactor = [decoder decodeFloatForKey:@"oscLayerSizeFactor"];
|
||||
self.backgroundAlpha = [decoder decodeFloatForKey:@"backgroundAlpha"];
|
||||
|
||||
@@ -86,8 +86,9 @@ import UIKit
|
||||
@objc public var stickBallLayer = CAShapeLayer()
|
||||
|
||||
// this is for all stick pads and mouse Pad
|
||||
@objc public var sensitivityFactor: CGFloat = 1.0
|
||||
|
||||
@objc public var sensitivityFactorX: CGFloat = 1.0
|
||||
@objc public var sensitivityFactorY: CGFloat = 1.0
|
||||
|
||||
// check quick double tap:
|
||||
private var quickDoubleTapDetected: Bool
|
||||
private var touchTapTimeInterval: TimeInterval
|
||||
@@ -213,7 +214,8 @@ import UIKit
|
||||
self.touchLockedForMoveEvent = UITouch()
|
||||
self.twoTouchesDetected = false
|
||||
self.stickIndicatorOffset = 95
|
||||
self.sensitivityFactor = 1.0
|
||||
self.sensitivityFactorX = 1.0
|
||||
self.sensitivityFactorY = 1.0
|
||||
super.init(frame: .zero)
|
||||
|
||||
upIndicator = createLrudDirectionLayer()
|
||||
@@ -564,8 +566,8 @@ import UIKit
|
||||
CATransaction.setDisableActions(true)
|
||||
self.stickBallLayer.removeAllAnimations()
|
||||
if !OnScreenWidgetView.editMode {
|
||||
let realOffsetX = touchInputToStickBallCoord(input: offSetX*sensitivityFactor)
|
||||
let realOffsetY = touchInputToStickBallCoord(input: offSetY*sensitivityFactor)
|
||||
let realOffsetX = touchInputToStickBallCoord(input: offSetX*sensitivityFactorX)
|
||||
let realOffsetY = touchInputToStickBallCoord(input: offSetY*sensitivityFactorY)
|
||||
self.stickBallLayer.position = CGPointMake(CGRectGetMidX(self.crossMarkLayer.frame) + realOffsetX, CGRectGetMidY(self.crossMarkLayer.frame) + realOffsetY)
|
||||
if fabs(realOffsetX) == stickBallMaxOffset || fabs(realOffsetY) == stickBallMaxOffset {
|
||||
handleStickBallReachingBorder()
|
||||
@@ -676,7 +678,7 @@ import UIKit
|
||||
case down = 8
|
||||
}
|
||||
|
||||
let nearZeroPoint = abs(offSetX) < 16/sensitivityFactor && abs(offSetY) < 16/sensitivityFactor
|
||||
let nearZeroPoint = abs(offSetX) < 16/sensitivityFactorX && abs(offSetY) < 16/sensitivityFactorY
|
||||
// NSLog("deltaX: %f, detalY: %f", deltaX, deltaY)
|
||||
|
||||
var buttonPressed = 0;
|
||||
@@ -1058,7 +1060,7 @@ import UIKit
|
||||
self.sendOscButtonDownEvent(keyString: self.cmdString)
|
||||
}
|
||||
if CommandManager.keyboardButtonMappings.keys.contains(self.cmdString) {
|
||||
LiSendKeyboardEvent(CommandManager.keyboardButtonMappings[self.cmdString]!,Int8(KEY_ACTION_DOWN), 0)
|
||||
LiSendLiSendKeyboardEvent(CommandManager.keyboardButtonMappings[self.cmdString]!,Int8(KEY_ACTION_DOWN), 0)
|
||||
}
|
||||
if CommandManager.mouseButtonMappings.keys.contains(self.cmdString) {
|
||||
LiSendMouseButtonEvent(CChar(BUTTON_ACTION_PRESS), Int32(CommandManager.mouseButtonMappings[self.cmdString]!))
|
||||
@@ -1146,30 +1148,30 @@ import UIKit
|
||||
case "MOUSEPAD":
|
||||
DispatchQueue.global(qos: .userInteractive).async {
|
||||
self.updateTouchLocation(touch: touches.first!)
|
||||
LiSendMouseMoveEvent(Int16(truncatingIfNeeded: Int(self.deltaX * 1.7 * self.sensitivityFactor)), Int16(truncatingIfNeeded: Int(self.deltaY * 1.7 * self.sensitivityFactor)))
|
||||
LiSendMouseMoveEvent(Int16(truncatingIfNeeded: Int(self.deltaX * 1.7 * self.sensitivityFactorX)), Int16(truncatingIfNeeded: Int(self.deltaY * 1.7 * self.sensitivityFactorY)))
|
||||
}
|
||||
break
|
||||
case "LSPAD":
|
||||
self.updateTouchLocation(touch: touches.first!)
|
||||
DispatchQueue.global(qos: .userInteractive).async {
|
||||
self.sendLeftStickTouchPadEvent(inputX: self.offSetX * self.sensitivityFactor, inputY: self.offSetY * self.sensitivityFactor)
|
||||
self.sendLeftStickTouchPadEvent(inputX: self.offSetX * self.sensitivityFactorX, inputY: self.offSetY * self.sensitivityFactorY)
|
||||
}
|
||||
if widgetType == WidgetTypeEnum.touchPad {updateStickIndicator()}
|
||||
case "RSPAD":
|
||||
self.updateTouchLocation(touch: touches.first!)
|
||||
DispatchQueue.global(qos: .userInteractive).async {
|
||||
self.sendRightStickTouchPadEvent(inputX: self.offSetX * self.sensitivityFactor, inputY: self.offSetY * self.sensitivityFactor)
|
||||
self.sendRightStickTouchPadEvent(inputX: self.offSetX * self.sensitivityFactorX, inputY: self.offSetY * self.sensitivityFactorY)
|
||||
}
|
||||
if widgetType == WidgetTypeEnum.touchPad {updateStickIndicator()}
|
||||
case "LSVPAD":
|
||||
DispatchQueue.global(qos: .userInteractive).async {
|
||||
self.updateTouchLocation(touch: touches.first!)
|
||||
self.sendLeftStickTouchPadEvent(inputX: self.deltaX*1.5167*self.sensitivityFactor, inputY: self.deltaY*1.5167*self.sensitivityFactor)
|
||||
self.sendLeftStickTouchPadEvent(inputX: self.deltaX*1.5167*self.sensitivityFactorX, inputY: self.deltaY*1.5167*self.sensitivityFactorY)
|
||||
}
|
||||
case "RSVPAD":
|
||||
DispatchQueue.global(qos: .userInteractive).async {
|
||||
self.updateTouchLocation(touch: touches.first!)
|
||||
self.sendRightStickTouchPadEvent(inputX: self.deltaX*1.5167*self.sensitivityFactor, inputY: self.deltaY*1.5167*self.sensitivityFactor)
|
||||
self.sendRightStickTouchPadEvent(inputX: self.deltaX*1.5167*self.sensitivityFactorX, inputY: self.deltaY*1.5167*self.sensitivityFactorY)
|
||||
}
|
||||
case "DPAD", "WASDPAD", "ARROWPAD":
|
||||
self.updateTouchLocation(touch: touches.first!)
|
||||
|
||||
@@ -404,7 +404,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
widgetView.borderWidth = buttonState.borderWidth;
|
||||
[widgetView setVibrationWithStyle:buttonState.vibrationStyle];
|
||||
widgetView.mouseButtonAction = buttonState.mouseButtonAction;
|
||||
widgetView.sensitivityFactor = buttonState.sensitivityFactor;
|
||||
widgetView.sensitivityFactorX = buttonState.sensitivityFactorX;
|
||||
widgetView.sensitivityFactorY = buttonState.sensitivityFactorY;
|
||||
widgetView.stickIndicatorOffset = buttonState.stickIndicatorOffset;
|
||||
widgetView.minStickOffset = buttonState.minStickOffset;
|
||||
// Add the widgetView to the view controller's view
|
||||
|
||||
@@ -3391,25 +3391,48 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Sensitivity: %.2f" : {
|
||||
"SensitivityX: %.2f" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "灵敏度: %.2f"
|
||||
"value" : "灵敏度X: %.2f"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "灵敏度: %.2f"
|
||||
"value" : "灵敏度X: %.2f"
|
||||
}
|
||||
},
|
||||
"zh-HK" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "灵敏度: %.2f"
|
||||
"value" : "灵敏度X: %.2f"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SensitivityY: %.2f" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "灵敏度Y: %.2f"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "灵敏度Y: %.2f"
|
||||
}
|
||||
},
|
||||
"zh-HK" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "灵敏度Y: %.2f"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -71,9 +71,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (weak, nonatomic) IBOutlet UISlider *stickIndicatorOffsetSlider;
|
||||
@property (weak, nonatomic) IBOutlet UIStackView *stickIndicatorOffsetStack;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel *sensitivityLabel;
|
||||
@property (weak, nonatomic) IBOutlet UISlider *sensitivitySlider;
|
||||
@property (weak, nonatomic) IBOutlet UIStackView *sensitivityStack;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *sensitivityXLabel;
|
||||
@property (weak, nonatomic) IBOutlet UISlider *sensitivityXSlider;
|
||||
@property (weak, nonatomic) IBOutlet UIStackView *sensitivityXStack;
|
||||
@property (strong, nonatomic) IBOutlet UILabel *sensitivityYLabel;
|
||||
@property (strong, nonatomic) IBOutlet UISlider *sensitivityYSlider;
|
||||
@property (strong, nonatomic) IBOutlet UIStackView *sensitivityYStack;
|
||||
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UISegmentedControl *vibrationStyleSelector;
|
||||
@property (strong, nonatomic) IBOutlet UIStackView *vibrationStyleStack;
|
||||
|
||||
+32
-12
@@ -109,7 +109,8 @@
|
||||
widgetView.borderWidth = buttonState.borderWidth;
|
||||
[widgetView setVibrationWithStyle:buttonState.vibrationStyle];
|
||||
widgetView.mouseButtonAction = buttonState.mouseButtonAction;
|
||||
widgetView.sensitivityFactor = buttonState.sensitivityFactor;
|
||||
widgetView.sensitivityFactorX = buttonState.sensitivityFactorX;
|
||||
widgetView.sensitivityFactorY = buttonState.sensitivityFactorY;
|
||||
widgetView.stickIndicatorOffset = buttonState.stickIndicatorOffset;
|
||||
widgetView.minStickOffset = buttonState.minStickOffset;
|
||||
// Add the widgetView to the view controller's view
|
||||
@@ -561,7 +562,8 @@
|
||||
newWidget.widthFactor = widget.widthFactor;
|
||||
newWidget.heightFactor = widget.heightFactor;
|
||||
newWidget.borderWidth = widget.borderWidth;
|
||||
newWidget.sensitivityFactor = widget.sensitivityFactor;
|
||||
newWidget.sensitivityFactorX = widget.sensitivityFactorX;
|
||||
newWidget.sensitivityFactorY = widget.sensitivityFactorY;
|
||||
newWidget.stickIndicatorOffset = widget.stickIndicatorOffset;
|
||||
newWidget.minStickOffset = [widgetInitParams[@"minStickOffsetString"] floatValue];
|
||||
[newWidget setVibrationWithStyle:widget.vibrationStyle];
|
||||
@@ -659,14 +661,16 @@
|
||||
bool showSensitivityFactorSlider = selectedWidgetView.hasSensitivityTweak;
|
||||
bool showStickIndicatorOffsetSlider = selectedWidgetView.hasStickIndicator;
|
||||
|
||||
self.sensitivityStack.hidden = !showSensitivityFactorSlider;
|
||||
self.sensitivityXStack.hidden = self.sensitivityYStack.hidden = !showSensitivityFactorSlider;
|
||||
self.stickIndicatorOffsetStack.hidden = !showStickIndicatorOffsetSlider;
|
||||
self.mouseDownButtonStack.hidden = !([selectedWidgetView.cmdString containsString:@"MOUSEPAD"] && selectedWidgetView.widgetType == WidgetTypeEnumTouchPad);
|
||||
[self autoFitView:self.widgetPanelStack];
|
||||
|
||||
if(showSensitivityFactorSlider){
|
||||
[self.sensitivitySlider setValue:self->selectedWidgetView.sensitivityFactor];
|
||||
[self.sensitivityLabel setText:[LocalizationHelper localizedStringForKey:@"Sensitivity: %.2f", self->selectedWidgetView.sensitivityFactor]];
|
||||
[self.sensitivityXSlider setValue:self->selectedWidgetView.sensitivityFactorX];
|
||||
[self.sensitivityXLabel setText:[LocalizationHelper localizedStringForKey:@"SensitivityX: %.2f", self->selectedWidgetView.sensitivityFactorX]];
|
||||
[self.sensitivityYSlider setValue:self->selectedWidgetView.sensitivityFactorY];
|
||||
[self.sensitivityYLabel setText:[LocalizationHelper localizedStringForKey:@"SensitivityY: %.2f", self->selectedWidgetView.sensitivityFactorY]];
|
||||
}
|
||||
if(showStickIndicatorOffsetSlider){
|
||||
// illustrating the indicator offset,
|
||||
@@ -701,7 +705,8 @@
|
||||
self->selectedWidgetView = nil;
|
||||
|
||||
self.stickIndicatorOffsetStack.hidden = true;
|
||||
self.sensitivityStack.hidden = true;
|
||||
self.sensitivityXStack.hidden = self.sensitivityYStack.hidden = true;
|
||||
self.mouseDownButtonStack.hidden = true;
|
||||
|
||||
self->controllerLayerSelected = true;
|
||||
self->selectedControllerLayer = controllerLayer;
|
||||
@@ -798,9 +803,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sensitivitySliderMoved:(UISlider* )sender{
|
||||
[self.sensitivityLabel setText:[LocalizationHelper localizedStringForKey:@"Sensitivity: %.2f", sender.value]];
|
||||
if(self->selectedWidgetView != nil && self->widgetViewSelected) self->selectedWidgetView.sensitivityFactor = sender.value;
|
||||
- (void)sensitivityXSliderMoved:(UISlider* )sender{
|
||||
[self.sensitivityXLabel setText:[LocalizationHelper localizedStringForKey:@"SensitivityX: %.2f", sender.value]];
|
||||
[self.sensitivityYLabel setText:[LocalizationHelper localizedStringForKey:@"SensitivityY: %.2f", sender.value]];
|
||||
[self.sensitivityYSlider setValue:sender.value];
|
||||
if(self->selectedWidgetView != nil && self->widgetViewSelected){
|
||||
self->selectedWidgetView.sensitivityFactorX = sender.value;
|
||||
self->selectedWidgetView.sensitivityFactorY = sender.value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)sensitivityYSliderMoved:(UISlider* )sender{
|
||||
[self.sensitivityYLabel setText:[LocalizationHelper localizedStringForKey:@"SensitivityY: %.2f", sender.value]];
|
||||
if(self->selectedWidgetView != nil && self->widgetViewSelected) self->selectedWidgetView.sensitivityFactorY = sender.value;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -883,10 +899,14 @@
|
||||
self.widgetBorderWidthLabel.text = [LocalizationHelper localizedStringForKey:@"Border Width"];
|
||||
self.borderWidthAlphaStack.hidden = YES;
|
||||
|
||||
[self.sensitivitySlider addTarget:self action:@selector(sensitivitySliderMoved:) forControlEvents:(UIControlEventValueChanged)];
|
||||
self.sensitivityLabel.text = [LocalizationHelper localizedStringForKey:@"Sensitivity"];
|
||||
self.sensitivityStack.hidden = YES;
|
||||
[self.sensitivityXSlider addTarget:self action:@selector(sensitivityXSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
|
||||
self.sensitivityXLabel.text = [LocalizationHelper localizedStringForKey:@"SensitivityX"];
|
||||
self.sensitivityXStack.hidden = YES;
|
||||
|
||||
[self.sensitivityYSlider addTarget:self action:@selector(sensitivityYSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
|
||||
self.sensitivityYLabel.text = [LocalizationHelper localizedStringForKey:@"SensitivityY"];
|
||||
self.sensitivityYStack.hidden = YES;
|
||||
|
||||
// stick indicator offset slider
|
||||
//self.stickIndicatorOffsetSlider.hidden = YES;
|
||||
[self.stickIndicatorOffsetSlider addTarget:self action:@selector(stickIndicatorOffsetSliderMoved:) forControlEvents:(UIControlEventValueChanged)];
|
||||
|
||||
@@ -30,5 +30,6 @@
|
||||
|
||||
|
||||
-(void)updatePreferredDisplayMode:(BOOL)streamActive;
|
||||
-(void)reConfigStreamViewRealtime;
|
||||
|
||||
@end
|
||||
|
||||
@@ -215,7 +215,10 @@
|
||||
NSLog(@"streamview gestures: %d", (uint32_t)[_streamView.gestureRecognizers count]);
|
||||
}
|
||||
|
||||
|
||||
-(void)automaticallyStartSendingBuiltinGyroEvents{
|
||||
[_controllerSupport updateConfig: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 streamFrameTopLayerView:self.view]; //reinitiate setupStreamView process.
|
||||
}
|
||||
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
|
||||
@@ -2077,6 +2077,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"NZO-BM-nef.text" : {
|
||||
"comment" : "Class = \"UILabel\"; text = \"test\"; ObjectID = \"NZO-BM-nef\";",
|
||||
"extractionState" : "extracted_with_value",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"OOg-A3-DdM.segmentTitles[0]" : {
|
||||
"comment" : "Class = \"UISegmentedControl\"; OOg-A3-DdM.segmentTitles[0] = \"Lowest Latency\"; ObjectID = \"OOg-A3-DdM\";",
|
||||
"extractionState" : "extracted_with_value",
|
||||
|
||||
+1894
-1810
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user