Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6db518f4b9 | ||
|
|
c0fc1becb7 | ||
|
|
70e5b3520c | ||
|
|
ebec9877b0 | ||
|
|
d9a5d8aaac | ||
|
|
e58d05a85b | ||
|
|
3efddab070 | ||
|
|
a17a27005d | ||
|
|
a8f7f4679b | ||
|
|
11c0119944 | ||
|
|
80804ee7ac | ||
|
|
06e80823b8 | ||
|
|
ecda390dc0 | ||
|
|
481c443211 | ||
|
|
80b7b8eaec | ||
|
|
1e33fc7935 | ||
|
|
6b42d271ba | ||
|
|
7823d1a60b | ||
|
|
d23c4a5795 | ||
|
|
c91c40e79f | ||
|
|
5302f418db | ||
|
|
6370bc187a | ||
|
|
3e2dc4989e | ||
|
|
715cb86ab9 | ||
|
|
cf375eae84 | ||
|
|
4d4ab333f4 | ||
|
|
ca04c62ecd | ||
|
|
34f632e7e4 | ||
|
|
4f952b5daa | ||
|
|
edcb9cf275 | ||
|
|
ac44efbbbe | ||
|
|
e0a81dbd34 | ||
|
|
301c8580c8 | ||
|
|
9b9b278a14 | ||
|
|
31c6569910 | ||
|
|
ed3a837200 | ||
|
|
9cfa5f35cb | ||
|
|
cc13b60411 | ||
|
|
caa4fccabd | ||
|
|
4ba33002dd | ||
|
|
ef418be2df | ||
|
|
b7d8889180 | ||
|
|
18fe545533 | ||
|
|
87208b07a5 | ||
|
|
c713eafac0 | ||
|
|
d493cba990 | ||
|
|
ae188fd999 | ||
|
|
5747656be7 | ||
|
|
4e85d3d079 | ||
|
|
e2bd8b1512 | ||
|
|
422c34f945 | ||
|
|
8d0b646fbe | ||
|
|
2c4a7cc055 | ||
|
|
54a31689f7 | ||
|
|
6bf967b9d2 | ||
|
|
b6abd71392 | ||
|
|
8506640d7f | ||
|
|
592b7acfc4 | ||
|
|
858843ff9a | ||
|
|
9ffeba72fe | ||
|
|
4074823e4e | ||
|
|
b99172d932 | ||
|
|
017b03d200 | ||
|
|
ea12dd3c47 | ||
|
|
2b98543125 | ||
|
|
a0f13881bf | ||
|
|
62ae63d7f6 | ||
|
|
589ca19e4f | ||
|
|
b1785b1fa5 | ||
|
|
3fc26d279a | ||
|
|
bde477558f | ||
|
|
b5afe1fe29 | ||
|
|
8b2470faf8 | ||
|
|
7fcc3d0013 | ||
|
|
153b6ce6fe | ||
|
|
777c825cca | ||
|
|
33a8e02c5f | ||
|
|
c797c9db1a | ||
|
|
766e30a066 | ||
|
|
3894d92f1b | ||
|
|
2be2ffbcb6 | ||
|
|
570dff2696 | ||
|
|
be13295096 | ||
|
|
ea89d0a822 | ||
|
|
d7bb9483e4 | ||
|
|
7699e47157 | ||
|
|
978c50c271 | ||
|
|
0f5e644041 | ||
|
|
c5e891eceb | ||
|
|
147b2ce045 | ||
|
|
9553ec3d96 | ||
|
|
890d3fbfe1 | ||
|
|
b9ea8cc1a9 | ||
|
|
141c9ee2ab | ||
|
|
f1811ca53d | ||
|
|
5bf163f40c | ||
|
|
395647cff9 | ||
|
|
3f3ffdca13 | ||
|
|
34659cac70 | ||
|
|
d8820df26e | ||
|
|
6495bad6fe | ||
|
|
f918779fc8 | ||
|
|
8999fd625d | ||
|
|
113aaa1b81 | ||
|
|
ec29679c02 | ||
|
|
962d19f3cb | ||
|
|
3bec2d6e65 | ||
|
|
571812062f | ||
|
|
c4801f9889 | ||
|
|
ada2e6f480 | ||
|
|
fadf023563 | ||
|
|
5db6aa0695 | ||
|
|
1ca71bbc11 | ||
|
|
39b8429998 | ||
|
|
e05b626d51 | ||
|
|
146ca2353d | ||
|
|
6d5c5fb0c2 | ||
|
|
3d5885f5bd | ||
|
|
888ecad4d3 | ||
|
|
b3a64fdf0f | ||
|
|
dc8e361b6b | ||
|
|
15bc488f71 | ||
|
|
22b4cc6222 | ||
|
|
f5c03f8045 | ||
|
|
0a47becdc6 | ||
|
|
e4d264cc83 | ||
|
|
7c455b0daa | ||
|
|
d2a1add105 | ||
|
|
dcdfbc7394 | ||
|
|
2b5a1c0551 | ||
|
|
cb034b96a4 | ||
|
|
e741f83c06 | ||
|
|
b192360ef3 | ||
|
|
a028191c82 | ||
|
|
c6b27ad0e0 | ||
|
|
1d1d4cbddf | ||
|
|
747997f46c | ||
|
|
805cf517bb | ||
|
|
ea78b434d5 | ||
|
|
69f5fbef31 | ||
|
|
db75cac9bc | ||
|
|
ba4af74a9d | ||
|
|
fb474237ee | ||
|
|
d476f5d75b | ||
|
|
8720847f54 | ||
|
|
a12bd80cc1 | ||
|
|
ab3c551357 | ||
|
|
a1a7047370 | ||
|
|
29e43979a7 | ||
|
|
6b25de1361 | ||
|
|
53e68258f3 | ||
|
|
6e3c982a22 | ||
|
|
f0e812e9e2 | ||
|
|
9ff10135a8 | ||
|
|
9618b7bb94 | ||
|
|
fd768db70b | ||
|
|
3c5b6ba795 | ||
|
|
add09210ba | ||
|
|
6065b4f742 | ||
|
|
d90bf747fc | ||
|
|
ec8095ea9d | ||
|
|
b11849e45b | ||
|
|
e2f09d711d | ||
|
|
04b68e3a61 | ||
|
|
b21b93ff71 | ||
|
|
9f9df09c61 | ||
|
|
c7700904e0 | ||
|
|
a8b45851cc | ||
|
|
bf1a30505f | ||
|
|
7a55fee258 | ||
|
|
abc7805aab | ||
|
|
98db99b3ff | ||
|
|
07d08918a3 | ||
|
|
8371c9fedd | ||
|
|
b106e60880 | ||
|
|
81c04bc2b2 | ||
|
|
945a4c67e4 | ||
|
|
95644075ec | ||
|
|
19adb5e106 | ||
|
|
ff789200b9 | ||
|
|
b53b0784aa | ||
|
|
69056332d3 | ||
|
|
f5342caca6 | ||
|
|
039bf549a9 | ||
|
|
ea9e335a36 | ||
|
|
46e3f85903 | ||
|
|
b00d836c13 | ||
|
|
b587279450 | ||
|
|
279ef707d5 | ||
|
|
7e8be94530 | ||
|
|
c8262da5d7 | ||
|
|
81beb35809 | ||
|
|
eb302e5d19 | ||
|
|
9c54168173 | ||
|
|
3eb233ffe2 | ||
|
|
cf21ca9503 | ||
|
|
b6ecdcd0ea | ||
|
|
a975b0e24a | ||
|
|
84b198ed29 | ||
|
|
4cff75c531 | ||
|
|
916e9b65a6 | ||
|
|
eb6adea47c | ||
|
|
458daddf38 | ||
|
|
ea98fe1fbf | ||
|
|
c3b7814542 | ||
|
|
abe414765e | ||
|
|
9a93022478 | ||
|
|
033265d58e | ||
|
|
2bcdd25cc2 | ||
|
|
c38dfc2c20 | ||
|
|
ef5c77d8df | ||
|
|
b05c3c7e4a | ||
|
|
606ec51108 | ||
|
|
3dbc97701d | ||
|
|
31b3df08cc | ||
|
|
01718282ff | ||
|
|
1b5f414c89 | ||
|
|
a441670591 | ||
|
|
7c0f9b65f1 | ||
|
|
837a75c477 | ||
|
|
0a449c25eb | ||
|
|
88d5038f94 | ||
|
|
2de3197ca9 | ||
|
|
c72accb3cb | ||
|
|
00d89f12e8 | ||
|
|
565e31983c | ||
|
|
06aa772a02 | ||
|
|
a5b1cd6c99 | ||
|
|
d84be68f4c | ||
|
|
e01b51bf37 | ||
|
|
9c6bf5c16f | ||
|
|
9bf4ba9af9 | ||
|
|
a37c7ed8f8 | ||
|
|
36ba82dd16 | ||
|
|
802f8714ef | ||
|
|
bf6cf21084 | ||
|
|
30df8aec8a | ||
|
|
84bffdd287 | ||
|
|
6c4b5321e1 | ||
|
|
14ef07f072 | ||
|
|
52c2a831d9 | ||
|
|
d427270699 | ||
|
|
b25f2d0916 | ||
|
|
56fc18c378 | ||
|
|
38343c20cb | ||
|
|
6f1773d512 | ||
|
|
d9fc1fc5c9 | ||
|
|
3ad8b0db71 | ||
|
|
a021784d48 | ||
|
|
072f7bdffb | ||
|
|
b8a3aa5d8c | ||
|
|
ee91177ca6 | ||
|
|
3f02a76c3d | ||
|
|
c88753c7e9 | ||
|
|
94addc69f7 | ||
|
|
b4cfe21074 | ||
|
|
8437c8ada1 | ||
|
|
0a5109823c | ||
|
|
e863a5df6a | ||
|
|
547eb1c85d | ||
|
|
63c853d4ce | ||
|
|
329c9b7b92 | ||
|
|
0789a2f27e | ||
|
|
382116ab21 | ||
|
|
7290bff594 | ||
|
|
8b57c448ef | ||
|
|
e5cf54e92f | ||
|
|
34d9875ff3 | ||
|
|
070fbc8b52 | ||
|
|
9d57c22757 | ||
|
|
93f1a2b4fb | ||
|
|
a156962259 | ||
|
|
9d8fbf789f | ||
|
|
0d91be217b | ||
|
|
91a8fdc392 | ||
|
|
b79a762ce1 | ||
|
|
46770f4588 | ||
|
|
aae87d1684 | ||
|
|
0bac5f1ae9 | ||
|
|
457a4e8725 | ||
|
|
a5c8224023 | ||
|
|
001deeee66 | ||
|
|
7847299c77 | ||
|
|
ac77447066 | ||
|
|
f09c7be18d | ||
|
|
ee4eb35fe3 | ||
|
|
8834f492b4 | ||
|
|
f2cf788d86 | ||
|
|
c3c7e670fc | ||
|
|
c3d44647f9 | ||
|
|
115d540b7d | ||
|
|
ec4299fd88 | ||
|
|
c6785e3728 | ||
|
|
b2e4d45025 | ||
|
|
4170376945 | ||
|
|
01d2a937ca | ||
|
|
4e3be8513d | ||
|
|
c8f0d8bf0b | ||
|
|
bfe02ed6a3 | ||
|
|
3442df0ca4 | ||
|
|
b85a1e9c07 | ||
|
|
e7fd911fb8 | ||
|
|
d673c4900c | ||
|
|
49fb6dbbd6 | ||
|
|
5c88787401 | ||
|
|
873269e410 | ||
|
|
6740a7130b |
@@ -0,0 +1,45 @@
|
||||
name: Build IPAs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "noWaterMark" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build IPAs
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Checkout submodules
|
||||
run: "git submodule update --init --recursive"
|
||||
|
||||
- name: Build FullScreen Version
|
||||
run: |
|
||||
plutil -replace UIRequiresFullScreen -bool true Limelight/Limelight-Info.plist
|
||||
xcodebuild -verbose -scheme Moonlight-ZWM -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MoonlightFullScreen.xcarchive CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED="NO" CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
|
||||
mkdir -p ./build/IPA_FullScreen && mkdir -p ./build/IPA_FullScreen/Payload
|
||||
cp -r ./build/MoonlightFullScreen.xcarchive/Products/Applications/Moonlight-ZWM.app ./build/IPA_FullScreen/Payload/Moonlight-ZWM.app
|
||||
cd ./build/IPA_FullScreen && zip -r ../../build/Moonlight-ZWM_FullScreen.ipa ./Payload/* && cd ../..
|
||||
|
||||
- name: Upload FullScreen IPA to Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Moonlight-ZWM_FullScreen.ipa
|
||||
path: build/Moonlight-ZWM_FullScreen.ipa
|
||||
|
||||
- name: Build StageManager Version
|
||||
run: |
|
||||
plutil -replace UIRequiresFullScreen -bool false Limelight/Limelight-Info.plist
|
||||
xcodebuild -verbose -scheme Moonlight-ZWM -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MoonlightStageManager.xcarchive CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED="NO" CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
|
||||
mkdir -p ./build/IPA_StageManager && mkdir -p ./build/IPA_StageManager/Payload
|
||||
cp -r ./build/MoonlightStageManager.xcarchive/Products/Applications/Moonlight-ZWM.app ./build/IPA_StageManager/Payload/Moonlight-ZWM.app
|
||||
cd ./build/IPA_StageManager && zip -r ../../build/Moonlight-ZWM_StageManager.ipa ./Payload/* && cd ../..
|
||||
|
||||
- name: Upload StageManager IPA to Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Moonlight-ZWM_StageManager.ipa
|
||||
path: build/Moonlight-ZWM_StageManager.ipa
|
||||
@@ -3,3 +3,4 @@
|
||||
**/xcschemes/*.xcscheme
|
||||
Build
|
||||
DerivedData
|
||||
*.xccheckout
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "MainFrameViewController.h"
|
||||
#import "Moonlight-Swift.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
@@ -22,17 +24,34 @@ static NSString* DB_NAME = @"Moonlight_tvOS.bin";
|
||||
static NSString* DB_NAME = @"Limelight_iOS.sqlite";
|
||||
#endif
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
UIApplicationShortcutItem* shortcut = [launchOptions valueForKey:UIApplicationLaunchOptionsShortcutItemKey];
|
||||
if (shortcut != nil) {
|
||||
_pcUuidToLoad = (NSString*)[shortcut.userInfo objectForKey:@"UUID"];
|
||||
|
||||
/*
|
||||
// orietation limitatioin test
|
||||
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
|
||||
UIViewController *topController = window.rootViewController;
|
||||
while (topController.presentedViewController) {
|
||||
topController = topController.presentedViewController;
|
||||
}
|
||||
#endif
|
||||
return [topController supportedInterfaceOrientations];
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
|
||||
NSLog(@"orientation limit");
|
||||
return UIInterfaceOrientationMaskLandscape;
|
||||
}
|
||||
*/
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for command tool customization after application launch (works only when user default is nil)
|
||||
[CommandManager presetDefaultCommands];
|
||||
return YES;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
|
||||
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler {
|
||||
_pcUuidToLoad = (NSString*)[shortcutItem.userInfo objectForKey:@"UUID"];
|
||||
_shortcutCompletionHandler = completionHandler;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef Limelight_mkcert_h
|
||||
#define Limelight_mkcert_h
|
||||
|
||||
#include <sys/_types/_time_t.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/pkcs12.h>
|
||||
|
||||
|
||||
@@ -17,25 +17,45 @@
|
||||
framerate:(NSInteger)framerate
|
||||
height:(NSInteger)height
|
||||
width:(NSInteger)width
|
||||
audioConfig:(NSInteger)audioConfig
|
||||
audioConfig:(NSInteger)audioConfig
|
||||
onscreenControls:(NSInteger)onscreenControls
|
||||
keyboardToggleFingers:(NSInteger)keyboardToggleFingers
|
||||
oscLayoutToolFingers:(NSInteger)oscLayoutToolFingers
|
||||
slideToSettingsScreenEdge:(NSInteger)slideToSettingsScreenEdge
|
||||
slideToSettingsDistance:(CGFloat)slideToSettingsDistance
|
||||
pointerVelocityModeDivider:(CGFloat)pointerVelocityModeDivider
|
||||
touchPointerVelocityFactor:(CGFloat)touchPointerVelocityFactor
|
||||
mousePointerVelocityFactor:(CGFloat)mousePointerVelocityFactor
|
||||
oscTapExlusionAreaSize:(CGFloat)oscTapExlusionAreaSize
|
||||
reverseMouseWheelDirection:(BOOL)reverseMouseWheelDirection
|
||||
largerStickLR1:(BOOL)largerStickLR1
|
||||
liftStreamViewForKeyboard:(BOOL)liftStreamViewForKeyboard
|
||||
showKeyboardToolbar:(BOOL)showKeyboardToolbar
|
||||
optimizeGames:(BOOL)optimizeGames
|
||||
multiController:(BOOL)multiController
|
||||
swapABXYButtons:(BOOL)swapABXYButtons
|
||||
audioOnPC:(BOOL)audioOnPC
|
||||
preferredCodec:(uint32_t)preferredCodec
|
||||
enableYUV444:(BOOL)enableYUV444
|
||||
useFramePacing:(BOOL)useFramePacing
|
||||
enableHdr:(BOOL)enableHdr
|
||||
btMouseSupport:(BOOL)btMouseSupport
|
||||
absoluteTouchMode:(BOOL)absoluteTouchMode
|
||||
statsOverlay:(BOOL)statsOverlay;
|
||||
// absoluteTouchMode:(BOOL)absoluteTouchMode
|
||||
touchMode:(NSInteger)touchMode
|
||||
statsOverlayLevel:(NSInteger)statsOverlayLevel
|
||||
statsOverlayEnabled:(BOOL)statsOverlayEnabled
|
||||
unlockDisplayOrientation:(BOOL)unlockDisplayOrientation
|
||||
resolutionSelected:(NSInteger)resolutionSelected
|
||||
externalDisplayMode:(NSInteger)externalDisplayMode
|
||||
localMousePointerMode:(NSInteger)localMousePointerMode;
|
||||
|
||||
- (NSArray*) getHosts;
|
||||
- (void) updateHost:(TemporaryHost*)host;
|
||||
- (void) updateAppsForExistingHost:(TemporaryHost *)host;
|
||||
- (void) removeHost:(TemporaryHost*)host;
|
||||
- (void) removeApp:(TemporaryApp*)app;
|
||||
|
||||
- (Settings*) retrieveSettings;
|
||||
- (void) saveData;
|
||||
- (TemporarySettings*) getSettings;
|
||||
|
||||
- (void) updateUniqueId:(NSString*)uniqueId;
|
||||
|
||||
@@ -58,16 +58,35 @@
|
||||
width:(NSInteger)width
|
||||
audioConfig:(NSInteger)audioConfig
|
||||
onscreenControls:(NSInteger)onscreenControls
|
||||
keyboardToggleFingers:(NSInteger)keyboardToggleFingers
|
||||
oscLayoutToolFingers:(NSInteger)oscLayoutToolFingers
|
||||
slideToSettingsScreenEdge:(NSInteger)slideToSettingsScreenEdge
|
||||
slideToSettingsDistance:(CGFloat)slideToSettingsDistance
|
||||
pointerVelocityModeDivider:(CGFloat)pointerVelocityModeDivider
|
||||
touchPointerVelocityFactor:(CGFloat)touchPointerVelocityFactor
|
||||
mousePointerVelocityFactor:(CGFloat)mousePointerVelocityFactor
|
||||
oscTapExlusionAreaSize:(CGFloat)oscTapExlusionAreaSize
|
||||
reverseMouseWheelDirection:(BOOL)reverseMouseWheelDirection
|
||||
largerStickLR1:(BOOL)largerStickLR1
|
||||
liftStreamViewForKeyboard:(BOOL)liftStreamViewForKeyboard
|
||||
showKeyboardToolbar:(BOOL)showKeyboardToolbar
|
||||
optimizeGames:(BOOL)optimizeGames
|
||||
multiController:(BOOL)multiController
|
||||
swapABXYButtons:(BOOL)swapABXYButtons
|
||||
audioOnPC:(BOOL)audioOnPC
|
||||
preferredCodec:(uint32_t)preferredCodec
|
||||
enableYUV444:(BOOL)enableYUV444
|
||||
useFramePacing:(BOOL)useFramePacing
|
||||
enableHdr:(BOOL)enableHdr
|
||||
btMouseSupport:(BOOL)btMouseSupport
|
||||
absoluteTouchMode:(BOOL)absoluteTouchMode
|
||||
statsOverlay:(BOOL)statsOverlay {
|
||||
// absoluteTouchMode:(BOOL)absoluteTouchMode
|
||||
touchMode:(NSInteger)touchMode
|
||||
statsOverlayLevel:(NSInteger)statsOverlayLevel
|
||||
statsOverlayEnabled:(BOOL)statsOverlayEnabled
|
||||
unlockDisplayOrientation:(BOOL)unlockDisplayOrientation
|
||||
resolutionSelected:(NSInteger)resolutionSelected
|
||||
externalDisplayMode:(NSInteger)externalDisplayMode
|
||||
localMousePointerMode:(NSInteger)localMousePointerMode {
|
||||
|
||||
[_managedObjectContext performBlockAndWait:^{
|
||||
Settings* settingsToSave = [self retrieveSettings];
|
||||
@@ -77,17 +96,35 @@
|
||||
settingsToSave.width = [NSNumber numberWithInteger:width];
|
||||
settingsToSave.audioConfig = [NSNumber numberWithInteger:audioConfig];
|
||||
settingsToSave.onscreenControls = [NSNumber numberWithInteger:onscreenControls];
|
||||
settingsToSave.keyboardToggleFingers = [NSNumber numberWithInteger:(uint16_t)keyboardToggleFingers];
|
||||
settingsToSave.oscLayoutToolFingers = [NSNumber numberWithInteger:(uint16_t)oscLayoutToolFingers];
|
||||
settingsToSave.slideToSettingsScreenEdge = [NSNumber numberWithInteger:(uint32_t)slideToSettingsScreenEdge];
|
||||
settingsToSave.slideToSettingsDistance = [NSNumber numberWithFloat:slideToSettingsDistance];
|
||||
settingsToSave.pointerVelocityModeDivider = [NSNumber numberWithFloat:pointerVelocityModeDivider];
|
||||
settingsToSave.touchPointerVelocityFactor = [NSNumber numberWithFloat:touchPointerVelocityFactor];
|
||||
settingsToSave.mousePointerVelocityFactor = [NSNumber numberWithFloat:mousePointerVelocityFactor];
|
||||
settingsToSave.oscTapExlusionAreaSize = [NSNumber numberWithFloat:oscTapExlusionAreaSize];
|
||||
settingsToSave.reverseMouseWheelDirection = reverseMouseWheelDirection;
|
||||
settingsToSave.largerStickLR1 = largerStickLR1;
|
||||
settingsToSave.liftStreamViewForKeyboard = liftStreamViewForKeyboard;
|
||||
settingsToSave.showKeyboardToolbar = showKeyboardToolbar;
|
||||
settingsToSave.optimizeGames = optimizeGames;
|
||||
settingsToSave.multiController = multiController;
|
||||
settingsToSave.swapABXYButtons = swapABXYButtons;
|
||||
settingsToSave.playAudioOnPC = audioOnPC;
|
||||
settingsToSave.preferredCodec = preferredCodec;
|
||||
settingsToSave.enableYUV444 = enableYUV444;
|
||||
settingsToSave.useFramePacing = useFramePacing;
|
||||
settingsToSave.enableHdr = enableHdr;
|
||||
settingsToSave.btMouseSupport = btMouseSupport;
|
||||
settingsToSave.absoluteTouchMode = absoluteTouchMode;
|
||||
settingsToSave.statsOverlay = statsOverlay;
|
||||
|
||||
// settingsToSave.absoluteTouchMode = absoluteTouchMode;
|
||||
settingsToSave.touchMode = [NSNumber numberWithInteger:(uint16_t)touchMode];
|
||||
settingsToSave.statsOverlayEnabled = statsOverlayEnabled;
|
||||
settingsToSave.statsOverlayLevel = [NSNumber numberWithInteger:(uint16_t)statsOverlayLevel];
|
||||
settingsToSave.unlockDisplayOrientation = unlockDisplayOrientation;
|
||||
settingsToSave.resolutionSelected = [NSNumber numberWithInteger:resolutionSelected];
|
||||
settingsToSave.externalDisplayMode = [NSNumber numberWithInteger:externalDisplayMode];
|
||||
settingsToSave.localMousePointerMode = [NSNumber numberWithInteger:localMousePointerMode];
|
||||
[self saveData];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
self.externalAddress = host.externalAddress;
|
||||
self.localAddress = host.localAddress;
|
||||
self.ipv6Address = host.ipv6Address;
|
||||
self.mac = host.mac;
|
||||
if(!(host.mac == nil || [host.mac isEqualToString:@"00:00:00:00:00:00"])) self.mac = host.mac; // try to fix invalid mac happens in some cases
|
||||
self.name = host.name;
|
||||
self.uuid = host.uuid;
|
||||
self.serverCodecModeSupport = host.serverCodecModeSupport;
|
||||
@@ -70,9 +70,9 @@
|
||||
if (self.ipv6Address != nil) {
|
||||
parentHost.ipv6Address = self.ipv6Address;
|
||||
}
|
||||
if (self.mac != nil) {
|
||||
parentHost.mac = self.mac;
|
||||
}
|
||||
// try to fix invalid mac happens in some cases
|
||||
// 添加主机crash问题重点关注
|
||||
if (!(self.mac == nil || [self.mac isEqualToString:@"00:00:00:00:00:00"])) parentHost.mac = self.mac;
|
||||
if (self.serverCert != nil) {
|
||||
parentHost.serverCert = self.serverCert;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
//
|
||||
|
||||
#import "Settings+CoreDataClass.h"
|
||||
#define RELATIVE_TOUCH 0
|
||||
#define REGULAR_NATIVE_TOUCH 1
|
||||
#define PURE_NATIVE_TOUCH 2
|
||||
#define ABSOLUTE_TOUCH 3
|
||||
#define OSC_TOOL_FINGERS 4
|
||||
|
||||
|
||||
@interface TemporarySettings : NSObject
|
||||
|
||||
@@ -18,13 +24,27 @@
|
||||
@property (nonatomic, retain) NSNumber * width;
|
||||
@property (nonatomic, retain) NSNumber * audioConfig;
|
||||
@property (nonatomic, retain) NSNumber * onscreenControls;
|
||||
@property (nonatomic, retain) NSNumber * keyboardToggleFingers;
|
||||
@property (nonatomic, retain) NSNumber * oscLayoutToolFingers;
|
||||
@property (nonatomic, retain) NSNumber * slideToSettingsScreenEdge;
|
||||
@property (nonatomic, retain) NSNumber * slideToSettingsDistance;
|
||||
@property (nonatomic, retain) NSNumber * oscTapExlusionAreaSize;
|
||||
@property (nonatomic, retain) NSNumber * touchPointerVelocityFactor;
|
||||
@property (nonatomic, retain) NSNumber * mousePointerVelocityFactor;
|
||||
@property (nonatomic, retain) NSNumber * pointerVelocityModeDivider;
|
||||
@property (nonatomic, retain) NSString * uniqueId;
|
||||
@property (nonatomic, retain) NSNumber * resolutionSelected;
|
||||
@property (nonatomic, retain) NSNumber * externalDisplayMode;
|
||||
@property (nonatomic, retain) NSNumber * localMousePointerMode;
|
||||
@property (nonatomic) enum {
|
||||
CODEC_PREF_AUTO,
|
||||
CODEC_PREF_H264,
|
||||
CODEC_PREF_HEVC,
|
||||
CODEC_PREF_AV1,
|
||||
} preferredCodec;
|
||||
@property (nonatomic) BOOL enableYUV444;
|
||||
@property (nonatomic) BOOL reverseMouseWheelDirection;
|
||||
@property (nonatomic) BOOL largerStickLR1;
|
||||
@property (nonatomic) BOOL useFramePacing;
|
||||
@property (nonatomic) BOOL multiController;
|
||||
@property (nonatomic) BOOL swapABXYButtons;
|
||||
@@ -32,8 +52,13 @@
|
||||
@property (nonatomic) BOOL optimizeGames;
|
||||
@property (nonatomic) BOOL enableHdr;
|
||||
@property (nonatomic) BOOL btMouseSupport;
|
||||
@property (nonatomic) BOOL absoluteTouchMode;
|
||||
@property (nonatomic) BOOL statsOverlay;
|
||||
// @property (nonatomic) BOOL absoluteTouchMode;
|
||||
@property (nonatomic, retain) NSNumber * touchMode;
|
||||
@property (nonatomic, retain) NSNumber * statsOverlayLevel;
|
||||
@property (nonatomic) BOOL statsOverlayEnabled;
|
||||
@property (nonatomic) BOOL liftStreamViewForKeyboard;
|
||||
@property (nonatomic) BOOL showKeyboardToolbar;
|
||||
@property (nonatomic) BOOL unlockDisplayOrientation;
|
||||
|
||||
- (id) initFromSettings:(Settings*)settings;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
self.audioConfig = [NSNumber numberWithInteger:[[NSUserDefaults standardUserDefaults] integerForKey:@"audioConfig"]];
|
||||
assert([self.audioConfig intValue] != 0);
|
||||
self.preferredCodec = (typeof(self.preferredCodec))[[NSUserDefaults standardUserDefaults] integerForKey:@"preferredCodec"];
|
||||
self.enableYUV444 = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableYUV444"];
|
||||
self.useFramePacing = [[NSUserDefaults standardUserDefaults] integerForKey:@"useFramePacing"] != 0;
|
||||
self.playAudioOnPC = [[NSUserDefaults standardUserDefaults] boolForKey:@"audioOnPC"];
|
||||
self.enableHdr = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableHdr"];
|
||||
@@ -75,6 +76,7 @@
|
||||
self.width = settings.width;
|
||||
self.audioConfig = settings.audioConfig;
|
||||
self.preferredCodec = settings.preferredCodec;
|
||||
self.enableYUV444 = settings.enableYUV444;
|
||||
self.useFramePacing = settings.useFramePacing;
|
||||
self.playAudioOnPC = settings.playAudioOnPC;
|
||||
self.enableHdr = settings.enableHdr;
|
||||
@@ -82,9 +84,27 @@
|
||||
self.multiController = settings.multiController;
|
||||
self.swapABXYButtons = settings.swapABXYButtons;
|
||||
self.onscreenControls = settings.onscreenControls;
|
||||
self.reverseMouseWheelDirection = settings.reverseMouseWheelDirection;
|
||||
self.largerStickLR1 = settings.largerStickLR1;
|
||||
self.btMouseSupport = settings.btMouseSupport;
|
||||
self.absoluteTouchMode = settings.absoluteTouchMode;
|
||||
self.statsOverlay = settings.statsOverlay;
|
||||
// self.absoluteTouchMode = settings.absoluteTouchMode;
|
||||
self.touchMode = settings.touchMode;
|
||||
self.statsOverlayLevel = settings.statsOverlayLevel;
|
||||
self.statsOverlayEnabled = settings.statsOverlayEnabled;
|
||||
self.keyboardToggleFingers = settings.keyboardToggleFingers;
|
||||
self.oscLayoutToolFingers = settings.oscLayoutToolFingers;
|
||||
self.slideToSettingsScreenEdge = settings.slideToSettingsScreenEdge;
|
||||
self.slideToSettingsDistance = settings.slideToSettingsDistance;
|
||||
self.liftStreamViewForKeyboard = settings.liftStreamViewForKeyboard;
|
||||
self.showKeyboardToolbar = settings.showKeyboardToolbar;
|
||||
self.oscTapExlusionAreaSize = settings.oscTapExlusionAreaSize;
|
||||
self.touchPointerVelocityFactor = settings.touchPointerVelocityFactor;
|
||||
self.mousePointerVelocityFactor = settings.mousePointerVelocityFactor;
|
||||
self.pointerVelocityModeDivider = settings.pointerVelocityModeDivider;
|
||||
self.unlockDisplayOrientation = settings.unlockDisplayOrientation;
|
||||
self.resolutionSelected = settings.resolutionSelected;
|
||||
self.externalDisplayMode = settings.externalDisplayMode;
|
||||
self.localMousePointerMode = settings.localMousePointerMode;
|
||||
#endif
|
||||
self.uniqueId = settings.uniqueId;
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "a_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "arrow_uturn_backward_square-80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "arrow_uturn_backward_square-120x120@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "arrow_uturn_backward_square_fill-80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "arrow_uturn_backward_square_fill-120x120.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "b_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "chevron_compact_down@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "chevron_compact_down@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 848 B |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "chevron_compact_up@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "chevron_compact_up@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 833 B |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "DownButtonHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "l1_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "l2_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "LeftButtonHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "OSCLayoutExit_80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "OSCLayoutExit_120x120@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 831 B |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "r1_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "r2_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "RightButtonHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "SelectButtonHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "square_and_arrow_down-80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "square_and_arrow_down-120x120@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "square_and_arrow_up_on_square-80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "square_and_arrow_up_on_square-120x120@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 950 B |
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x",
|
||||
"filename" : "stick_inner_48x49@1x.png"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x",
|
||||
"filename" : "stick_inner_96x97@2x.png"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x",
|
||||
"filename" : "stick_inner_144x146@3x.png"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "StartButtonHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "StickInnerHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "StickOuterHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "trash_square-80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "trash_square-120x120@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "trash_square_fill-80x80@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "trash_square_fill-120x120@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "UpButtonHD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "x_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "y_button_HD.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -23,18 +23,32 @@
|
||||
#define DOUBLE_TAP_DEAD_ZONE_DELTA 0.025f
|
||||
|
||||
@implementation AbsoluteTouchHandler {
|
||||
StreamView* view;
|
||||
StreamView* streamView;
|
||||
|
||||
NSTimer* longPressTimer;
|
||||
UITouch* lastTouchDown;
|
||||
CGPoint lastTouchDownLocation;
|
||||
UITouch* lastTouchUp;
|
||||
CGPoint lastTouchUpLocation;
|
||||
|
||||
// upper screen edge check
|
||||
bool touchPointSpawnedAtUpperScreenEdge;
|
||||
CGFloat slideGestureVerticalThreshold;
|
||||
CGFloat screenWidthWithThreshold;
|
||||
CGFloat EDGE_TOLERANCE;
|
||||
|
||||
}
|
||||
|
||||
- (id)initWithView:(StreamView*)view {
|
||||
self = [self init];
|
||||
self->view = view;
|
||||
self->streamView = view;
|
||||
|
||||
// upper screen check
|
||||
EDGE_TOLERANCE = 15.0;
|
||||
slideGestureVerticalThreshold = CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.4;
|
||||
screenWidthWithThreshold = CGRectGetWidth([[UIScreen mainScreen] bounds]) - EDGE_TOLERANCE;
|
||||
self->touchPointSpawnedAtUpperScreenEdge = false;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -45,19 +59,28 @@
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
CGPoint initialPoint = [[touches anyObject] locationInView:streamView];
|
||||
if(initialPoint.y < slideGestureVerticalThreshold && (initialPoint.x < EDGE_TOLERANCE || initialPoint.x > screenWidthWithThreshold)) {
|
||||
self->touchPointSpawnedAtUpperScreenEdge = true;
|
||||
return; // we're done here. this touch event will not be sent to the remote PC.
|
||||
}
|
||||
|
||||
touchPointSpawnedAtUpperScreenEdge = false; // reset this flag immediately if we get a touch event passing the check above, this fixes irresponsive touch after closing the command tool menu.
|
||||
|
||||
// Ignore touch down events with more than one finger
|
||||
if ([[event allTouches] count] > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
UITouch* touch = [touches anyObject];
|
||||
CGPoint touchLocation = [touch locationInView:view];
|
||||
CGPoint touchLocation = [touch locationInView:streamView];
|
||||
|
||||
// Don't reposition for finger down events within the deadzone. This makes double-clicking easier.
|
||||
if (touch.timestamp - lastTouchUp.timestamp > DOUBLE_TAP_DEAD_ZONE_DELAY ||
|
||||
sqrt(pow((touchLocation.x / view.bounds.size.width) - (lastTouchUpLocation.x / view.bounds.size.width), 2) +
|
||||
pow((touchLocation.y / view.bounds.size.height) - (lastTouchUpLocation.y / view.bounds.size.height), 2)) > DOUBLE_TAP_DEAD_ZONE_DELTA) {
|
||||
[view updateCursorLocation:touchLocation isMouse:NO];
|
||||
sqrt(pow((touchLocation.x / streamView.bounds.size.width) - (lastTouchUpLocation.x / streamView.bounds.size.width), 2) +
|
||||
pow((touchLocation.y / streamView.bounds.size.height) - (lastTouchUpLocation.y / streamView.bounds.size.height), 2)) > DOUBLE_TAP_DEAD_ZONE_DELTA) {
|
||||
[streamView updateCursorLocation:touchLocation isMouse:NO];
|
||||
}
|
||||
|
||||
// Press the left button down
|
||||
@@ -75,25 +98,31 @@
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
if(touchPointSpawnedAtUpperScreenEdge) return; // we're done here. this touch event will not be sent to the remote PC.
|
||||
|
||||
// Ignore touch move events with more than one finger
|
||||
if ([[event allTouches] count] > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
UITouch* touch = [touches anyObject];
|
||||
CGPoint touchLocation = [touch locationInView:view];
|
||||
CGPoint touchLocation = [touch locationInView:streamView];
|
||||
|
||||
if (sqrt(pow((touchLocation.x / view.bounds.size.width) - (lastTouchDownLocation.x / view.bounds.size.width), 2) +
|
||||
pow((touchLocation.y / view.bounds.size.height) - (lastTouchDownLocation.y / view.bounds.size.height), 2)) > LONG_PRESS_ACTIVATION_DELTA) {
|
||||
if (sqrt(pow((touchLocation.x / streamView.bounds.size.width) - (lastTouchDownLocation.x / streamView.bounds.size.width), 2) +
|
||||
pow((touchLocation.y / streamView.bounds.size.height) - (lastTouchDownLocation.y / streamView.bounds.size.height), 2)) > LONG_PRESS_ACTIVATION_DELTA) {
|
||||
// Moved too far since touch down. Cancel the long press timer.
|
||||
[longPressTimer invalidate];
|
||||
longPressTimer = nil;
|
||||
}
|
||||
|
||||
[view updateCursorLocation:[[touches anyObject] locationInView:view] isMouse:NO];
|
||||
[streamView updateCursorLocation:[[touches anyObject] locationInView:streamView] isMouse:NO];
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
if(touchPointSpawnedAtUpperScreenEdge) return; // we're done here. this touch event will not be sent to the remote PC.
|
||||
|
||||
// Only fire this logic if all touches have ended
|
||||
if ([[event allTouches] count] == [touches count]) {
|
||||
// Cancel the long press timer
|
||||
@@ -108,7 +137,7 @@
|
||||
|
||||
// Remember this last touch for touch-down deadzoning
|
||||
lastTouchUp = [touches anyObject];
|
||||
lastTouchUpLocation = [lastTouchUp locationInView:view];
|
||||
lastTouchUpLocation = [lastTouchUp locationInView:streamView];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,492 @@
|
||||
//
|
||||
// KeyManager.swift
|
||||
// Moonlight-ZWM
|
||||
//
|
||||
// Created by ZWM on 2024/7/23.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
// Define the RemoteCommand class
|
||||
@objc public class RemoteCommand: NSObject, NSSecureCoding {
|
||||
// MARK: - NSSecureCoding
|
||||
|
||||
public static var supportsSecureCoding: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@objc var keyboardCmdString: String
|
||||
@objc var alias: String
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
init(keyboardCmdString: String, alias: String) {
|
||||
self.keyboardCmdString = keyboardCmdString
|
||||
self.alias = alias
|
||||
}
|
||||
|
||||
// MARK: - NSSecureCoding
|
||||
|
||||
required public init?(coder: NSCoder) {
|
||||
guard let keyboardCmdString = coder.decodeObject(of: NSString.self, forKey: "keyboardCmdString") as String?,
|
||||
let alias = coder.decodeObject(of: NSString.self, forKey: "alias") as String? else {
|
||||
return nil
|
||||
}
|
||||
self.keyboardCmdString = keyboardCmdString
|
||||
self.alias = alias
|
||||
}
|
||||
|
||||
public func encode(with coder: NSCoder) {
|
||||
coder.encode(keyboardCmdString, forKey: "keyboardCmdString")
|
||||
coder.encode(alias, forKey: "alias")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Define the CommandManager class
|
||||
@objc public class CommandManager: NSObject {
|
||||
@objc public static let shared = CommandManager()
|
||||
|
||||
@objc public static let mouseButtonMappings: [String: Int32] = ["M_LEFT" : BUTTON_LEFT,
|
||||
"M_MIDDLE" : BUTTON_MIDDLE,
|
||||
"M_RIGHT" : BUTTON_RIGHT,
|
||||
"M_X1" : BUTTON_X1,
|
||||
"M_X2" : BUTTON_X2]
|
||||
|
||||
@objc public static let oscButtonMappings: [String: Int32] = ["OSCA" : A_FLAG,
|
||||
"OSCB" : B_FLAG,
|
||||
"OSCX" : X_FLAG,
|
||||
"OSCY" : Y_FLAG,
|
||||
"OSCL1" : LB_FLAG,
|
||||
"OSCR1" : RB_FLAG,
|
||||
"OSCL3" : LS_CLK_FLAG,
|
||||
"OSCR3" : RS_CLK_FLAG,
|
||||
"OSCSTART" : PLAY_FLAG,
|
||||
"OSCSELECT" : BACK_FLAG,
|
||||
"OSCUP" : UP_FLAG,
|
||||
"OSCDOWN" : DOWN_FLAG,
|
||||
"OSCLEFT" : LEFT_FLAG,
|
||||
"OSCRIGHT" : RIGHT_FLAG,
|
||||
"OSCL2" : 0,
|
||||
"OSCR2" : 0]
|
||||
|
||||
@objc public static let oscRectangleButtonCmds: [String] = [
|
||||
"OSCUP",
|
||||
"OSCDOWN",
|
||||
"OSCLEFT",
|
||||
"OSCRIGHT",
|
||||
"OSCSTART",
|
||||
"OSCSELECT"]
|
||||
|
||||
@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 nonVectorStickPads: [String] = ["LSPAD", "RSPAD"]
|
||||
@objc public static let specialOverlayButtonCmds: [String] = ["SETTINGS"]
|
||||
|
||||
static let keyboardButtonMappings: [String: Int16] = [
|
||||
// Windows Key Codes
|
||||
"CTRL": 0x11, // VK_CONTROL
|
||||
"SHIFT": 0x10, // VK_SHIFT
|
||||
"ALT": 0x12, // VK_MENU
|
||||
"F1": 0x70, // VK_F1
|
||||
"F2": 0x71, // VK_F2
|
||||
"F3": 0x72, // VK_F3
|
||||
"F4": 0x73, // VK_F4
|
||||
"F5": 0x74, // VK_F5
|
||||
"F6": 0x75, // VK_F6
|
||||
"F7": 0x76, // VK_F7
|
||||
"F8": 0x77, // VK_F8
|
||||
"F9": 0x78, // VK_F9
|
||||
"F10": 0x79, // VK_F10
|
||||
"F11": 0x7A, // VK_F11
|
||||
"F12": 0x7B, // VK_F12
|
||||
"A": 0x41, // 'A' key
|
||||
"B": 0x42, // 'B' key
|
||||
"C": 0x43, // 'C' key
|
||||
"D": 0x44, // 'D' key
|
||||
"E": 0x45, // 'E' key
|
||||
"F": 0x46, // 'F' key
|
||||
"G": 0x47, // 'G' key
|
||||
"H": 0x48, // 'H' key
|
||||
"I": 0x49, // 'I' key
|
||||
"J": 0x4A, // 'J' key
|
||||
"K": 0x4B, // 'K' key
|
||||
"L": 0x4C, // 'L' key
|
||||
"M": 0x4D, // 'M' key
|
||||
"N": 0x4E, // 'N' key
|
||||
"O": 0x4F, // 'O' key
|
||||
"P": 0x50, // 'P' key
|
||||
"Q": 0x51, // 'Q' key
|
||||
"R": 0x52, // 'R' key
|
||||
"S": 0x53, // 'S' key
|
||||
"T": 0x54, // 'T' key
|
||||
"U": 0x55, // 'U' key
|
||||
"V": 0x56, // 'V' key
|
||||
"W": 0x57, // 'W' key
|
||||
"X": 0x58, // 'X' key
|
||||
"Y": 0x59, // 'Y' key
|
||||
"Z": 0x5A, // 'Z' key
|
||||
"0": 0x30, // '0' key
|
||||
"1": 0x31, // '1' key
|
||||
"2": 0x32, // '2' key
|
||||
"3": 0x33, // '3' key
|
||||
"4": 0x34, // '4' key
|
||||
"5": 0x35, // '5' key
|
||||
"6": 0x36, // '6' key
|
||||
"7": 0x37, // '7' key
|
||||
"8": 0x38, // '8' key
|
||||
"9": 0x39, // '9' key
|
||||
"ESC": 0x1B, // VK_ESCAPE
|
||||
"SPACE": 0x20, // VK_SPACE
|
||||
"ENTER": 0x0D, // VK_RETURN
|
||||
"TAB": 0x09, // VK_TAB
|
||||
"BACKSPACE": 0x08, // VK_BACK
|
||||
"INSERT": 0x2D, // VK_INSERT
|
||||
"DEL": 0x2E, // VK_DELETE
|
||||
"HOME": 0x24, // VK_HOME
|
||||
"END": 0x23, // VK_END
|
||||
"PG_UP": 0x21, // VK_PRIOR
|
||||
"PG_DOWN": 0x22, // VK_NEXT
|
||||
"UP_ARROW": 0x26, // VK_UP
|
||||
"DOWN_ARROW": 0x28, // VK_DOWN
|
||||
"LEFT_ARROW": 0x25, // VK_LEFT
|
||||
"RIGHT_ARROW": 0x27, // VK_RIGHT
|
||||
"NUM_LCK": 0x90, // VK_NUMLOCK
|
||||
"SCR_LCK": 0x91, // VK_SCROLL
|
||||
"CAPS_LOCK": 0x14, // VK_CAPITAL
|
||||
"PAUSE": 0x13, // VK_PAUSE
|
||||
"PR_SCR": 0x2C, // VK_SNAPSHOT
|
||||
"NUMPAD0": 0x60, // VK_NUMPAD0
|
||||
"NUMPAD1": 0x61, // VK_NUMPAD1
|
||||
"NUMPAD2": 0x62, // VK_NUMPAD2
|
||||
"NUMPAD3": 0x63, // VK_NUMPAD3
|
||||
"NUMPAD4": 0x64, // VK_NUMPAD4
|
||||
"NUMPAD5": 0x65, // VK_NUMPAD5
|
||||
"NUMPAD6": 0x66, // VK_NUMPAD6
|
||||
"NUMPAD7": 0x67, // VK_NUMPAD7
|
||||
"NUMPAD8": 0x68, // VK_NUMPAD8
|
||||
"NUMPAD9": 0x69, // VK_NUMPAD9
|
||||
"MULTIPLY": 0x6A, // VK_MULTIPLY
|
||||
"ADD": 0x6B, // VK_ADD
|
||||
"SUBTRACT": 0x6D, // VK_SUBTRACT
|
||||
"DECIMAL": 0x6E, // VK_DECIMAL
|
||||
"DIVIDE": 0x6F, // VK_DIVIDE
|
||||
"SEMI_COLON": 0xBA, // VK_OEM_1
|
||||
"EQUALS": 0xBB, // VK_OEM_PLUS
|
||||
"COMMA": 0xBC, // VK_OEM_COMMA
|
||||
"MINUS": 0xBD, // VK_OEM_MINUS
|
||||
"PERIOD": 0xBE, // VK_OEM_PERIOD
|
||||
"FORWARD_SLASH": 0xBF, // VK_OEM_2
|
||||
"GRAVE_ACCENT": 0xC0, // VK_OEM_3
|
||||
"OPEN_BRACKET": 0xDB, // VK_OEM_4
|
||||
"BACKSLASH": 0xDC, // VK_OEM_5
|
||||
"CLOSE_BRACKET": 0xDD, // VK_OEM_6
|
||||
"SINGLE_QUOTE": 0xDE, // VK_OEM_7
|
||||
"VOLUME_MUTE": 0xAD, // VK_VOLUME_MUTE
|
||||
"VOLUME_DOWN": 0xAE, // VK_VOLUME_DOWN
|
||||
"VOLUME_UP": 0xAF, // VK_VOLUME_UP
|
||||
"MEDIA_NEXT": 0xB0, // VK_MEDIA_NEXT_TRACK
|
||||
"MEDIA_PREV": 0xB1, // VK_MEDIA_PREV_TRACK
|
||||
"MEDIA_STOP": 0xB2, // VK_MEDIA_STOP
|
||||
"MEDIA_PLAY_PAUSE": 0xB3, // VK_MEDIA_PLAY_PAUSE
|
||||
"LAUNCH_MAIL": 0xB4, // VK_LAUNCH_MAIL
|
||||
"LAUNCH_MEDIA_SELECT": 0xB5, // VK_LAUNCH_MEDIA_SELECT
|
||||
"LAUNCH_APP1": 0xB6, // VK_LAUNCH_APP1
|
||||
"LAUNCH_APP2": 0xB7, // VK_LAUNCH_APP2
|
||||
"WIN": 0x5B,
|
||||
"LEFT_WIN": 0x5B, // VK_LWIN
|
||||
"RIGHT_WIN": 0x5C, // VK_RWIN
|
||||
"APPS": 0x5D, // VK_APPS
|
||||
|
||||
// macOS Key Codes
|
||||
"CMD": 0x37, // ⌘ Command
|
||||
"OPT": 0x3A, // ⌥ Option
|
||||
"CONTROL": 0x3B, // ⌃ Control
|
||||
"SHIFT_MAC": 0x38, // ⇧ Shift
|
||||
"FUNCTION": 0x3F, // fn
|
||||
"DELETE_MAC": 0x75, // Forward Delete
|
||||
"RETURN_MAC": 0x24, // Return
|
||||
"ENTER_MAC": 0x4C, // Enter
|
||||
"ESCAPE_MAC": 0x35, // Escape
|
||||
"TAB_MAC": 0x30, // Tab
|
||||
"SPACE_MAC": 0x31, // Space
|
||||
"UP_ARROW_MAC": 0x7E, // Up Arrow
|
||||
"DOWN_ARROW_MAC": 0x7D, // Down Arrow
|
||||
"LEFT_ARROW_MAC": 0x7B, // Left Arrow
|
||||
"RIGHT_ARROW_MAC": 0x7C, // Right Arrow
|
||||
"F1_MAC": 0x7A, // F1
|
||||
"F2_MAC": 0x78, // F2
|
||||
"F3_MAC": 0x63, // F3
|
||||
"F4_MAC": 0x76, // F4
|
||||
"F5_MAC": 0x60, // F5
|
||||
"F6_MAC": 0x61, // F6
|
||||
"F7_MAC": 0x62, // F7
|
||||
"F8_MAC": 0x64, // F8
|
||||
"F9_MAC": 0x65, // F9
|
||||
"F10_MAC": 0x6D, // F10
|
||||
"F11_MAC": 0x67, // F11
|
||||
"F12_MAC": 0x6F, // F12
|
||||
"0_MAC": 0x52, // 0
|
||||
"1_MAC": 0x53, // 1
|
||||
"2_MAC": 0x54, // 2
|
||||
"3_MAC": 0x55, // 3
|
||||
"4_MAC": 0x56, // 4
|
||||
"5_MAC": 0x57, // 5
|
||||
"6_MAC": 0x58, // 6
|
||||
"7_MAC": 0x59, // 7
|
||||
"8_MAC": 0x5A, // 8
|
||||
"9_MAC": 0x5B, // 9
|
||||
"NUMPAD0_MAC": 0x4F, // Numpad 0
|
||||
"NUMPAD1_MAC": 0x50, // Numpad 1
|
||||
"NUMPAD2_MAC": 0x51, // Numpad 2
|
||||
"NUMPAD3_MAC": 0x52, // Numpad 3
|
||||
"NUMPAD4_MAC": 0x53, // Numpad 4
|
||||
"NUMPAD5_MAC": 0x54, // Numpad 5
|
||||
"NUMPAD6_MAC": 0x55, // Numpad 6
|
||||
"NUMPAD7_MAC": 0x56, // Numpad 7
|
||||
"NUMPAD8_MAC": 0x57, // Numpad 8
|
||||
"NUMPAD9_MAC": 0x58, // Numpad 9
|
||||
"NUMPAD_ADD_MAC": 0x45, // Numpad Add
|
||||
"NUMPAD_SUBTRACT_MAC": 0x4A, // Numpad Subtract
|
||||
"NUMPAD_MULTIPLY_MAC": 0x43, // Numpad Multiply
|
||||
"NUMPAD_DIVIDE_MAC": 0x4B, // Numpad Divide
|
||||
"NUMPAD_DECIMAL_MAC": 0x41, // Numpad Decimal
|
||||
]
|
||||
|
||||
private var commands: [RemoteCommand] = []
|
||||
|
||||
public weak var viewController: CommandManagerViewController?
|
||||
|
||||
private override init() {
|
||||
super.init()
|
||||
loadCommands()
|
||||
}
|
||||
|
||||
@objc static func presetDefaultCommands() {
|
||||
let defaults = UserDefaults.standard
|
||||
//if true { // save default entries if the data is empty.
|
||||
if defaults.data(forKey: "savedCommands") == nil { // save default entries if the data is empty.
|
||||
let defaultCommands: [RemoteCommand] = [
|
||||
RemoteCommand(keyboardCmdString: "WIN", alias: "WIN"),
|
||||
RemoteCommand(keyboardCmdString: "F11", alias: "F11"),
|
||||
RemoteCommand(keyboardCmdString: "ESC", alias: "ESC"),
|
||||
RemoteCommand(keyboardCmdString: "CTRL+SHIFT+ESC", alias: "任务管理器(Task Manager)"),
|
||||
RemoteCommand(keyboardCmdString: "ALT+F1", alias: "N卡截图(Nvidia Screenshot)"),
|
||||
RemoteCommand(keyboardCmdString: "ALT+F9", alias: "N卡录屏(Nvidia Screen Recording)"),
|
||||
RemoteCommand(keyboardCmdString: "ALT+F4", alias: "关闭窗口(ALT+F4)"),
|
||||
RemoteCommand(keyboardCmdString: "CTRL+A", alias: "全选(Select All)"),
|
||||
RemoteCommand(keyboardCmdString: "CTRL+C", alias: "复制(Copy)"),
|
||||
RemoteCommand(keyboardCmdString: "CTRL+V", alias: "粘贴(Paste)"),
|
||||
RemoteCommand(keyboardCmdString: "WIN+D", alias: "切换桌面(Switch to Desktop)"),
|
||||
RemoteCommand(keyboardCmdString: "WIN+P", alias: "多显模式(Project)"),
|
||||
RemoteCommand(keyboardCmdString: "WIN+G", alias: "Xbox Game Bar"),
|
||||
RemoteCommand(keyboardCmdString: "SHIFT+TAB", alias: "Steam Overlay"),
|
||||
]
|
||||
|
||||
let data = try? NSKeyedArchiver.archivedData(withRootObject: defaultCommands, requiringSecureCoding: false)
|
||||
defaults.set(data, forKey: "savedCommands")
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func createTestKeyMappings() -> [String: Int16] {
|
||||
return CommandManager.keyboardButtonMappings
|
||||
}
|
||||
|
||||
// extractKeyStrings from keyboardCMDString
|
||||
@objc public func extractKeyStringsFromComboCommand(from input: String) -> [String]? {
|
||||
let keys = CommandManager.keyboardButtonMappings.keys.joined(separator: "|")
|
||||
let pattern = "^(?:(\(keys))(?:\\+(\(keys))*)*)$"
|
||||
|
||||
guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else {
|
||||
print("Failed to create regex")
|
||||
return nil
|
||||
}
|
||||
let range = NSRange(location: 0, length: input.utf16.count)
|
||||
guard let match = regex.firstMatch(in: input, options: [], range: range) else {
|
||||
print("No match found for input: \(input)")
|
||||
return nil
|
||||
}
|
||||
print("Regex matched for input: \(input)")
|
||||
|
||||
let matchedString = (input as NSString).substring(with: match.range(at: 0))
|
||||
let keyStrings = matchedString.split(separator: "+").map { String($0) }
|
||||
|
||||
guard !keyStrings.isEmpty else {
|
||||
print("No key strings found in the matched string")
|
||||
return nil
|
||||
}
|
||||
|
||||
var validKeyStrings: [String] = []
|
||||
|
||||
for key in keyStrings {
|
||||
if CommandManager.keyboardButtonMappings.keys.contains(key) {
|
||||
validKeyStrings.append(key)
|
||||
} else {
|
||||
print(" '\(key)' is not defined in key mappings")
|
||||
return nil //treat any illegal string as a whole
|
||||
}
|
||||
}
|
||||
|
||||
if validKeyStrings.isEmpty {
|
||||
print("No valid key strings found in the matched string")
|
||||
return nil
|
||||
}
|
||||
|
||||
for (index, key) in validKeyStrings.enumerated() {
|
||||
print("Valid Key \(index): \(key)")
|
||||
}
|
||||
|
||||
return validKeyStrings
|
||||
|
||||
}
|
||||
|
||||
//super combo key button strings
|
||||
@objc public func extractKeyStringsFromComboKeys(from input: String) -> [String]? {
|
||||
let combinedStrings = [CommandManager.keyboardButtonMappings.keys.map { $0 as String },
|
||||
CommandManager.oscButtonMappings.keys.map { $0 as String },
|
||||
CommandManager.mouseButtonMappings.keys.map { $0 as String }]
|
||||
.lazy // 零内存开销
|
||||
.flatMap { $0 } // 三维展开
|
||||
.map(String.init(describing:)) // 安全类型转换
|
||||
|
||||
let keys = combinedStrings.joined(separator: "|")
|
||||
// print(keys)
|
||||
let pattern = "^(?:(\(keys))(?:\\-(\(keys))*)*)$"
|
||||
|
||||
guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else {
|
||||
print("Failed to create regex")
|
||||
return nil
|
||||
}
|
||||
let range = NSRange(location: 0, length: input.utf16.count)
|
||||
guard let match = regex.firstMatch(in: input, options: [], range: range) else {
|
||||
print("No match found for input: \(input)")
|
||||
return nil
|
||||
}
|
||||
print("Regex matched for input: \(input)")
|
||||
|
||||
let matchedString = (input as NSString).substring(with: match.range(at: 0))
|
||||
let keyStrings = matchedString.split(separator: "-").map { String($0) }
|
||||
|
||||
guard !keyStrings.isEmpty else {
|
||||
print("No key strings found in the matched string")
|
||||
return nil
|
||||
}
|
||||
|
||||
var validKeyStrings: [String] = []
|
||||
|
||||
for key in keyStrings {
|
||||
validKeyStrings.append(key)
|
||||
}
|
||||
|
||||
if validKeyStrings.isEmpty {
|
||||
print("No valid key strings found in the matched string")
|
||||
return nil
|
||||
}
|
||||
|
||||
for (index, key) in validKeyStrings.enumerated() {
|
||||
print("Valid Key \(index): \(key)")
|
||||
}
|
||||
|
||||
return validKeyStrings
|
||||
}
|
||||
|
||||
@objc public func addCommand(_ command: RemoteCommand) -> Bool {
|
||||
command.keyboardCmdString = command.keyboardCmdString.uppercased() // convert all letters to upper case
|
||||
if(command.alias.trimmingCharacters(in: .whitespacesAndNewlines).count == 0) {command.alias = command.keyboardCmdString} // copy cmd string as alias when alias is empty
|
||||
let keyStrings = extractKeyStringsFromComboCommand(from: command.keyboardCmdString)
|
||||
if (keyStrings == nil) {return false} // in case of non-keyboard command strings, return false
|
||||
commands.append(command)
|
||||
saveCommands()
|
||||
viewController?.reloadTableView() // don't know why but this reload has to be called from the CommandManager, doesn't work by calling it in the viewcontroller, probably related with the dialog box.
|
||||
return true
|
||||
}
|
||||
|
||||
@objc public func deleteCommand(at index: Int) {
|
||||
guard index >= 0 && index < commands.count else {
|
||||
return
|
||||
}
|
||||
commands.remove(at: index)
|
||||
saveCommands()
|
||||
}
|
||||
|
||||
@objc public func getAllCommands() -> [RemoteCommand] {
|
||||
return commands
|
||||
}
|
||||
|
||||
private func loadCommands() {
|
||||
if let savedCommandsData = UserDefaults.standard.data(forKey: "savedCommands") {
|
||||
do {
|
||||
// Attempt to unarchive the data into an array of RemoteCommand
|
||||
if let savedCommands = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSArray.self, RemoteCommand.self], from: savedCommandsData) as? [RemoteCommand] {
|
||||
// Assign the unarchived commands to your property
|
||||
print(" Assign the unarchived commands to your property ")
|
||||
commands = savedCommands
|
||||
} else {
|
||||
// Handle the case where the data could not be unarchived into the expected type
|
||||
print("Data could not be unarchived into [RemoteCommand]")
|
||||
}
|
||||
} catch {
|
||||
// Handle any errors that occur during unarchiving
|
||||
print("Failed to unarchive savedCommands with error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func saveCommands() {
|
||||
if let data = try? NSKeyedArchiver.archivedData(withRootObject: commands, requiringSecureCoding: false) {
|
||||
UserDefaults.standard.set(data, forKey: "savedCommands")
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func sendKeyComboCommand(keyboardCmdStrings: [String], delay: TimeInterval = 0.2, index: Int = 0) { // we need a large delay for WAN streaming
|
||||
// 如果已处理完所有按键,则开始释放按键
|
||||
guard index < keyboardCmdStrings.count else {
|
||||
// 释放按键
|
||||
for keyStr in keyboardCmdStrings.reversed() { // 从后往前释放按键
|
||||
if let keyCode = CommandManager.keyboardButtonMappings[keyStr] {
|
||||
LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_UP), 0) // 释放按键
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前按键的映射值
|
||||
if let keyCode = CommandManager.keyboardButtonMappings[keyboardCmdStrings[index]] {
|
||||
// 发送当前按键的按下事件
|
||||
LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_DOWN), 0)
|
||||
|
||||
// 延迟后递归处理下一个按键
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
|
||||
self.sendKeyComboCommand(keyboardCmdStrings: keyboardCmdStrings, delay: delay, index: index + 1)
|
||||
}
|
||||
} else {
|
||||
print("No mapping found for \(keyboardCmdStrings[index])")
|
||||
// 如果当前按键没有映射,跳过当前按键并继续下一个
|
||||
self.sendKeyComboCommand(keyboardCmdStrings: keyboardCmdStrings, delay: delay, index: index + 1)
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func sendKeyComboDown(keyboardCmdStrings: [String]) { // we need a large delay for WAN streaming
|
||||
for keyStr in keyboardCmdStrings {
|
||||
if let keyCode = CommandManager.keyboardButtonMappings[keyStr] {
|
||||
LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_DOWN), 0) // 释放按键
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func sendKeyComboUp(keyboardCmdStrings: [String]) { // we need a large delay for WAN streaming
|
||||
for keyStr in keyboardCmdStrings {
|
||||
if let keyCode = CommandManager.keyboardButtonMappings[keyStr] {
|
||||
LiSendKeyboardEvent(keyCode, Int8(KEY_ACTION_UP), 0) // 释放按键
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -46,6 +46,8 @@
|
||||
-(void) setMotionEventState:(uint16_t)controllerNumber motionType:(uint8_t)motionType reportRateHz:(uint16_t)reportRateHz;
|
||||
-(void) setControllerLed:(uint16_t)controllerNumber r:(uint8_t)r g:(uint8_t)g b:(uint8_t)b;
|
||||
|
||||
-(uint16_t) getActiveGamepadMask;
|
||||
|
||||
+(int) getConnectedGamepadMask:(StreamConfiguration*)streamConfig;
|
||||
|
||||
-(NSUInteger) getConnectedGamepadCount;
|
||||
|
||||
@@ -46,6 +46,7 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
char _controllerNumbers;
|
||||
bool _multiController;
|
||||
bool _swapABXYButtons;
|
||||
bool _captureMouse;
|
||||
}
|
||||
|
||||
// UPDATE_BUTTON_FLAG(controller, flag, pressed)
|
||||
@@ -354,6 +355,10 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
rightStickY = MAX_MAGNITUDE(rightStickY, controller.mergedWithController.lastRightStickY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//NSLog(@"gamepadMask: %@", [self binaryRepresentationOfInteger:buttonFlags]); // we got the pressed OSC buttons here.
|
||||
|
||||
// Player 1 is always present for OSC
|
||||
LiSendMultiControllerEvent(_multiController ? controller.playerIndex : 0, [self getActiveGamepadMask],
|
||||
buttonFlags, leftTrigger, rightTrigger,
|
||||
@@ -370,6 +375,19 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (NSString *)binaryRepresentationOfInteger:(int)number {
|
||||
NSMutableString *binaryString = [NSMutableString string];
|
||||
int numBits = sizeof(number) * 8;
|
||||
|
||||
for (int i = numBits - 1; i >= 0; i--) {
|
||||
[binaryString appendString:((number >> i) & 1) ? @"1" : @"0"];
|
||||
}
|
||||
|
||||
return binaryString;
|
||||
}
|
||||
|
||||
|
||||
+(BOOL) hasKeyboardOrMouse {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
return GCMouse.mice.count > 0 || GCKeyboard.coalescedKeyboard != nil;
|
||||
@@ -847,20 +865,25 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
}
|
||||
|
||||
-(void) registerMouseCallbacks:(GCMouse*) mouse API_AVAILABLE(ios(14.0)) {
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float deltaX, float deltaY) {
|
||||
self->accumulatedDeltaX += deltaX / MOUSE_SPEED_DIVISOR;
|
||||
self->accumulatedDeltaY += -deltaY / MOUSE_SPEED_DIVISOR;
|
||||
|
||||
short truncatedDeltaX = (short)self->accumulatedDeltaX;
|
||||
short truncatedDeltaY = (short)self->accumulatedDeltaY;
|
||||
|
||||
if (truncatedDeltaX != 0 || truncatedDeltaY != 0) {
|
||||
LiSendMouseMoveEvent(truncatedDeltaX, truncatedDeltaY);
|
||||
if (_captureMouse){
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput * _Nonnull mouse, float deltaX, float deltaY) {
|
||||
self->accumulatedDeltaX += deltaX / MOUSE_SPEED_DIVISOR;
|
||||
self->accumulatedDeltaY += -deltaY / MOUSE_SPEED_DIVISOR;
|
||||
|
||||
self->accumulatedDeltaX -= truncatedDeltaX;
|
||||
self->accumulatedDeltaY -= truncatedDeltaY;
|
||||
}
|
||||
};
|
||||
short truncatedDeltaX = (short)self->accumulatedDeltaX;
|
||||
short truncatedDeltaY = (short)self->accumulatedDeltaY;
|
||||
|
||||
if (truncatedDeltaX != 0 || truncatedDeltaY != 0) {
|
||||
LiSendMouseMoveEvent(truncatedDeltaX, truncatedDeltaY);
|
||||
|
||||
self->accumulatedDeltaX -= truncatedDeltaX;
|
||||
self->accumulatedDeltaY -= truncatedDeltaY;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
mouse.mouseInput.mouseMovedHandler = nil;
|
||||
}
|
||||
|
||||
|
||||
mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput * _Nonnull button, float value, BOOL pressed) {
|
||||
LiSendMouseButtonEvent(pressed ? BUTTON_ACTION_PRESS : BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||
@@ -1061,7 +1084,7 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
// Even if no gamepads are present, we will always count one if OSC is enabled,
|
||||
// or it's set to auto and no keyboard or mouse is present. Absolute touch mode
|
||||
// disables the OSC.
|
||||
if (level != OnScreenControlsLevelOff && (![ControllerSupport hasKeyboardOrMouse] || level != OnScreenControlsLevelAuto) && !settings.absoluteTouchMode) {
|
||||
if (level != OnScreenControlsLevelOff && (![ControllerSupport hasKeyboardOrMouse] || level != OnScreenControlsLevelAuto) && (settings.touchMode.intValue == RELATIVE_TOUCH)) {
|
||||
mask |= 0x1;
|
||||
}
|
||||
|
||||
@@ -1103,6 +1126,7 @@ 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];
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// LayoutOnScreenControls.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 9/26/22.
|
||||
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "OnScreenControls.h"
|
||||
#import "Moonlight-Swift.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
This object is a subclass of 'OnScreenControls' and adds additional properties and functions which allow the user to drag and drop each of the 19 on screen controller buttons in order to change their positions on screen. The object is used in the 'LayoutOnScreenControlsViewController' thus allowing the user to drag, drop, hide, unhide, on screen controller buttons.
|
||||
Note that this is in contrast to the game stream view which displays an 'OnScreenControls' object on screen that allows the app to register taps on each button as controller input. It does not (and naturally should not) allow the user to move the buttons around the screen.
|
||||
*/
|
||||
@interface LayoutOnScreenControls : OnScreenControls
|
||||
|
||||
@property UIView* _view;
|
||||
@property NSMutableArray *layoutChanges;
|
||||
@property CALayer *layerBeingDragged;
|
||||
@property UIViewController *layoutToolVC;
|
||||
|
||||
- (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport
|
||||
streamConfig:(StreamConfiguration*)streamConfig oscLevel:(int)oscLevel;
|
||||
|
||||
- (CALayer*) controllerLayerFromName:(NSString*)name;
|
||||
- (BOOL) isLayer:(CALayer*)layer hoveringOverButton:(UIButton*)button;
|
||||
|
||||
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||
// - (void) updateGuidelinesForOnScreenWidget:(OnScreenWidgetView* )widget;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,337 @@
|
||||
//
|
||||
// LayoutOnScreenControls.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 9/26/22.
|
||||
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LayoutOnScreenControls.h"
|
||||
#import "OSCProfilesTableViewController.h"
|
||||
#import "OnScreenButtonState.h"
|
||||
#import "OSCProfilesManager.h"
|
||||
|
||||
@interface LayoutOnScreenControls ()
|
||||
@end
|
||||
|
||||
@implementation LayoutOnScreenControls {
|
||||
|
||||
UIButton *trashCanButton;
|
||||
UIView *horizontalGuideline;
|
||||
UIView *verticalGuideline;
|
||||
}
|
||||
|
||||
@synthesize layerBeingDragged;
|
||||
@synthesize _view;
|
||||
@synthesize layoutChanges;
|
||||
|
||||
|
||||
|
||||
|
||||
- (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport streamConfig:(StreamConfiguration*)streamConfig oscLevel:(int)oscLevel {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(updateGuidelinesForOnScreenWidget:)
|
||||
name:@"OnScreenWidgetMovedByTouch" // This is a special notification for reloading the on screen keyboard buttons. which can't be executed by _oscProfilesTableViewController.needToUpdateOscLayoutTVC code block, and has to be triggered by a notification
|
||||
object:nil];
|
||||
|
||||
|
||||
_view = view;
|
||||
_view.multipleTouchEnabled = false;
|
||||
|
||||
self = [super initWithView:view controllerSup:controllerSupport streamConfig:streamConfig];
|
||||
self.isLayingOut = true; // make sure the super class have a flag to tell it's currently laying out the OSCs, intead play mode.
|
||||
self._level = oscLevel;
|
||||
|
||||
layoutChanges = [[NSMutableArray alloc] init]; // will contain OSC button layout changes the user has made for this profile
|
||||
|
||||
[self drawButtons];
|
||||
[self drawGuidelines]; // add the blue guidelines that appear when button is being tapped and dragged
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Drawing
|
||||
|
||||
/**
|
||||
* This method overrides the superclass's drawButtons method. The purpose of this method is to create a dPad parent layer, and add the four dPad buttons to it so that the user can drag the entire dPad around, directional buttons and all, as one unit as is the expected behavior. Note that we do not want the four dPad buttons to be child layers of a CALayer parent layer on the game stream view since the touch logic implemented for the four dPad buttons on the game stream view is written assuming the dPad buttons are not children of another parent CALayer
|
||||
*/
|
||||
- (void) drawButtons {
|
||||
[super setDPadCenter]; // Set custom position for D-Pad here
|
||||
[super setAnalogStickPositions]; // Set custom position for analog sticks here
|
||||
[super drawBumpers];
|
||||
[super drawButtons];
|
||||
|
||||
|
||||
UIImage* downButtonImage = [UIImage imageNamed:@"DownButton"];
|
||||
UIImage* rightButtonImage = [UIImage imageNamed:@"RightButton"];
|
||||
UIImage* upButtonImage = [UIImage imageNamed:@"UpButton"];
|
||||
UIImage* leftButtonImage = [UIImage imageNamed:@"LeftButton"];
|
||||
|
||||
// create dPad background layer
|
||||
self._dPadBackground = [CALayer layer];
|
||||
self._dPadBackground.name = @"dPad";
|
||||
self._dPadBackground.frame = CGRectMake(self.D_PAD_CENTER_X,
|
||||
self.D_PAD_CENTER_Y,
|
||||
self._leftButton.frame.size.width * 2 + BUTTON_DIST,
|
||||
self._leftButton.frame.size.width * 2 + BUTTON_DIST);
|
||||
self._dPadBackground.position = CGPointMake(self.D_PAD_CENTER_X, self.D_PAD_CENTER_Y); // since dPadBackground's dimensions have change after settings its width and height you need to reset its position again here
|
||||
[self.OSCButtonLayers addObject:self._dPadBackground];
|
||||
[_view.layer addSublayer:self._dPadBackground];
|
||||
|
||||
// add dPad buttons to parent layer
|
||||
[self._dPadBackground addSublayer:self._downButton];
|
||||
[self._dPadBackground addSublayer:self._rightButton];
|
||||
[self._dPadBackground addSublayer:self._upButton];
|
||||
[self._dPadBackground addSublayer:self._leftButton];
|
||||
|
||||
[self resizeControllerLayerWith:self._dPadBackground and:_dPadSizeFactor];
|
||||
|
||||
/*
|
||||
// reposition each dPad button within their parent dPadBackground layer
|
||||
self._downButton.frame = CGRectMake(self._dPadBackground.frame.size.width/3, self._dPadBackground.frame.size.height/2 + D_PAD_DIST, downButtonImage.size.width, downButtonImage.size.height);
|
||||
self._rightButton.frame = CGRectMake(self._dPadBackground.frame.size.width/2 + D_PAD_DIST, self._dPadBackground.frame.size.height/3, rightButtonImage.size.width, rightButtonImage.size.height);
|
||||
self._upButton.frame = CGRectMake(self._dPadBackground.frame.size.width/3, 0, upButtonImage.size.width, upButtonImage.size.height);
|
||||
self._leftButton.frame = CGRectMake(0, self._dPadBackground.frame.size.height/3, leftButtonImage.size.width, leftButtonImage.size.height);*/
|
||||
}
|
||||
|
||||
/**
|
||||
* draws a horizontal and vertical line that is made visible and positioned over whichever button the user is dragging around the screen
|
||||
*/
|
||||
- (void) drawGuidelines {
|
||||
horizontalGuideline = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self._view.frame.size.width * 2, 2)];
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor];
|
||||
horizontalGuideline.hidden = YES;
|
||||
[self._view addSubview: horizontalGuideline];
|
||||
|
||||
verticalGuideline = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 2, self._view.frame.size.height * 2)];
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor];
|
||||
verticalGuideline.hidden = YES;
|
||||
[self._view addSubview: verticalGuideline];
|
||||
}
|
||||
|
||||
- (void) updateGuidelinesForOnScreenWidget: (NSNotification *)notification{
|
||||
/* have guidelines follow wherever the user is touching on the screen */
|
||||
OnScreenWidgetView* widget = notification.object;
|
||||
horizontalGuideline.hidden = verticalGuideline.hidden = NO;
|
||||
horizontalGuideline.center = verticalGuideline.center = CGPointMake(CGRectGetMidX(widget.frame), CGRectGetMidY(widget.frame));
|
||||
/*
|
||||
Telegraph to the user whether the horizontal and/or vertical guidelines line up with one or more of the buttons on screen by doing the following:
|
||||
-Change horizontal guideline color to yellow if its y-position is almost equal to that of one of the buttons on screen.
|
||||
-Change vertical guideline color to yellow if its x-position is almost equal to that of one of the buttons on screen.
|
||||
*/
|
||||
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor]; // change horizontal guideline back to blue if it doesn't line up with one of the on screen buttons
|
||||
for (CALayer *button in self.OSCButtonLayers) { // horizontal guideline position check
|
||||
if ((layerBeingDragged != button) && !button.isHidden) {
|
||||
if ((horizontalGuideline.center.y < button.position.y + 1) &&
|
||||
(horizontalGuideline.center.y > button.position.y - 1)) {
|
||||
horizontalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(UIView* view in self.layoutToolVC.view.subviews){
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]] && view != widget) {
|
||||
if ((horizontalGuideline.center.y < view.center.y + 1) && (horizontalGuideline.center.y > view.center.y - 1)) {
|
||||
horizontalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor]; // change vertical guideline back to blue if it doesn't line up with one of the on screen buttons
|
||||
for (CALayer *button in self.OSCButtonLayers) { // vertical guideline position check
|
||||
if ((layerBeingDragged != button) && !button.isHidden) {
|
||||
if ((verticalGuideline.center.x < button.position.x + 1) &&
|
||||
(verticalGuideline.center.x > button.position.x - 1)) {
|
||||
verticalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(UIView* view in self.layoutToolVC.view.subviews){
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]] && view != widget) {
|
||||
if ((verticalGuideline.center.x < view.center.x + 1) && (verticalGuideline.center.x > view.center.x - 1)) {
|
||||
verticalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Queries
|
||||
|
||||
/* used to determine whether user is dragging an OSC button (of type CALayer) over the trash can with the intent of hiding that button */
|
||||
- (BOOL) isLayer:(CALayer *)layer hoveringOverButton:(UIButton *)button {
|
||||
CGRect buttonConvertedRect = [self._view convertRect:button.imageView.frame fromView:button.superview];
|
||||
|
||||
if (CGRectIntersectsRect(layer.frame, buttonConvertedRect)) {
|
||||
return YES;
|
||||
}
|
||||
else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
/* returns reference to button layer object given the button's name*/
|
||||
- (CALayer*)controllerLayerFromName: (NSString*)name {
|
||||
for (CALayer *buttonLayer in self.OSCButtonLayers) {
|
||||
|
||||
if ([buttonLayer.name isEqualToString:name]) {
|
||||
return buttonLayer;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - Touch
|
||||
|
||||
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
/* Reset variables related to on screen controller button drag and drop routine. These variables should be reset in 'touchesCancelled' or 'touchesEnded' but these may not be called in unaccounted-for edge cases such as when the user opens various OS-level control center related views by dragging down from the top of the screen, or dragging up from the bottom of the screen. Since Apple likes to add new control centers and new ways of opening them (i.e. Dynamic Island on iPhone 14 Pro) it's best to reset these variables here when the user is beginning a new on screen controller button drag routine */
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"LegacyOscCALayerSelectedNotification" object:self];
|
||||
layerBeingDragged = nil;
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor];
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor];
|
||||
|
||||
for (UITouch* touch in touches) { // Process touch
|
||||
|
||||
CGPoint touchLocation = [touch locationInView:_view];
|
||||
touchLocation = [[touch view] convertPoint:touchLocation toView:nil];
|
||||
CALayer *layer = [_view.layer hitTest:touchLocation];
|
||||
|
||||
/* Don't let user drag and move anything other than on screen controller buttons, which are CALayer types. The reason is that 'LayoutOnScreenControls' should only be responsible for managing and letting users move on screen controller buttons. Since this class's view is currently set to be set equal to the 'LayoutOnScreenControlsViewController' view it belongs to, we need to make sure touches on the VC's objects don't propagate down to 'LayoutOnScreenControls'. Weird stuff can happen to the UI buttons that belong to that VC (trash can button, undo button, save button, etc), such as them being dragged around the screen with the user's touches */
|
||||
for (UIView *subview in self._view.subviews) {
|
||||
|
||||
if (CGRectContainsPoint(subview.frame, touchLocation)) {
|
||||
if (![subview isKindOfClass:[CALayer class]]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (layer == self._upButton ||
|
||||
layer == self._downButton ||
|
||||
layer == self._leftButton ||
|
||||
layer == self._rightButton) { // don't let user drag individual dPad buttons
|
||||
layerBeingDragged = self._dPadBackground;
|
||||
}
|
||||
else if (layer == self._rightStick) { // only let user drag right stick's background, not the inner analog stick itself
|
||||
layerBeingDragged = self._rightStickBackground;
|
||||
}
|
||||
else if (layer == self._leftStick) { // only let user drag left stick's background, not the inner analog stick itself
|
||||
layerBeingDragged = self._leftStickBackground;
|
||||
}
|
||||
else if(layer == self._aButton ||
|
||||
layer == self._bButton ||
|
||||
layer == self._xButton ||
|
||||
layer == self._yButton ||
|
||||
layer == self._l1Button ||
|
||||
layer == self._l2Button ||
|
||||
layer == self._r1Button ||
|
||||
layer == self._r2Button ||
|
||||
layer == self._selectButton ||
|
||||
layer == self._startButton){ // we must iterates all the controller button layers manually here, to prevent other widgets being dragged accidently
|
||||
layerBeingDragged = layer;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"ControllerCALayerSelected" object:layerBeingDragged]; // inform that a CALayer of onScreen controller has being selected
|
||||
|
||||
/* save the name, position, and visibility of button being touched in array in case user wants to undo the change later */
|
||||
OnScreenButtonState *onScreenButtonState = [[OnScreenButtonState alloc] initWithButtonName:layerBeingDragged.name buttonType:LegacyOscButton andPosition:layerBeingDragged.position];
|
||||
// add hidden attr here
|
||||
onScreenButtonState.isHidden = layerBeingDragged.isHidden;
|
||||
|
||||
[layoutChanges addObject:onScreenButtonState];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"OSCLayoutChanged" object:self]; // lets the view controller know whether to fade the undo button in or out depending on whether there are any further OSC layout changes the user is allowed to undo
|
||||
|
||||
/* make guide lines visible and position them over the button the user is touching */
|
||||
horizontalGuideline.center = layerBeingDragged.position;
|
||||
horizontalGuideline.hidden = NO;
|
||||
verticalGuideline.center = layerBeingDragged.position;
|
||||
verticalGuideline.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
UITouch *touch = [touches anyObject];
|
||||
CGPoint touchLocation = [touch locationInView:_view];
|
||||
|
||||
|
||||
layerBeingDragged.position = touchLocation; // move object to touch location
|
||||
|
||||
/* have guidelines follow wherever the user is touching on the screen */
|
||||
horizontalGuideline.center = layerBeingDragged.position;
|
||||
verticalGuideline.center = layerBeingDragged.position;
|
||||
|
||||
/*
|
||||
Telegraph to the user whether the horizontal and/or vertical guidelines line up with one or more of the buttons on screen by doing the following:
|
||||
-Change horizontal guideline color to yellow if its y-position is almost equal to that of one of the buttons on screen.
|
||||
-Change vertical guideline color to yellow if its x-position is almost equal to that of one of the buttons on screen.
|
||||
*/
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor]; // change horizontal guideline back to blue if it doesn't line up with one of the on screen buttons
|
||||
for (CALayer *button in self.OSCButtonLayers) { // horizontal guideline position check
|
||||
if ((layerBeingDragged != button) && !button.isHidden) {
|
||||
if ((horizontalGuideline.center.y < button.position.y + 1) &&
|
||||
(horizontalGuideline.center.y > button.position.y - 1)) {
|
||||
horizontalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// alignment with onScreenWidgets
|
||||
for(UIView* view in self.layoutToolVC.view.subviews){
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]]) {
|
||||
if ((horizontalGuideline.center.y < view.center.y + 1) && (horizontalGuideline.center.y > view.center.y - 1)) {
|
||||
horizontalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor]; // change vertical guideline back to blue if it doesn't line up with one of the on screen buttons
|
||||
for (CALayer *button in self.OSCButtonLayers) { // vertical guideline position check
|
||||
if ((layerBeingDragged != button) && !button.isHidden) {
|
||||
if ((verticalGuideline.center.x < button.position.x + 1) &&
|
||||
(verticalGuideline.center.x > button.position.x - 1)) {
|
||||
verticalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// alignment with onScreenWidgets
|
||||
for(UIView* view in self.layoutToolVC.view.subviews){
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]]) {
|
||||
if ((verticalGuideline.center.x < view.center.x + 1) && (verticalGuideline.center.x > view.center.x - 1)) {
|
||||
verticalGuideline.backgroundColor = [UIColor yellowColor];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
layerBeingDragged = nil;
|
||||
|
||||
horizontalGuideline.hidden = YES;
|
||||
verticalGuideline.hidden = YES;
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor];
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor];
|
||||
}
|
||||
|
||||
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
layerBeingDragged = nil;
|
||||
|
||||
horizontalGuideline.hidden = YES;
|
||||
verticalGuideline.hidden = YES;
|
||||
horizontalGuideline.backgroundColor = [UIColor blueColor];
|
||||
verticalGuideline.backgroundColor = [UIColor blueColor];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// OSCProfile.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 12/22/22.
|
||||
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "OnScreenButtonState.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
This object contains information pertaining to any of the user created, custom on screen controller layout configurations, or 'profiles.' The object contains a 'name' property for easy reference, as well as an 'isSelected' property which is used to determine whether this particular custom OSC layout should show on screen during game stream view. Only one 'OSCProfile' is set to 'isSelected' at any given time. The object also contains an array of 'OnScreenButtonStates' which provides information that allows us to move and hide/unhide each of the 19 on screen buttons. Note that the 'buttonStates' property should contain an NSMutableArray of ENCODED 'OnScreenButtonState' objects. This allows us to save the 'OSCProfile' object to NSUserDefaults.
|
||||
Additionally the 'OSCProfile' object adopts encoding and decoding protocols so that we can encode the object before saving it to NSUserDefaults. By saving this object to NSUserDefaults we allow the user to save and load their custom on screen controller button layouts between app launches
|
||||
*/
|
||||
@interface OSCProfile : NSObject <NSCoding, NSSecureCoding>
|
||||
|
||||
@property NSString *name;
|
||||
@property NSMutableArray <OnScreenButtonState *> *buttonStates;
|
||||
@property BOOL isSelected;
|
||||
|
||||
- (id) initWithName:(NSString*)name buttonStates:(NSMutableArray*)buttonStates isSelected:(BOOL)isSelected;
|
||||
|
||||
+ (BOOL) supportsSecureCoding;
|
||||
- (id) initWithCoder:(NSCoder*)decoder;
|
||||
- (void) encodeWithCoder:(NSCoder*)encoder;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// OSCProfile.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 12/22/22.
|
||||
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OSCProfile.h"
|
||||
|
||||
@implementation OSCProfile
|
||||
|
||||
- (id) initWithName:(NSString*)name buttonStates:(NSMutableArray*)buttonStates isSelected:(BOOL)isSelected {
|
||||
if ((self = [self init])) {
|
||||
self.name = name;
|
||||
self.buttonStates = buttonStates;
|
||||
self.isSelected = isSelected;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (BOOL) supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder:(NSCoder*)encoder {
|
||||
[encoder encodeObject:self.name forKey:@"name"];
|
||||
[encoder encodeObject:self.buttonStates forKey:@"buttonStates"];
|
||||
[encoder encodeBool:self.isSelected forKey:@"isSelected"];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder*)decoder {
|
||||
if (self = [super init]) {
|
||||
self.name = [decoder decodeObjectForKey:@"name"];
|
||||
self.buttonStates = [decoder decodeObjectForKey:@"buttonStates"];
|
||||
self.isSelected = [decoder decodeBoolForKey:@"isSelected"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// OSCProfilesManager.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 1/1/23.
|
||||
// Copyright © 2023 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "OSCProfile.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
This singleton object can be accessed from any class and provides methods to get and set on screen controller profile related data.
|
||||
Note that the implementation file contains a number of 'Helper' methods. These helper methods are only used in this class's implementation file and help to reduce re-writing large blocks of code that are called multiple times throughout the file
|
||||
*/
|
||||
@interface OSCProfilesManager : NSObject
|
||||
|
||||
|
||||
+ (OSCProfilesManager *) sharedManager;
|
||||
+ (void) setOnScreenWidgetViewsSet:(NSMutableSet* )set;
|
||||
|
||||
#pragma mark - Getters
|
||||
/**
|
||||
* Returns an array of decoded profile objects
|
||||
*/
|
||||
- (NSMutableArray *) getAllProfiles;
|
||||
|
||||
/**
|
||||
* Returns the OSC Profile that is currently selected to be displayed on screen during game streaming
|
||||
*/
|
||||
- (OSCProfile *) getSelectedProfile;
|
||||
|
||||
/**
|
||||
* Returns the index of the 'selected' profile within the array it's in
|
||||
*/
|
||||
- (NSInteger) getIndexOfSelectedProfile;
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma mark - Setters
|
||||
/**
|
||||
* Sets the profile object with the particular 'name' as the selected profile to be displayed on screen during game streaming
|
||||
*/
|
||||
- (void) setProfileToSelected:(NSString *)name;
|
||||
|
||||
/**
|
||||
* Saves a profile object with a particular 'name' and an array of button layers (the CALayer button layers are the objects currently visible on screen) to persistent storage
|
||||
*/
|
||||
- (void) saveProfileWithName:(NSString*)name andButtonLayers:(NSMutableArray *)buttonLayers;
|
||||
|
||||
- (bool) updateSelectedProfile:(NSMutableArray *) oscButtonLayers;
|
||||
/**
|
||||
* Delete current selected profile.
|
||||
*/
|
||||
- (void) deleteCurrentSelectedProfile;
|
||||
|
||||
#pragma mark - Queries
|
||||
/**
|
||||
* Lets the caller of this method know whether a profile with a given name already exists in persistent storage
|
||||
*/
|
||||
- (BOOL) profileNameAlreadyExist:(NSString*)name;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,333 @@
|
||||
//
|
||||
// OSCProfilesManager.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 1/1/23.
|
||||
// Copyright © 2023 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OSCProfilesManager.h"
|
||||
#import "OnScreenButtonState.h"
|
||||
#import "Moonlight-Swift.h"
|
||||
#import "LayoutOnScreenControlsViewController.h"
|
||||
#import "OnScreenControls.h"
|
||||
|
||||
@implementation OSCProfilesManager
|
||||
|
||||
static NSMutableSet *OnScreenWidgetViews;
|
||||
|
||||
#pragma mark - Initializer
|
||||
|
||||
+ (OSCProfilesManager *) sharedManager {
|
||||
static OSCProfilesManager *_sharedManager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
|
||||
dispatch_once(&onceToken, ^{
|
||||
_sharedManager = [[self alloc] init];
|
||||
});
|
||||
return _sharedManager;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Class Helper Methods
|
||||
|
||||
|
||||
+ (void) setOnScreenWidgetViewsSet:(NSMutableSet* )set{
|
||||
OnScreenWidgetViews = set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profile whose 'name' property has a value that is equal to the 'name' passed into the method
|
||||
*/
|
||||
- (OSCProfile *) OSCProfileWithName:(NSString*)name {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
|
||||
for (OSCProfile *profile in profiles) {
|
||||
|
||||
if ([profile.name isEqualToString:name]) {
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of encoded 'OSCProfile' objects from the array of decoded 'OSCProfile' objects passed into this method
|
||||
*/
|
||||
- (NSMutableArray *) encodedProfilesFromArray:(NSMutableArray *)profiles {
|
||||
|
||||
NSMutableArray *profilesEncoded = [[NSMutableArray alloc] init];
|
||||
/* encode each profile and add them back into an array */
|
||||
for (OSCProfile *profile in profiles) { //
|
||||
NSData *profileEncoded = [NSKeyedArchiver archivedDataWithRootObject:profile requiringSecureCoding:YES error:nil];
|
||||
[profilesEncoded addObject:profileEncoded];
|
||||
}
|
||||
|
||||
return profilesEncoded;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete an 'OSCProfile' object of specific index for another in the 'OSCProfile' objects array stored in persistent storage
|
||||
*/
|
||||
-(void)deleteCurrentSelectedProfile{
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
NSInteger selectedIndex = [self getIndexOfSelectedProfile];
|
||||
|
||||
/* Remove the selected profile */
|
||||
if(selectedIndex != 0) [profiles removeObjectAtIndex:selectedIndex]; //deleting default profile (index 0) is not allowed
|
||||
else {
|
||||
NSLog(@"Default profile!"); // to be updated here.
|
||||
}
|
||||
|
||||
selectedIndex--;
|
||||
if(selectedIndex < 0) selectedIndex = 0;
|
||||
OSCProfile *newSelectedProfile = [profiles objectAtIndex:selectedIndex];
|
||||
newSelectedProfile.isSelected = YES;
|
||||
|
||||
NSMutableArray *profilesEncoded = [self encodedProfilesFromArray:profiles]; // encode each 'profile' object in the array and add them to a new array
|
||||
|
||||
/* Encode the array itself, NOT the objects in the array, which are already encoded. Save array to persistent storage */
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replaces one 'OSCProfile' object for another in the 'OSCProfile' objects array stored in persistent storage
|
||||
*/
|
||||
- (void) replaceProfile:(OSCProfile*)oldProfile withProfile:(OSCProfile*)newProfile {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
|
||||
for (OSCProfile *profile in profiles) { // set all profiles' 'isSelected' property to NO since the new profile we're saving over the old profile with will be the 'selected' profile
|
||||
profile.isSelected = NO;
|
||||
}
|
||||
|
||||
/* Set the new profile as the selected one. The reasoning behind this is that this method is currently being used when the user saves over an existing profile with another profile that has the same name. The expected behavior is that the newly saved profile becomes the selected profile which will show on screen when they launch the game stream view */
|
||||
newProfile.isSelected = YES;
|
||||
|
||||
/* Remove the old profile from the array and insert the new profile into its place */
|
||||
int index = 0;
|
||||
for (int i = 0; i < profiles.count; i++) {
|
||||
|
||||
if ([[profiles[i] name] isEqualToString: oldProfile.name]) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
[profiles removeObjectAtIndex:index];
|
||||
[profiles insertObject:newProfile atIndex:index];
|
||||
|
||||
NSMutableArray *profilesEncoded = [self encodedProfilesFromArray:profiles]; // encode each 'profile' object in the array and add them to a new array
|
||||
|
||||
/* Encode the array itself, NOT the objects in the array, which are already encoded. Save array to persistent storage */
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Globally Accessible Methods
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
- (NSMutableArray *) getAllProfiles {
|
||||
|
||||
NSData *profilesArrayEncoded = [[NSUserDefaults standardUserDefaults] objectForKey: @"OSCProfiles"]; // Get the encoded array of encoded OSC profiles from persistent storage
|
||||
NSSet *classes = [NSSet setWithObjects:[NSString class], [NSMutableData class], [NSMutableArray class], [OSCProfile class], [OnScreenButtonState class], nil];
|
||||
|
||||
NSMutableArray *profilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:profilesArrayEncoded error:nil]; // Decode the encoded array itself, NOT the objects contained in the array
|
||||
|
||||
/* Decode each of the encoded profiles, place them into an array, then return the array */
|
||||
NSMutableArray *profilesDecoded = [[NSMutableArray alloc] init];
|
||||
OSCProfile *profileDecoded;
|
||||
for (NSData *profileEncoded in profilesEncoded) {
|
||||
|
||||
profileDecoded = [NSKeyedUnarchiver unarchivedObjectOfClasses: classes fromData:profileEncoded error: nil];
|
||||
[profilesDecoded addObject: profileDecoded];
|
||||
}
|
||||
return profilesDecoded;
|
||||
}
|
||||
|
||||
- (OSCProfile *) getSelectedProfile {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
|
||||
for (OSCProfile *profile in profiles) {
|
||||
|
||||
if (profile.isSelected) {
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSInteger) getIndexOfSelectedProfile {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
for (OSCProfile *profile in profiles) {
|
||||
|
||||
if (profile.isSelected == YES) {
|
||||
return [profiles indexOfObject:profile];
|
||||
}
|
||||
}
|
||||
return 0; // if none of the profiles in the array have their 'isSelected' property set to YES (which should not be possible) return the 'Default' profile as the 'selected' profile
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
- (void) setProfileToSelected:(NSString *)name {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
|
||||
/* Iterate through each profile. If its name equals the value of the 'name' parameter passed into this method then set the profile's 'isSelected' property to YES, otherwise set the value to NO */
|
||||
for (OSCProfile *profile in profiles) {
|
||||
|
||||
if ([profile.name isEqualToString:name]) {
|
||||
profile.isSelected = YES;
|
||||
}
|
||||
else {
|
||||
profile.isSelected = NO;
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableArray *profilesEncoded = [self encodedProfilesFromArray:profiles]; // encode each 'profile' object in the array and add them to a new array
|
||||
|
||||
/* Encode the array itself, NOT the objects inside the array, which have already been encoded by this point */
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
|
||||
- (bool) updateSelectedProfile:(NSMutableArray *) oscButtonLayers {
|
||||
NSMutableArray* buttonStatesEncoded = [self convertOnScreenControllerAndButtonsToButtonStates:oscButtonLayers];
|
||||
if([self getIndexOfSelectedProfile]==0) return false;
|
||||
OSCProfile *newProfile = [[OSCProfile alloc] initWithName:[self getSelectedProfile].name
|
||||
buttonStates:buttonStatesEncoded isSelected:YES]; // create a new 'OSCProfile'. Set the array of encoded button states created above to the 'buttonStates' property of the new profile, along with a 'name'. Set 'isSelected' argument to YES which will set this saved profile as the one that will show up in the game stream view
|
||||
|
||||
|
||||
/* set all saved OSCProfiles 'isSelected' property to NO since the new profile you're adding will be set as the selected profile */
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
for (OSCProfile *profile in profiles) {
|
||||
profile.isSelected = NO;
|
||||
}
|
||||
[self replaceProfile:[self getSelectedProfile] withProfile:newProfile];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
- (void) saveProfileWithName:(NSString*)name andButtonLayers:(NSMutableArray *)oscButtonLayers {
|
||||
NSMutableArray* buttonStatesEncoded = [self convertOnScreenControllerAndButtonsToButtonStates:oscButtonLayers];
|
||||
OSCProfile *newProfile = [[OSCProfile alloc] initWithName:name
|
||||
buttonStates:buttonStatesEncoded isSelected:YES]; // create a new 'OSCProfile'. Set the array of encoded button states created above to the 'buttonStates' property of the new profile, along with a 'name'. Set 'isSelected' argument to YES which will set this saved profile as the one that will show up in the game stream view
|
||||
/* set all saved OSCProfiles 'isSelected' property to NO since the new profile you're adding will be set as the selected profile */
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
for (OSCProfile *profile in profiles) {
|
||||
|
||||
profile.isSelected = NO;
|
||||
}
|
||||
|
||||
if ([self profileNameAlreadyExist:name]) { // if a saved profile with the same 'name' already exists in persistent storage then overwrite it and save the change to persistent storage
|
||||
[self replaceProfile:[self OSCProfileWithName:name] withProfile:newProfile];
|
||||
}
|
||||
else { // otherwise encode then add the new profile to the end of the OSCProfiles array
|
||||
NSData *newProfileEncoded = [NSKeyedArchiver archivedDataWithRootObject:newProfile requiringSecureCoding:YES error:nil];
|
||||
NSMutableArray *profilesEncoded = [self encodedProfilesFromArray:profiles];
|
||||
[profilesEncoded addObject:newProfileEncoded];
|
||||
|
||||
/* Encode the 'profilesEncoded' array itself, NOT the objects in the 'profilesEncoded' array, all of which are already encoded by this point */
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
// saving test:
|
||||
/*
|
||||
NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
|
||||
NSString *path = [documentsPath stringByAppendingPathComponent:@"newDefault.bin"];
|
||||
[newProfileEncoded writeToFile:path atomically:YES];
|
||||
NSLog(@"默认 Profile 数据已保存到: %@", path);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (NSMutableArray* ) convertOnScreenControllerAndButtonsToButtonStates:(NSMutableArray *) oscButtonLayers {
|
||||
/* iterate through each OSC button the user sees on screen, create an 'OnScreenButtonState' object from each button, encode each object, and then add each object to an array */
|
||||
/*
|
||||
NSSet *validPositionButtonNames = [NSSet setWithObjects:
|
||||
@"l2Button",
|
||||
@"l1Button",
|
||||
@"dPad",
|
||||
@"selectButton",
|
||||
@"leftStickBackground",
|
||||
@"rightStickBackground",
|
||||
@"r2Button",
|
||||
@"r1Button",
|
||||
@"aButton",
|
||||
@"bButton",
|
||||
@"xButton",
|
||||
@"yButton",
|
||||
@"startButton",
|
||||
nil]; */
|
||||
NSMutableArray *buttonStatesEncoded = [[NSMutableArray alloc] init];
|
||||
|
||||
// save on-screen game controller buttons & sticks as buttonstate:
|
||||
for (CALayer *oscButtonLayer in oscButtonLayers) {
|
||||
|
||||
OnScreenButtonState *buttonState = [[OnScreenButtonState alloc] initWithButtonName:oscButtonLayer.name buttonType:LegacyOscButton andPosition:oscButtonLayer.position];
|
||||
// add hidden attr here
|
||||
buttonState.isHidden = oscButtonLayer.isHidden;
|
||||
buttonState.oscLayerSizeFactor = [OnScreenControls getControllerLayerSizeFactor:oscButtonLayer];
|
||||
buttonState.backgroundAlpha = oscButtonLayer.opacity;
|
||||
NSLog(@"oscLayerName: %@, opacity: %f, ", oscButtonLayer.name, buttonState.backgroundAlpha);
|
||||
|
||||
|
||||
// buttonState.oscLayerSizeFactor = oscButtonLayer.bounds;
|
||||
|
||||
NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil];
|
||||
[buttonStatesEncoded addObject: buttonStateEncoded];
|
||||
}
|
||||
|
||||
// save on-screen widget views (keyboard & mouse command) as buttonstate:
|
||||
for(OnScreenWidgetView* widgetView in OnScreenWidgetViews){
|
||||
OnScreenButtonState *buttonState = [[OnScreenButtonState alloc] initWithButtonName:widgetView.keyString buttonType:CustomOnScreenWidget andPosition:widgetView.center];
|
||||
buttonState.alias = widgetView.keyLabel;
|
||||
buttonState.timestamp = widgetView.timestamp;
|
||||
buttonState.widthFactor = widgetView.widthFactor;
|
||||
buttonState.heightFactor = widgetView.heightFactor;
|
||||
buttonState.backgroundAlpha = widgetView.backgroundAlpha;
|
||||
buttonState.borderWidth = widgetView.borderWidth;
|
||||
buttonState.sensitivityFactor = widgetView.sensitivityFactor;
|
||||
buttonState.stickIndicatorOffset = widgetView.stickIndicatorOffset;
|
||||
|
||||
NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil];
|
||||
[buttonStatesEncoded addObject: buttonStateEncoded];
|
||||
|
||||
}
|
||||
return buttonStatesEncoded;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - Queries
|
||||
|
||||
- (BOOL) profileNameAlreadyExist:(NSString*)name {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
|
||||
/* Iterate through the decoded profiles and return 'YES' if one of the profiles' 'name' properties equals the 'name' passed into this method */
|
||||
for (OSCProfile *profile in profiles) {
|
||||
|
||||
if ([profile.name isEqualToString:name]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// OnScreenButtonState.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 10/20/22.
|
||||
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
This object is used to save positional and visibility information for any particular on screen virtual controller button.
|
||||
We are able to associate this 'OnScreenButtonState' object and its corresponding CALayer onscreen controller button by setting their 'name' properties equal; in our particular case we give them descriptive names such as 'aButton', 'upButton', 'leftStick', etc. By keeping references to the 19 on screen controller buttons (CALayers) in an array, and creating 19 'OnScreenButtonState' objects with names corresponding to these 19 CALayers and keeping them in an array, we can iterate through both arrays to find OSC buttons (CALayers) with the same name as one of the 'OnScreenButtonStateObjects' and then set the CALayer on screen control button's 'position' and 'hidden' property according to the value of the 'OnScreenButtonState' objects 'position' and 'isHidden' properties.
|
||||
Naturally we would like the user to be able to save their controller layout configurations so that they can load them between app launches, so we adopt encoding/decoding related protocols so we encode these 'OnScreenButtonState' objects and save them to NSUserDefaults
|
||||
*/
|
||||
|
||||
// OS Button state info obj to be modified
|
||||
@interface OnScreenButtonState : NSObject <NSCoding, NSSecureCoding>
|
||||
|
||||
@property NSString *name;
|
||||
@property NSString *alias;
|
||||
@property CGPoint position;
|
||||
@property (nonatomic, assign) BOOL isHidden;
|
||||
@property (nonatomic, assign) uint8_t buttonType;
|
||||
@property (nonatomic, assign) NSTimeInterval timestamp;
|
||||
@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 stickIndicatorOffset; // for OnScreenWidgetView
|
||||
|
||||
@property (nonatomic, assign) CGFloat oscLayerSizeFactor; // for OnScreenController CALayer
|
||||
@property (nonatomic, assign) CGFloat backgroundAlpha; // for OnScreenController CALayer
|
||||
|
||||
// @property (nonatomic, assign) BOOL hasValidPosition;
|
||||
|
||||
typedef NS_ENUM(NSInteger, OnScreenButtonType) {
|
||||
LegacyOscButton,
|
||||
CustomOnScreenWidget
|
||||
};
|
||||
|
||||
- (id) initWithButtonName:(NSString*)name buttonType:(uint8_t)buttonType andPosition:(CGPoint)position;
|
||||
|
||||
+ (BOOL) supportsSecureCoding;
|
||||
- (void) encodeWithCoder:(NSCoder*)encoder;
|
||||
- (id) initWithCoder:(NSCoder*)decoder;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// OnScreenButtonState.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by Long Le on 10/20/22.
|
||||
// Copyright © 2022 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OnScreenButtonState.h"
|
||||
|
||||
@implementation OnScreenButtonState
|
||||
|
||||
|
||||
- (id) initWithButtonName:(NSString*)name buttonType:(uint8_t)buttonType andPosition:(CGPoint)position {
|
||||
if ((self = [self init])) {
|
||||
self.name = name;
|
||||
//self.isHidden = isHidden;
|
||||
self.position = position;
|
||||
self.buttonType = buttonType;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (BOOL) supportsSecureCoding {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder:(NSCoder*)encoder {
|
||||
[encoder encodeObject:self.name forKey:@"name"];
|
||||
[encoder encodeObject:self.alias forKey:@"alias"];
|
||||
[encoder encodeDouble:self.timestamp forKey:@"timestamp"];
|
||||
[encoder encodeInt:self.buttonType forKey:@"buttonType"];
|
||||
[encoder encodeCGPoint:self.position forKey:@"position"];
|
||||
[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.stickIndicatorOffset forKey:@"stickIndicatorOffset"];
|
||||
[encoder encodeFloat:self.oscLayerSizeFactor forKey:@"oscLayerSizeFactor"];
|
||||
[encoder encodeFloat:self.backgroundAlpha forKey:@"backgroundAlpha"];
|
||||
[encoder encodeFloat:self.borderWidth forKey:@"borderWidth"];
|
||||
}
|
||||
|
||||
- (id) initWithCoder:(NSCoder*)decoder {
|
||||
if (self = [super init]) {
|
||||
self.name = [decoder decodeObjectForKey:@"name"];
|
||||
self.alias = [decoder decodeObjectForKey:@"alias"];
|
||||
self.timestamp = [decoder decodeDoubleForKey:@"timestamp"];
|
||||
self.buttonType = [decoder decodeIntForKey:@"buttonType"];
|
||||
self.position = [decoder decodeCGPointForKey:@"position"];
|
||||
self.isHidden = [decoder decodeBoolForKey:@"isHidden"];
|
||||
self.widthFactor = [decoder decodeFloatForKey:@"widthFactor"];
|
||||
self.heightFactor = [decoder decodeFloatForKey:@"heightFactor"];
|
||||
self.sensitivityFactor = [decoder decodeFloatForKey:@"velocityFactor"];
|
||||
self.stickIndicatorOffset = [decoder decodeFloatForKey:@"stickIndicatorOffset"];
|
||||
self.oscLayerSizeFactor = [decoder decodeFloatForKey:@"oscLayerSizeFactor"];
|
||||
self.backgroundAlpha = [decoder decodeFloatForKey:@"backgroundAlpha"];
|
||||
self.borderWidth = [decoder decodeFloatForKey:@"borderWidth"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// CustomTapGestureRecognizer.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by ZWM on 2024/5/15.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef CustomTapGestureRecognizer_h
|
||||
#define CustomTapGestureRecognizer_h
|
||||
|
||||
|
||||
@interface CustomTapGestureRecognizer : UIGestureRecognizer{
|
||||
CGFloat lowestTouchPointYCoord;
|
||||
}
|
||||
|
||||
|
||||
@property (nonatomic, assign) uint8_t numberOfTouchesRequired;
|
||||
@property (nonatomic, assign) bool immediateTriggering; // if enabled, trigger the signal on touchesBegan stage.
|
||||
@property (nonatomic, assign) double tapDownTimeThreshold; // tap down threshold in seconds.
|
||||
@property (nonatomic, assign) bool isOnScreenControllerBeingPressed; // will be set by the onscreencontrol class
|
||||
//@property (nonatomic, assign) bool haveOnScreenButtonsOnStreamview;
|
||||
@property (nonatomic, readonly) CGFloat lowestTouchPointHeight;
|
||||
@property (nonatomic, readonly) bool gestureCaptured;
|
||||
@property (nonatomic, readonly) NSTimeInterval gestureCapturedTime;
|
||||
|
||||
@end
|
||||
#endif /* CustomTapGestureRecognizer_h */
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// CustomTapGestureRecognizer.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by ZWM on 2024/5/15.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIGestureRecognizerSubclass.h>
|
||||
#import "CustomTapGestureRecognizer.h"
|
||||
#import "Moonlight-Swift.h"
|
||||
|
||||
// The most accurate & reliable tap gesture recognizer of iOS:
|
||||
// - Almost 100% recoginition rate. UITapGestureRecognizer of Apple API fails frequently, just a piece of crap.
|
||||
// - When immediateTriggering is set to false (for native multi-touch):
|
||||
// Gesture signal will be triggered on touchesEnded stage, multi finger touch operations will not be interrupted by the arising keyboard.
|
||||
// Instances of different [numberOfTouchesRequired] barely compete with each other, for example, the chance of 3-finger gesture get triggered by 4 or 5 finger tap is very small.
|
||||
// - Set property immediateTriggering to true, to ensure the priority of keyboard toggle in non-native touch mode, in compete with 2-finger gestures.
|
||||
// - This recognizer also provides properties like gestureCapturedTime, to be accessed outside the class for useful purpose.
|
||||
|
||||
@implementation CustomTapGestureRecognizer
|
||||
|
||||
static CGFloat screenHeightInPoints;
|
||||
static CGFloat screenWidthInPoints;
|
||||
|
||||
- (instancetype)initWithTarget:(nullable id)target action:(nullable SEL)action {
|
||||
self = [super initWithTarget:target action:action];
|
||||
screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
|
||||
screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
|
||||
lowestTouchPointYCoord = 0.0;
|
||||
_numberOfTouchesRequired = 3;
|
||||
_immediateTriggering = false;
|
||||
_tapDownTimeThreshold = 0.3;
|
||||
_gestureCaptured = false;
|
||||
_isOnScreenControllerBeingPressed = false;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
// Check if the number of touches and taps meets the required criteria
|
||||
if ([[event allTouches] count] == _numberOfTouchesRequired) {
|
||||
_gestureCapturedTime = CACurrentMediaTime();
|
||||
_gestureCaptured = true;
|
||||
for(UITouch *touch in [event allTouches]){
|
||||
if(lowestTouchPointYCoord < [touch locationInView:self.view].y) lowestTouchPointYCoord = [touch locationInView:self.view].y;
|
||||
}
|
||||
|
||||
// this mechanism is deprecated.
|
||||
/* if(_numberOfTouchesRequired == 2){
|
||||
NSArray *twoTouches = [[event allTouches] allObjects];
|
||||
_areVirtualControllerTaps = fabs([twoTouches[1] locationInView:self.view].x - [twoTouches[0] locationInView:self.view].x) > screenWidthInPoints/3;
|
||||
} */
|
||||
|
||||
_lowestTouchPointHeight = screenHeightInPoints - lowestTouchPointYCoord;
|
||||
if(_immediateTriggering){
|
||||
lowestTouchPointYCoord = 0.0; //reset for next recoginition
|
||||
self.state = UIGestureRecognizerStateRecognized;
|
||||
return;
|
||||
}
|
||||
self.state = UIGestureRecognizerStatePossible;
|
||||
}
|
||||
if ([[event allTouches] count] > _numberOfTouchesRequired) {
|
||||
_gestureCaptured = false;
|
||||
self.state = UIGestureRecognizerStateFailed;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
// [super touchesEnded:touches withEvent:event];
|
||||
if(_immediateTriggering) return;
|
||||
uint8_t allTouchesCount = [[event allTouches] count];
|
||||
if(allTouchesCount > _numberOfTouchesRequired) {
|
||||
_gestureCaptured = false;
|
||||
self.state = UIGestureRecognizerStateFailed;
|
||||
}
|
||||
else if(_gestureCaptured && allTouchesCount == [touches count] && !_isOnScreenControllerBeingPressed && ![self isOnScreenWidgetViewBeingPressed]){ //must exclude virtual controller & onscreen button taps here to prevent stucked button, _areVirtualControllerTaps flag is set by onscreencontrols, containOnScreenButtonsTaps will be returned by iterating all widget views in streamframeview
|
||||
_gestureCaptured = false; //reset for next recognition
|
||||
if((CACurrentMediaTime() - _gestureCapturedTime) < _tapDownTimeThreshold){
|
||||
lowestTouchPointYCoord = 0.0; //reset for next recognition
|
||||
self.state = UIGestureRecognizerStateRecognized;
|
||||
}
|
||||
}
|
||||
if (allTouchesCount == [touches count]) _isOnScreenControllerBeingPressed = false; // need to reset this flag anyway, when all fingers are lefting
|
||||
}
|
||||
|
||||
|
||||
// it was a not a perfect choice to code OnScreenWidgetView in Swift...
|
||||
// we're unable to import this class to swift codebase by the bridging header,and have to exlucde the onscreen button taps here
|
||||
// by iterating every widget view instances. but it's basically ok since the number of widgetViews are always limited.
|
||||
// and this method will only be called when the recognizer is active & and the taps passes all the checks and is about to ge triggered.
|
||||
- (bool)isOnScreenWidgetViewBeingPressed {
|
||||
NSTimeInterval allFingersTapDownTime = CACurrentMediaTime() - _gestureCapturedTime; //RIGHTCLICK_TAP_DOWN_TIME_THRESHOLD_S has been passed to this recognizer as _tapDownTimeShreshold, we'll decide how to deal with pressed flag of on-screen widget views based on tapDownTime
|
||||
bool gotOneWidgetPressed = false;
|
||||
// the tap gestures are all added to the streamFrameTopLayerView, where all the OnScreenWidgetViews are added. so we can iterate them in this way:
|
||||
for(UIView* view in self.view.subviews){
|
||||
if ([view isKindOfClass:[OnScreenWidgetView class]]) {
|
||||
OnScreenWidgetView* widgetView = (OnScreenWidgetView*) view;
|
||||
if(gotOneWidgetPressed && allFingersTapDownTime <= _tapDownTimeThreshold){ // once we have just 1 button pressed already,& the tapDownTime has not exceeded the threshold, we'll reset pressed flag for the all the widgetViews.
|
||||
widgetView.pressed = false; //reset the flag for widgetView
|
||||
continue;
|
||||
}
|
||||
if(widgetView.pressed){
|
||||
gotOneWidgetPressed = true; //got one button pressed
|
||||
if(allFingersTapDownTime <= _tapDownTimeThreshold) widgetView.pressed = false; // reset the flag for current widgetView if tapDowntime is still within the threshold, if not, leave the flag for mouse scroller gesture in relative touch mode.
|
||||
}
|
||||
}
|
||||
}
|
||||
return gotOneWidgetPressed;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -248,6 +248,9 @@
|
||||
case UIKeyboardHIDUsageKeyboardRightAlt:
|
||||
keyCode = 0xA5;
|
||||
break;
|
||||
case UIKeyboardHIDUsageKeyboardErrorUndefined:
|
||||
NSLog(@"Undefined key pressed");
|
||||
return false;
|
||||
case 669: // This value corresponds to the "Globe" or "Language" key on most Apple branded iPad keyboards.
|
||||
keyCode = 0x1B; // This value corresponds to "Escape", which is missing from most Apple branded iPad keyboards.
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// NativeTouchHandler.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by ZWM on 2024/6/16.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#import "StreamView.h"
|
||||
#import "DataManager.h"
|
||||
#include <Limelight.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NativeTouchHandler : UIResponder
|
||||
@property (nonatomic, assign) NSMutableSet<UITouch *>* touchesCapturedByOnScreenButtons;
|
||||
|
||||
|
||||
- (id)initWithView:(StreamView* )view andSettings:(TemporarySettings*)settings;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,164 @@
|
||||
//
|
||||
// NativeTouchHandler.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by ZWM on 2024/6/16.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NativeTouchHandler.h"
|
||||
#import "NativeTouchPointer.h"
|
||||
#import "OnScreenControls.h"
|
||||
#import "StreamView.h"
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
|
||||
|
||||
|
||||
@implementation NativeTouchHandler {
|
||||
StreamView* streamView;
|
||||
TemporarySettings* currentSettings;
|
||||
bool activateCoordSelector;
|
||||
bool touchPointSpawnedAtUpperScreenEdge;
|
||||
|
||||
// Use a Dictionary to store UITouch object's memory address as key, and pointerId as value,字典存放UITouch对象地址和pointerId映射关系
|
||||
// pointerId will be generated from a pre-defined pool
|
||||
// Use a NSSet store active pointerId,
|
||||
NSMutableDictionary *pointerIdDict; //pointerId Dict for active touches.
|
||||
NSMutableSet<NSNumber *> *activePointerIds; //pointerId Set for active touches.
|
||||
NSMutableSet<NSNumber *> *pointerIdPool; //pre-defined pool of pointerIds.
|
||||
NSMutableSet<NSNumber *> *unassignedPointerIds;
|
||||
|
||||
CGFloat slideGestureVerticalThreshold;
|
||||
CGFloat screenWidthWithThreshold;
|
||||
CGFloat EDGE_TOLERANCE;
|
||||
}
|
||||
|
||||
- (id)initWithView:(StreamView*)view andSettings:(TemporarySettings*)settings{
|
||||
self = [super init];
|
||||
self->streamView = view;
|
||||
self->currentSettings = settings;
|
||||
self->activateCoordSelector = currentSettings.pointerVelocityModeDivider.floatValue != 1.0;
|
||||
// self->notPureNativeTouchMode = !(currentSettings.touchMode.intValue == PURE_NATIVE_TOUCH);
|
||||
|
||||
self->pointerIdDict = [NSMutableDictionary dictionary];
|
||||
self->pointerIdPool = [NSMutableSet set];
|
||||
for (uint8_t i = 0; i <= 10; i++) { //ipadOS supports upto 11 finger touches
|
||||
[self->pointerIdPool addObject:@(i)];
|
||||
}
|
||||
self->activePointerIds = [NSMutableSet set];
|
||||
// self->excludedPointerIds = [[NSMutableSet alloc] init];
|
||||
self->touchPointSpawnedAtUpperScreenEdge = false;
|
||||
|
||||
EDGE_TOLERANCE = 15.0;
|
||||
slideGestureVerticalThreshold = CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.4;
|
||||
screenWidthWithThreshold = CGRectGetWidth([[UIScreen mainScreen] bounds]) - EDGE_TOLERANCE;
|
||||
|
||||
[NativeTouchPointer setPointerVelocityDivider:settings.pointerVelocityModeDivider.floatValue];
|
||||
[NativeTouchPointer setPointerVelocityFactor:settings.touchPointerVelocityFactor.floatValue];
|
||||
[NativeTouchPointer initContextWithView:self->streamView];
|
||||
//_touchesCapturedByOnScreenButtons = [[NSMutableSet alloc] init];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// generate & populate pointerId into NSDict & NSSet, called in touchesBegan
|
||||
- (void)handleTouchDown:(UITouch*)touch{
|
||||
//populate pointerId
|
||||
uintptr_t memAddrValue = (uintptr_t)touch;
|
||||
unassignedPointerIds = [pointerIdPool mutableCopy]; //reset unassignedPointerIds
|
||||
[unassignedPointerIds minusSet:activePointerIds];
|
||||
uint8_t pointerId = [[unassignedPointerIds anyObject] unsignedIntValue];
|
||||
[pointerIdDict setObject:@(pointerId) forKey:@(memAddrValue)];
|
||||
[activePointerIds addObject:@(pointerId)];
|
||||
|
||||
//check if touch point is spawned on the left or right upper half screen edges, event to remote PC. this is for better handling in-stream slide gesture
|
||||
CGPoint initialPoint = [touch locationInView:self->streamView];
|
||||
if(initialPoint.y < slideGestureVerticalThreshold && (initialPoint.x < EDGE_TOLERANCE || initialPoint.x > screenWidthWithThreshold)) {
|
||||
self->touchPointSpawnedAtUpperScreenEdge = true;
|
||||
// [excludedPointerIds addObject:@(pointerId)];
|
||||
}
|
||||
}
|
||||
|
||||
// remove pointerId in touchesEnded or touchesCancelled
|
||||
- (void)removePointerId:(UITouch*)touch{
|
||||
uintptr_t memAddrValue = (uintptr_t)touch;
|
||||
NSNumber* pointerIdObj = [pointerIdDict objectForKey:@(memAddrValue)];
|
||||
if(pointerIdObj != nil){
|
||||
[activePointerIds removeObject:pointerIdObj];
|
||||
[pointerIdDict removeObjectForKey:@(memAddrValue)];
|
||||
// if([excludedPointerIds containsObject:pointerIdObj]) [excludedPointerIds removeObject:pointerIdObj]; // remove pointer id from excludedPointerId NSSet
|
||||
}
|
||||
}
|
||||
|
||||
// 从字典中获取UITouch事件对应的pointerId
|
||||
// called in method of sendTouchEvent
|
||||
- (uint8_t) retrievePointerIdFromDict:(UITouch*)touch{
|
||||
return [[pointerIdDict objectForKey:@((uintptr_t)touch)] unsignedIntValue];
|
||||
}
|
||||
|
||||
|
||||
- (void)sendTouchEvent:(UITouch*)touch withTouchtype:(uint8_t)touchType{
|
||||
if(touchPointSpawnedAtUpperScreenEdge) return; // we're done here. this touch event will not be sent to the remote PC. and this must be checked after coord selector finishes populating new relative coords, or the app will crash!
|
||||
|
||||
CGPoint targetCoords;
|
||||
// NSLog(@"excluded count: %d", (uint32_t)[excludedPointerIds count]);
|
||||
if(activateCoordSelector && touch.phase == UITouchPhaseMoved) targetCoords = [NativeTouchPointer selectCoordsFor:touch]; // coordinates of touch pointer replaced to relative ones here.
|
||||
else targetCoords = [touch locationInView:streamView];
|
||||
|
||||
CGPoint location = [streamView adjustCoordinatesForVideoArea:targetCoords];
|
||||
CGSize videoSize = [streamView getVideoAreaSize];
|
||||
CGFloat normalizedX = location.x / videoSize.width;
|
||||
CGFloat normalizedY = location.y / videoSize.height;
|
||||
uint8_t pointerId = [self retrievePointerIdFromDict:touch];
|
||||
|
||||
if([NativeTouchPointer getPointerObjFromDict:touch].needResetCoords){ // access whether the current pointer has reached the boundary, and need a coord reset.
|
||||
LiSendTouchEvent(LI_TOUCH_EVENT_UP, pointerId, normalizedX, normalizedY, 0, 0, 0, 0); //event must sent from the lowest level directy by LiSendTouchEvent to simulate continous dragging to another point on screen
|
||||
LiSendTouchEvent(LI_TOUCH_EVENT_DOWN, pointerId, 0.3, 0.4, 0, 0, 0, 0);
|
||||
}else LiSendTouchEvent(touchType, pointerId, normalizedX, normalizedY,(touch.force / touch.maximumPossibleForce) / sin(touch.altitudeAngle),0.0f, 0.0f,[streamView getRotationFromAzimuthAngle:[touch azimuthAngleInView:streamView]]);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
for (UITouch* touch in touches){
|
||||
// continue to the next loop if current touch is already captured by OSC. works only in regular native touch
|
||||
if([OnScreenControls.touchAddrsCapturedByOnScreenControls containsObject:@((uintptr_t)touch)]) continue;
|
||||
[self handleTouchDown:touch]; //generate & populate pointerId
|
||||
if(activateCoordSelector) [NativeTouchPointer populatePointerObjIntoDict:touch];
|
||||
[self sendTouchEvent:touch withTouchtype:LI_TOUCH_EVENT_DOWN];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
// NSLog(@"captured by OSB touches: %d", (uint32_t)[OnScreenControls.touchAddrsCapturedByOnScreenControls count]);
|
||||
for (UITouch* touch in touches){
|
||||
// continue to the next loop if current touch is already captured by OSC. works only in regular native touch
|
||||
if([OnScreenControls.touchAddrsCapturedByOnScreenControls containsObject:@((uintptr_t)touch)]) continue;
|
||||
if(activateCoordSelector) [NativeTouchPointer updatePointerObjInDict:touch];
|
||||
[self sendTouchEvent:touch withTouchtype:LI_TOUCH_EVENT_MOVE];
|
||||
[[NativeTouchPointer getPointerObjFromDict:touch] doesNeedResetCoords]; // execute the judging of doesReachBoundary for current pointer instance. (happens after the event is sent to Sunshine service)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
for (UITouch* touch in touches){
|
||||
// continue to the next loop if current touch is already captured by OSC. works only in regular native touch
|
||||
if([OnScreenControls.touchAddrsCapturedByOnScreenControls containsObject:@((uintptr_t)touch)]) continue;
|
||||
[self sendTouchEvent:touch withTouchtype:LI_TOUCH_EVENT_UP]; //send touch event before remove pointerId
|
||||
[self removePointerId:touch]; //then remove pointerId
|
||||
if(activateCoordSelector) [NativeTouchPointer removePointerObjFromDict:touch];
|
||||
}
|
||||
if(touchPointSpawnedAtUpperScreenEdge && [[event allTouches] count] == [touches count]) touchPointSpawnedAtUpperScreenEdge = false;
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[self touchesEnded:touches withEvent:event];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// NativeTouchPointer.h
|
||||
// Moonlight
|
||||
//
|
||||
// Created by ZWM on 2024/5/14.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "StreamView.h"
|
||||
#import "NativeTouchHandler.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NativeTouchPointer : NSObject
|
||||
@property (nonatomic, assign) bool needResetCoords;
|
||||
|
||||
+ (void)initContextWithView:(StreamView *)view;
|
||||
+ (void)setPointerVelocityDivider:(CGFloat)dividerLocation;
|
||||
+ (void)setPointerVelocityFactor:(CGFloat)velocityFactor;
|
||||
|
||||
+ (NativeTouchPointer* )getPointerObjFromDict:(UITouch*)touch;
|
||||
- (bool)doesNeedResetCoords;
|
||||
|
||||
+ (void)populatePointerObjIntoDict:(UITouch*)touch;
|
||||
+ (void)removePointerObjFromDict:(UITouch*)touch;
|
||||
+ (void)updatePointerObjInDict:(UITouch *)touch;
|
||||
+ (CGPoint)selectCoordsFor:(UITouch *)touch;
|
||||
|
||||
|
||||
- (instancetype)initWithTouch:(UITouch *)touch;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// NativeTouchPointer.m
|
||||
// Moonlight
|
||||
//
|
||||
// Created by ZWM on 2024/5/14.
|
||||
// Copyright © 2024 Moonlight Game Streaming Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "NativeTouchPointer.h"
|
||||
#include <Limelight.h>
|
||||
|
||||
// native touch pointer ojbect that stores & manipulates touch coordinates
|
||||
|
||||
static NSMutableDictionary *pointerObjDict;
|
||||
|
||||
static CGFloat pointerVelocityFactor;
|
||||
static CGFloat pointerVelocityDivider;
|
||||
static CGFloat pointerVelocityDividerLocationByPoints;
|
||||
static CGFloat streamViewHeight;
|
||||
static CGFloat streamViewWidth;
|
||||
static CGFloat fixedResetCoordX;
|
||||
static CGFloat fixedResetCoordY;
|
||||
static StreamView* _streamView;
|
||||
|
||||
@implementation NativeTouchPointer{
|
||||
CGPoint initialPoint;
|
||||
CGPoint latestPoint;
|
||||
CGPoint previousPoint;
|
||||
CGPoint latestRelativePoint;
|
||||
CGPoint previousRelativePoint;
|
||||
bool useRelativeCoords;
|
||||
}
|
||||
|
||||
- (instancetype)initWithTouch:(UITouch *)touch{
|
||||
self = [super init];
|
||||
self->initialPoint = [touch locationInView:_streamView];
|
||||
self->latestPoint = self->initialPoint;
|
||||
self->latestRelativePoint = self->initialPoint;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (bool)doesNeedResetCoords{
|
||||
bool boundaryReached = (latestRelativePoint.x > streamViewWidth || latestRelativePoint.x < 0.0f || latestRelativePoint.y > streamViewHeight || latestRelativePoint.y < 0.0f);
|
||||
bool withinExcludedArea = (initialPoint.x > streamViewWidth * (0.75) && initialPoint.x < streamViewWidth) && (initialPoint.y > streamViewHeight * (0.8) && initialPoint.y < streamViewHeight);
|
||||
_needResetCoords = (pointerVelocityFactor > 1.0f) && self->useRelativeCoords && boundaryReached && !withinExcludedArea;
|
||||
// boundary detection & coordinates reset to the specific point for HK:StarTrail(needs a very high pointer velocity)
|
||||
// must exclude touch pointer that uses native coords instead of relative ones.
|
||||
// also exclude touch pointer created within the bottom right corner
|
||||
|
||||
return _needResetCoords;
|
||||
}
|
||||
|
||||
- (void)updatePointerCoords:(UITouch *)touch{
|
||||
previousPoint = latestPoint;
|
||||
latestPoint = [touch locationInView:_streamView];
|
||||
previousRelativePoint = latestRelativePoint;
|
||||
if(_needResetCoords){// boundary detection & coordinates reset to the central screen point for HK:StarTrail(needs a very high pointer velocity); // boundary detection & coordinates reset to specific point for HK:StarTrail(needs a very high pointer velocity)
|
||||
previousRelativePoint.x = fixedResetCoordX;
|
||||
previousRelativePoint.y = fixedResetCoordY;
|
||||
}
|
||||
latestRelativePoint.x = previousRelativePoint.x + pointerVelocityFactor * (latestPoint.x - previousPoint.x);
|
||||
latestRelativePoint.y = previousRelativePoint.y + pointerVelocityFactor * (latestPoint.y - previousPoint.y);
|
||||
}
|
||||
|
||||
+ (void)initContextWithView:(StreamView *)view {
|
||||
_streamView = view;
|
||||
streamViewWidth = _streamView.frame.size.width;
|
||||
fixedResetCoordX = streamViewWidth * 0.3;
|
||||
streamViewHeight = _streamView.frame.size.height;
|
||||
fixedResetCoordY = streamViewHeight * 0.4;
|
||||
NSLog(@"stream wdith %f, stream height %f", streamViewWidth, streamViewHeight);
|
||||
pointerObjDict = [NSMutableDictionary dictionary];
|
||||
pointerVelocityDividerLocationByPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]) * pointerVelocityDivider;
|
||||
NSLog(@"pointerVelocityDivider: %.2f", pointerVelocityDivider);
|
||||
NSLog(@"pointerVelocityFactor: %.2f", pointerVelocityFactor);
|
||||
NSLog(@"pointerVelocityDividerLocationByPoints: %.2f", pointerVelocityDividerLocationByPoints);
|
||||
}
|
||||
|
||||
+ (void)setPointerVelocityDivider:(CGFloat)dividerLocation{
|
||||
pointerVelocityDivider = dividerLocation;
|
||||
}
|
||||
|
||||
+ (void)setPointerVelocityFactor:(CGFloat)velocityFactor{
|
||||
pointerVelocityFactor = velocityFactor;
|
||||
}
|
||||
|
||||
|
||||
+ (void)populatePointerObjIntoDict:(UITouch*)touch{
|
||||
[pointerObjDict setObject:[[NativeTouchPointer alloc] initWithTouch:touch] forKey:@((uintptr_t)touch)];
|
||||
}
|
||||
|
||||
+ (void)removePointerObjFromDict:(UITouch*)touch{
|
||||
uintptr_t memAddrValue = (uintptr_t)touch;
|
||||
NativeTouchPointer* pointer = [pointerObjDict objectForKey:@(memAddrValue)];
|
||||
if(pointer != nil){
|
||||
[pointerObjDict removeObjectForKey:@(memAddrValue)];
|
||||
}
|
||||
}
|
||||
|
||||
+ (NativeTouchPointer* )getPointerObjFromDict:(UITouch*)touch{
|
||||
return [pointerObjDict objectForKey:@((uintptr_t)touch)];
|
||||
}
|
||||
|
||||
|
||||
+ (void)updatePointerObjInDict:(UITouch *)touch{
|
||||
[[pointerObjDict objectForKey:@((uintptr_t)touch)] updatePointerCoords:touch];
|
||||
}
|
||||
|
||||
|
||||
+ (CGPoint)selectCoordsFor:(UITouch *)touch{
|
||||
NativeTouchPointer *pointer = [pointerObjDict objectForKey:@((uintptr_t)touch)];
|
||||
if(pointer == nil) return CGPointMake(0, 0);
|
||||
if((pointer -> initialPoint).x > pointerVelocityDividerLocationByPoints){ //if first contact coords locates on the right side of divider.
|
||||
pointer -> useRelativeCoords = true;
|
||||
return pointer->latestRelativePoint;
|
||||
}
|
||||
else{
|
||||
pointer -> useRelativeCoords = false;
|
||||
return[touch locationInView:_streamView];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -7,30 +7,130 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ControllerSupport.h"
|
||||
#import "CustomTapGestureRecognizer.h"
|
||||
#import "OSCProfile.h"
|
||||
#define MIN_CONTROLLER_LAYER_ALPHA 0.23
|
||||
|
||||
@class ControllerSupport;
|
||||
@class StreamConfiguration;
|
||||
|
||||
@interface OnScreenControls : NSObject
|
||||
// sending self as an instance to OnScreenWidgetView or other related classes
|
||||
@protocol InstanceProviderDelegate <NSObject>
|
||||
- (void)getOnScreenControlsInstance:(id)sender; // Renamed delegate method
|
||||
@end
|
||||
|
||||
|
||||
static const float D_PAD_DIST = 10;
|
||||
static const float BUTTON_DIST = 20;
|
||||
|
||||
@interface OnScreenControls : NSObject{
|
||||
@protected
|
||||
CGFloat _leftStickSizeFactor;
|
||||
CGFloat _leftStickOpacity;
|
||||
CGFloat _rightStickSizeFactor;
|
||||
CGFloat _rightStickOpacity;
|
||||
CGFloat _dPadSizeFactor;
|
||||
}
|
||||
|
||||
typedef NS_ENUM(NSInteger, OnScreenControlsLevel) {
|
||||
OnScreenControlsLevelOff,
|
||||
OnScreenControlsLevelAuto,
|
||||
OnScreenControlsLevelSimple,
|
||||
OnScreenControlsLevelFull,
|
||||
|
||||
OnScreenControlsLevelCustom,
|
||||
OnScreenControlsLevelAuto, // move it here instead of delete , to ensure integrity of the codes
|
||||
|
||||
// Internal levels selected by ControllerSupport
|
||||
OnScreenControlsLevelAutoGCGamepad,
|
||||
OnScreenControlsLevelAutoGCExtendedGamepad,
|
||||
OnScreenControlsLevelAutoGCExtendedGamepadWithStickButtons
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@property (nonatomic, weak) id<InstanceProviderDelegate> delegate; // Delegate property
|
||||
- (void)sendInstance;
|
||||
|
||||
// @property (nonatomic, assign) CustomTapGestureRecognizer* mouseRightClickTapRecognizer; // this object will be passed to onscreencontrols class for areVirtualControllerTaps flag setting
|
||||
@property (nonatomic, assign) bool isLayingOut;
|
||||
//@property (nonatomic) NSMutableSet<UITouch* >* touchesCapturedByOnScreenButtons;
|
||||
|
||||
|
||||
@property (nonatomic, assign) CGRect standardRoundButtonBounds;
|
||||
@property (nonatomic, assign) CGRect standardRectangleButtonBounds;
|
||||
@property (nonatomic, assign) CGRect standardStickBounds;
|
||||
@property (nonatomic, assign) CGRect standardStickBackgroundBounds;
|
||||
@property (nonatomic, assign) CGRect standardUpDownButtonBounds;
|
||||
@property (nonatomic, assign) CGRect standardLeftRightButtonBounds;
|
||||
|
||||
@property (nonatomic, assign) CGPoint leftStickCenter;
|
||||
@property (nonatomic, assign) CGPoint rightStickCenter;
|
||||
|
||||
@property CALayer* _aButton;
|
||||
@property (nonatomic, assign) CGFloat aButtonSizeFactor;
|
||||
@property CALayer* _bButton;
|
||||
@property (nonatomic, assign) CGFloat bButtonSizeFactor;
|
||||
@property CALayer* _xButton;
|
||||
@property (nonatomic, assign) CGFloat xButtonSizeFactor;
|
||||
@property CALayer* _yButton;
|
||||
@property (nonatomic, assign) CGFloat yButtonSizeFactor;
|
||||
|
||||
|
||||
@property CALayer* _startButton;
|
||||
@property CALayer* _selectButton;
|
||||
@property CALayer* _r1Button;
|
||||
@property CALayer* _r2Button;
|
||||
@property CALayer* _r3Button;
|
||||
@property CALayer* _l1Button;
|
||||
@property CALayer* _l2Button;
|
||||
@property CALayer* _l3Button;
|
||||
@property CALayer* _upButton;
|
||||
@property CALayer* _downButton;
|
||||
@property CALayer* _leftButton;
|
||||
@property CALayer* _rightButton;
|
||||
@property CALayer* _leftStickBackground;
|
||||
@property CALayer* _leftStick;
|
||||
@property CALayer* _rightStickBackground;
|
||||
@property CALayer* _rightStick;
|
||||
@property CALayer* _dPadBackground; // parent layer that contains each individual dPad button so user can drag them around the screen together
|
||||
|
||||
@property float D_PAD_CENTER_X;
|
||||
@property float D_PAD_CENTER_Y;
|
||||
|
||||
@property OnScreenControlsLevel _level;
|
||||
|
||||
@property NSMutableArray *OSCButtonLayers;
|
||||
|
||||
|
||||
+ (NSMutableSet* )touchAddrsCapturedByOnScreenControls;
|
||||
+ (void) testMethod;
|
||||
- (void) sendRightStickTouchPadEvent:(CGFloat) stickX : (CGFloat) stickY;
|
||||
- (void) clearRightStickTouchPadFlag;
|
||||
- (void) sendLeftStickTouchPadEvent:(CGFloat) stickX : (CGFloat) stickY;
|
||||
- (void) clearLeftStickTouchPadFlag;
|
||||
- (void) pressDownControllerButton: (int)flag;
|
||||
- (void) releaseControllerButton: (int)flag;
|
||||
- (void) updateLeftTrigger:(unsigned char)input;
|
||||
- (void) updateRightTrigger:(unsigned char)input;
|
||||
|
||||
- (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport streamConfig:(StreamConfiguration*)streamConfig;
|
||||
- (BOOL) handleTouchDownEvent:(NSSet*)touches;
|
||||
- (BOOL) handleTouchUpEvent:(NSSet*)touches;
|
||||
- (BOOL) handleTouchMovedEvent:(NSSet*)touches;
|
||||
- (void) setLevel:(OnScreenControlsLevel)level;
|
||||
- (OnScreenControlsLevel) getLevel;
|
||||
- (void) show;
|
||||
- (void) setupComplexControls;
|
||||
- (void) drawButtons;
|
||||
- (void) drawBumpers;
|
||||
- (void) updateControls;
|
||||
- (OnScreenControlsLevel) getLevel;
|
||||
- (void) setDPadCenter;
|
||||
- (void) setAnalogStickPositions;
|
||||
- (void) positionAndResizeSingleControllerLayers;
|
||||
- (void) resizeControllerLayerWith:(CALayer*)layer and:(CGFloat)sizeFactor;
|
||||
- (void) adjustControllerLayerOpacityWith:(CALayer*)layer and:(CGFloat)alpha;
|
||||
+ (CGFloat) getControllerLayerSizeFactor:(CALayer*)layer;
|
||||
- (CGFloat) getControllerLayerOpacity:(CALayer*)layer;
|
||||
|
||||
@end
|
||||
|
||||