diff --git a/.gitmodules b/.gitmodules index 11cd918..ca517c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "moonlight-common/moonlight-common-c"] path = moonlight-common/moonlight-common-c url = https://github.com/moonlight-stream/moonlight-common-c.git +[submodule "X1Kit"] + path = X1Kit + url = https://github.com/cgutman/X1Kit.git diff --git a/Limelight/Input/StreamView.h b/Limelight/Input/StreamView.h index c82efea..28cad34 100644 --- a/Limelight/Input/StreamView.h +++ b/Limelight/Input/StreamView.h @@ -8,6 +8,7 @@ #import "ControllerSupport.h" #import "OnScreenControls.h" +#import "Moonlight-Swift.h" @protocol EdgeDetectionDelegate @@ -22,7 +23,7 @@ @end -@interface StreamView : OSView +@interface StreamView : OSView @property (nonatomic, retain) IBOutlet UITextField* keyInputField; diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 1f36592..8f41148 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -16,6 +16,7 @@ CGPoint touchLocation, originalLocation; BOOL touchMoved; OnScreenControls* onScreenControls; + X1Mouse* x1mouse; BOOL isInputingText; BOOL isDragging; @@ -73,6 +74,10 @@ [onScreenControls setLevel:level]; } #endif + + x1mouse = [[X1Mouse alloc] init]; + x1mouse.delegate = self; + [x1mouse start]; } - (void)startInteractionTimer { @@ -423,4 +428,38 @@ return commands; } +- (void)connectedStateDidChangeWithIdentifier:(NSUUID * _Nonnull)identifier isConnected:(BOOL)isConnected { + NSLog(@"Citrix X1 mouse state change: %@ -> %s", + identifier, isConnected ? "connected" : "disconnected"); +} + +- (void)mouseDidMoveWithIdentifier:(NSUUID * _Nonnull)identifier deltaX:(int16_t)deltaX deltaY:(int16_t)deltaY { + LiSendMouseMoveEvent(deltaX, deltaY); +} + +- (int) buttonFromX1ButtonCode:(enum X1MouseButton)button { + switch (button) { + case X1MouseButtonLeft: + return BUTTON_LEFT; + case X1MouseButtonRight: + return BUTTON_RIGHT; + case X1MouseButtonMiddle: + return BUTTON_MIDDLE; + default: + return -1; + } +} + +- (void)mouseDownWithIdentifier:(NSUUID * _Nonnull)identifier button:(enum X1MouseButton)button { + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, [self buttonFromX1ButtonCode:button]); +} + +- (void)mouseUpWithIdentifier:(NSUUID * _Nonnull)identifier button:(enum X1MouseButton)button { + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, [self buttonFromX1ButtonCode:button]); +} + +- (void)wheelDidScrollWithIdentifier:(NSUUID * _Nonnull)identifier deltaZ:(int8_t)deltaZ { + LiSendScrollEvent(deltaZ); +} + @end diff --git a/Limelight/Limelight-Info.plist b/Limelight/Limelight-Info.plist index 8f19272..abc5a10 100644 --- a/Limelight/Limelight-Info.plist +++ b/Limelight/Limelight-Info.plist @@ -2,6 +2,10 @@ + NSBluetoothPeripheralUsageDescription + Bluetooth access allows Moonlight to connect to Citrix X1 mice. + NSBluetoothAlwaysUsageDescription + Bluetooth access allows Moonlight to connect to Citrix X1 mice. CADisableMinimumFrameDuration CFBundleDevelopmentRegion diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index daff562..64b4812 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 9865DC3C2132922E0005B9B9 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9865DC3B2132922E0005B9B9 /* GameController.framework */; }; 9865DC3E21332D660005B9B9 /* MainFrameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FB89462519F646E200339C8A /* MainFrameViewController.m */; }; 9890CF6B203B7EE1006C4B06 /* libxml2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 9890CF6A203B7EE1006C4B06 /* libxml2.tbd */; }; + 9896219723D15C7000211983 /* X1Kit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9896219623D15C7000211983 /* X1Kit.swift */; }; 9897B6A1221260EF00966419 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 9897B6A0221260EF00966419 /* Controller.m */; }; 9897B6A62212732C00966419 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 9897B6A0221260EF00966419 /* Controller.m */; }; 98CFB82F1CAD481B0048EF74 /* libmoonlight-common.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 98AB2E841CAD46840089BB98 /* libmoonlight-common.a */; }; @@ -163,6 +164,7 @@ 986CCE6C2133E45300168291 /* Moonlight v1.2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Moonlight v1.2.xcdatamodel"; sourceTree = ""; }; 98878AE0206A226D00586E90 /* OSPortabilityDefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSPortabilityDefs.h; sourceTree = ""; }; 9890CF6A203B7EE1006C4B06 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; }; + 9896219623D15C7000211983 /* X1Kit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = X1Kit.swift; path = X1Kit/Sources/X1Kit/X1Kit.swift; sourceTree = ""; }; 9897B6A0221260EF00966419 /* Controller.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = ""; }; 9897B6A32212610800966419 /* Controller.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = ""; }; 98AB2E7F1CAD46830089BB98 /* moonlight-common.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "moonlight-common.xcodeproj"; path = "moonlight-common/moonlight-common.xcodeproj"; sourceTree = ""; }; @@ -392,6 +394,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 9896219423D15C2900211983 /* X1Kit */ = { + isa = PBXGroup; + children = ( + 9896219623D15C7000211983 /* X1Kit.swift */, + ); + name = X1Kit; + sourceTree = ""; + }; 98AB2E801CAD46830089BB98 /* Products */ = { isa = PBXGroup; children = ( @@ -416,6 +426,7 @@ FB290CE519B2C406004C83CF = { isa = PBXGroup; children = ( + 9896219423D15C2900211983 /* X1Kit */, 98AB2E7F1CAD46830089BB98 /* moonlight-common.xcodeproj */, FB290CF919B2C406004C83CF /* Moonlight */, FB1A67542132419700507771 /* Moonlight TV */, @@ -1017,6 +1028,7 @@ FB9AFD371A7E02DB00872C98 /* HttpRequest.m in Sources */, FB4678ED1A50C40900377732 /* OnScreenControls.m in Sources */, FB290D0019B2C406004C83CF /* main.m in Sources */, + 9896219723D15C7000211983 /* X1Kit.swift in Sources */, FBD3494319FC9C04002D2A60 /* AppAssetManager.m in Sources */, FB6549561A57907E001C8F39 /* DiscoveryWorker.m in Sources */, FB89462A19F646E200339C8A /* ControllerSupport.m in Sources */, diff --git a/X1Kit b/X1Kit new file mode 160000 index 0000000..e4dae23 --- /dev/null +++ b/X1Kit @@ -0,0 +1 @@ +Subproject commit e4dae23ed3bca00d35fc7f277ace9ca8c7c78bd8