diff --git a/Limelight.xcodeproj/project.pbxproj b/Limelight.xcodeproj/project.pbxproj index e0ebc145..e181c636 100644 --- a/Limelight.xcodeproj/project.pbxproj +++ b/Limelight.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ FB290DC419B2E98F004C83CF /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FB290DC319B2E98F004C83CF /* libxml2.dylib */; }; FB290E7919B37D81004C83CF /* iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FB290E7819B37D81004C83CF /* iPad.storyboard */; }; FB290E7B19B38036004C83CF /* iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FB290E7A19B38036004C83CF /* iPhone.storyboard */; }; + FB4678ED1A50C40900377732 /* OnScreenControls.m in Sources */ = {isa = PBXBuildFile; fileRef = FB4678EC1A50C40900377732 /* OnScreenControls.m */; }; FB7E794419C8B71B00A15F68 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FB7E794319C8B71B00A15F68 /* libiconv.dylib */; }; FB89462819F646E200339C8A /* CryptoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FB89460619F646E200339C8A /* CryptoManager.m */; }; FB89462919F646E200339C8A /* mkcert.c in Sources */ = {isa = PBXBuildFile; fileRef = FB89460719F646E200339C8A /* mkcert.c */; }; @@ -106,6 +107,8 @@ FB290DC319B2E98F004C83CF /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; FB290E7819B37D81004C83CF /* iPad.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = iPad.storyboard; sourceTree = SOURCE_ROOT; }; FB290E7A19B38036004C83CF /* iPhone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = iPhone.storyboard; sourceTree = SOURCE_ROOT; }; + FB4678EB1A50C40900377732 /* OnScreenControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnScreenControls.h; sourceTree = ""; }; + FB4678EC1A50C40900377732 /* OnScreenControls.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OnScreenControls.m; sourceTree = ""; }; FB7E794319C8B71B00A15F68 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; }; FB89460519F646E200339C8A /* CryptoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoManager.h; sourceTree = ""; }; FB89460619F646E200339C8A /* CryptoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CryptoManager.m; sourceTree = ""; }; @@ -392,6 +395,8 @@ FB89460B19F646E200339C8A /* ControllerSupport.m */, FB89460C19F646E200339C8A /* StreamView.h */, FB89460D19F646E200339C8A /* StreamView.m */, + FB4678EB1A50C40900377732 /* OnScreenControls.h */, + FB4678EC1A50C40900377732 /* OnScreenControls.m */, ); path = Input; sourceTree = ""; @@ -768,6 +773,7 @@ FB89463619F646E200339C8A /* StreamFrameViewController.m in Sources */, FB89462819F646E200339C8A /* CryptoManager.m in Sources */, FB89462E19F646E200339C8A /* PairManager.m in Sources */, + FB4678ED1A50C40900377732 /* OnScreenControls.m in Sources */, FB290D0019B2C406004C83CF /* main.m in Sources */, FBD3494319FC9C04002D2A60 /* AppManager.m in Sources */, FB89462A19F646E200339C8A /* ControllerSupport.m in Sources */, diff --git a/Limelight/Images.xcassets/AButton.imageset/Contents.json b/Limelight/Images.xcassets/AButton.imageset/Contents.json new file mode 100644 index 00000000..429e86f4 --- /dev/null +++ b/Limelight/Images.xcassets/AButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "a_button.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "a_button-1.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "a_button-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/AButton.imageset/a_button-1.png b/Limelight/Images.xcassets/AButton.imageset/a_button-1.png new file mode 100644 index 00000000..a1b6d68d Binary files /dev/null and b/Limelight/Images.xcassets/AButton.imageset/a_button-1.png differ diff --git a/Limelight/Images.xcassets/AButton.imageset/a_button-2.png b/Limelight/Images.xcassets/AButton.imageset/a_button-2.png new file mode 100644 index 00000000..a1b6d68d Binary files /dev/null and b/Limelight/Images.xcassets/AButton.imageset/a_button-2.png differ diff --git a/Limelight/Images.xcassets/AButton.imageset/a_button.png b/Limelight/Images.xcassets/AButton.imageset/a_button.png new file mode 100644 index 00000000..a1b6d68d Binary files /dev/null and b/Limelight/Images.xcassets/AButton.imageset/a_button.png differ diff --git a/Limelight/Images.xcassets/BButton.imageset/Contents.json b/Limelight/Images.xcassets/BButton.imageset/Contents.json new file mode 100644 index 00000000..8c941fa1 --- /dev/null +++ b/Limelight/Images.xcassets/BButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "b_button.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "b_button-1.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "b_button-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/BButton.imageset/b_button-1.png b/Limelight/Images.xcassets/BButton.imageset/b_button-1.png new file mode 100644 index 00000000..18649f46 Binary files /dev/null and b/Limelight/Images.xcassets/BButton.imageset/b_button-1.png differ diff --git a/Limelight/Images.xcassets/BButton.imageset/b_button-2.png b/Limelight/Images.xcassets/BButton.imageset/b_button-2.png new file mode 100644 index 00000000..18649f46 Binary files /dev/null and b/Limelight/Images.xcassets/BButton.imageset/b_button-2.png differ diff --git a/Limelight/Images.xcassets/BButton.imageset/b_button.png b/Limelight/Images.xcassets/BButton.imageset/b_button.png new file mode 100644 index 00000000..18649f46 Binary files /dev/null and b/Limelight/Images.xcassets/BButton.imageset/b_button.png differ diff --git a/Limelight/Images.xcassets/DownButton.imageset/Contents.json b/Limelight/Images.xcassets/DownButton.imageset/Contents.json new file mode 100644 index 00000000..e57d1fe7 --- /dev/null +++ b/Limelight/Images.xcassets/DownButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "down.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "down-1.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "down-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/DownButton.imageset/down-1.png b/Limelight/Images.xcassets/DownButton.imageset/down-1.png new file mode 100644 index 00000000..0557ceec Binary files /dev/null and b/Limelight/Images.xcassets/DownButton.imageset/down-1.png differ diff --git a/Limelight/Images.xcassets/DownButton.imageset/down-2.png b/Limelight/Images.xcassets/DownButton.imageset/down-2.png new file mode 100644 index 00000000..0557ceec Binary files /dev/null and b/Limelight/Images.xcassets/DownButton.imageset/down-2.png differ diff --git a/Limelight/Images.xcassets/DownButton.imageset/down.png b/Limelight/Images.xcassets/DownButton.imageset/down.png new file mode 100644 index 00000000..0557ceec Binary files /dev/null and b/Limelight/Images.xcassets/DownButton.imageset/down.png differ diff --git a/Limelight/Images.xcassets/LeftButton.imageset/Contents.json b/Limelight/Images.xcassets/LeftButton.imageset/Contents.json new file mode 100644 index 00000000..b5b34f59 --- /dev/null +++ b/Limelight/Images.xcassets/LeftButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "left.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "left-1.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "left-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/LeftButton.imageset/left-1.png b/Limelight/Images.xcassets/LeftButton.imageset/left-1.png new file mode 100644 index 00000000..3ab41503 Binary files /dev/null and b/Limelight/Images.xcassets/LeftButton.imageset/left-1.png differ diff --git a/Limelight/Images.xcassets/LeftButton.imageset/left-2.png b/Limelight/Images.xcassets/LeftButton.imageset/left-2.png new file mode 100644 index 00000000..3ab41503 Binary files /dev/null and b/Limelight/Images.xcassets/LeftButton.imageset/left-2.png differ diff --git a/Limelight/Images.xcassets/LeftButton.imageset/left.png b/Limelight/Images.xcassets/LeftButton.imageset/left.png new file mode 100644 index 00000000..3ab41503 Binary files /dev/null and b/Limelight/Images.xcassets/LeftButton.imageset/left.png differ diff --git a/Limelight/Images.xcassets/RightButton.imageset/Contents.json b/Limelight/Images.xcassets/RightButton.imageset/Contents.json new file mode 100644 index 00000000..a11eef90 --- /dev/null +++ b/Limelight/Images.xcassets/RightButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "right.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "right-1.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "right-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/RightButton.imageset/right-1.png b/Limelight/Images.xcassets/RightButton.imageset/right-1.png new file mode 100644 index 00000000..c717a8dc Binary files /dev/null and b/Limelight/Images.xcassets/RightButton.imageset/right-1.png differ diff --git a/Limelight/Images.xcassets/RightButton.imageset/right-2.png b/Limelight/Images.xcassets/RightButton.imageset/right-2.png new file mode 100644 index 00000000..c717a8dc Binary files /dev/null and b/Limelight/Images.xcassets/RightButton.imageset/right-2.png differ diff --git a/Limelight/Images.xcassets/RightButton.imageset/right.png b/Limelight/Images.xcassets/RightButton.imageset/right.png new file mode 100644 index 00000000..c717a8dc Binary files /dev/null and b/Limelight/Images.xcassets/RightButton.imageset/right.png differ diff --git a/Limelight/Images.xcassets/UpButton.imageset/Contents.json b/Limelight/Images.xcassets/UpButton.imageset/Contents.json new file mode 100644 index 00000000..523b6d71 --- /dev/null +++ b/Limelight/Images.xcassets/UpButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "up-1.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "up.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "up-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/UpButton.imageset/up-1.png b/Limelight/Images.xcassets/UpButton.imageset/up-1.png new file mode 100644 index 00000000..a2b194ed Binary files /dev/null and b/Limelight/Images.xcassets/UpButton.imageset/up-1.png differ diff --git a/Limelight/Images.xcassets/UpButton.imageset/up-2.png b/Limelight/Images.xcassets/UpButton.imageset/up-2.png new file mode 100644 index 00000000..a2b194ed Binary files /dev/null and b/Limelight/Images.xcassets/UpButton.imageset/up-2.png differ diff --git a/Limelight/Images.xcassets/UpButton.imageset/up.png b/Limelight/Images.xcassets/UpButton.imageset/up.png new file mode 100644 index 00000000..a2b194ed Binary files /dev/null and b/Limelight/Images.xcassets/UpButton.imageset/up.png differ diff --git a/Limelight/Images.xcassets/XButton.imageset/Contents.json b/Limelight/Images.xcassets/XButton.imageset/Contents.json new file mode 100644 index 00000000..82e66ef9 --- /dev/null +++ b/Limelight/Images.xcassets/XButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "x_button-1.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "x_button.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "x_button-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/XButton.imageset/x_button-1.png b/Limelight/Images.xcassets/XButton.imageset/x_button-1.png new file mode 100644 index 00000000..125ce38e Binary files /dev/null and b/Limelight/Images.xcassets/XButton.imageset/x_button-1.png differ diff --git a/Limelight/Images.xcassets/XButton.imageset/x_button-2.png b/Limelight/Images.xcassets/XButton.imageset/x_button-2.png new file mode 100644 index 00000000..125ce38e Binary files /dev/null and b/Limelight/Images.xcassets/XButton.imageset/x_button-2.png differ diff --git a/Limelight/Images.xcassets/XButton.imageset/x_button.png b/Limelight/Images.xcassets/XButton.imageset/x_button.png new file mode 100644 index 00000000..125ce38e Binary files /dev/null and b/Limelight/Images.xcassets/XButton.imageset/x_button.png differ diff --git a/Limelight/Images.xcassets/YButton.imageset/Contents.json b/Limelight/Images.xcassets/YButton.imageset/Contents.json new file mode 100644 index 00000000..1aa5efb9 --- /dev/null +++ b/Limelight/Images.xcassets/YButton.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "y_button.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "y_button-1.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "y_button-2.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Limelight/Images.xcassets/YButton.imageset/y_button-1.png b/Limelight/Images.xcassets/YButton.imageset/y_button-1.png new file mode 100644 index 00000000..626f2240 Binary files /dev/null and b/Limelight/Images.xcassets/YButton.imageset/y_button-1.png differ diff --git a/Limelight/Images.xcassets/YButton.imageset/y_button-2.png b/Limelight/Images.xcassets/YButton.imageset/y_button-2.png new file mode 100644 index 00000000..626f2240 Binary files /dev/null and b/Limelight/Images.xcassets/YButton.imageset/y_button-2.png differ diff --git a/Limelight/Images.xcassets/YButton.imageset/y_button.png b/Limelight/Images.xcassets/YButton.imageset/y_button.png new file mode 100644 index 00000000..626f2240 Binary files /dev/null and b/Limelight/Images.xcassets/YButton.imageset/y_button.png differ diff --git a/Limelight/Input/OnScreenControls.h b/Limelight/Input/OnScreenControls.h new file mode 100644 index 00000000..f9618689 --- /dev/null +++ b/Limelight/Input/OnScreenControls.h @@ -0,0 +1,16 @@ +// +// OnScreenControls.h +// Limelight +// +// Created by Diego Waxemberg on 12/28/14. +// Copyright (c) 2014 Limelight Stream. All rights reserved. +// + +#import + +@interface OnScreenControls : NSObject + +- (id) initWithView:(UIView*)view; +- (void) handleTouchDownEvent:(UIEvent*)event; +- (void) handleTouchUpEvent:(UIEvent*) event; +@end diff --git a/Limelight/Input/OnScreenControls.m b/Limelight/Input/OnScreenControls.m new file mode 100644 index 00000000..8104d1b2 --- /dev/null +++ b/Limelight/Input/OnScreenControls.m @@ -0,0 +1,193 @@ +// +// OnScreenControls.m +// Limelight +// +// Created by Diego Waxemberg on 12/28/14. +// Copyright (c) 2014 Limelight Stream. All rights reserved. +// + +#import "OnScreenControls.h" +#include "Limelight.h" + +#define UPDATE_BUTTON(x, y) (buttonFlags = \ +(y) ? (buttonFlags | (x)) : (buttonFlags & ~(x))) + +@implementation OnScreenControls { + UIView* _view; + BOOL shouldDrawControls; + CALayer* _aButton; + CALayer* _bButton; + CALayer* _xButton; + CALayer* _yButton; + CALayer* _upButton; + CALayer* _downButton; + CALayer* _leftButton; + CALayer* _rightButton; + + short buttonFlags; + short leftStickX, leftStickY; + short rightStickX, rightStickY; + char leftTrigger, rightTrigger; +} + +static const float BUTTON_SIZE = 50; +static const float BUTTON_DIST = 20; +static float BUTTON_CENTER_X; +static float BUTTON_CENTER_Y; + +static const float D_PAD_SHORT = 50; +static const float D_PAD_LONG = 65; +static const float D_PAD_DIST = 15; +static float D_PAD_CENTER_X; +static float D_PAD_CENTER_Y; + +- (id) initWithView:(UIView*)view { + self = [self init]; + _view = view; + shouldDrawControls = YES; + + D_PAD_CENTER_X = _view.frame.size.width * .15; + D_PAD_CENTER_Y = _view.frame.size.height * .75; + BUTTON_CENTER_X = _view.frame.size.width * .85; + BUTTON_CENTER_Y = _view.frame.size.height * .75; + + [self drawButtons]; + return self; +} + +- (void) drawButtons { + // create A button + _aButton = [CALayer layer]; + _aButton.frame = CGRectMake(BUTTON_CENTER_X - BUTTON_SIZE / 2, BUTTON_CENTER_Y + BUTTON_DIST, BUTTON_SIZE, BUTTON_SIZE); + _aButton.contents = (id) [UIImage imageNamed:@"AButton"].CGImage; + [_view.layer addSublayer:_aButton]; + + // create B button + _bButton = [CALayer layer]; + _bButton.frame = CGRectMake(BUTTON_CENTER_X + BUTTON_DIST, BUTTON_CENTER_Y - BUTTON_SIZE / 2, BUTTON_SIZE, BUTTON_SIZE); + _bButton.contents = (id) [UIImage imageNamed:@"BButton"].CGImage; + [_view.layer addSublayer:_bButton]; + + // create X Button + _xButton = [CALayer layer]; + _xButton.frame = CGRectMake(BUTTON_CENTER_X - BUTTON_DIST - BUTTON_SIZE, BUTTON_CENTER_Y - BUTTON_SIZE / 2, BUTTON_SIZE, BUTTON_SIZE); + _xButton.contents = (id) [UIImage imageNamed:@"XButton"].CGImage; + [_view.layer addSublayer:_xButton]; + + // create Y Button + _yButton = [CALayer layer]; + _yButton.frame = CGRectMake(BUTTON_CENTER_X - BUTTON_SIZE / 2, BUTTON_CENTER_Y - BUTTON_DIST - BUTTON_SIZE, BUTTON_SIZE, BUTTON_SIZE); + _yButton.contents = (id) [UIImage imageNamed:@"YButton"].CGImage; + [_view.layer addSublayer:_yButton]; + + // create Down button + _downButton = [CALayer layer]; + _downButton.frame = CGRectMake(D_PAD_CENTER_X - D_PAD_SHORT / 2, D_PAD_CENTER_Y + D_PAD_DIST, D_PAD_SHORT, D_PAD_LONG); + _downButton.contents = (id) [UIImage imageNamed:@"DownButton"].CGImage; + [_view.layer addSublayer:_downButton]; + + // create Right button + _rightButton = [CALayer layer]; + _rightButton.frame = CGRectMake(D_PAD_CENTER_X + D_PAD_DIST, D_PAD_CENTER_Y - D_PAD_SHORT / 2, D_PAD_LONG, D_PAD_SHORT); + _rightButton.contents = (id) [UIImage imageNamed:@"RightButton"].CGImage; + [_view.layer addSublayer:_rightButton]; + + // create Up button + _upButton = [CALayer layer]; + _upButton.frame = CGRectMake(D_PAD_CENTER_X - D_PAD_SHORT / 2, D_PAD_CENTER_Y - D_PAD_DIST - D_PAD_LONG, D_PAD_SHORT, D_PAD_LONG); + _upButton.contents = (id) [UIImage imageNamed:@"UpButton"].CGImage; + [_view.layer addSublayer:_upButton]; + + // create Left button + _leftButton = [CALayer layer]; + _leftButton.frame = CGRectMake(D_PAD_CENTER_X - D_PAD_DIST - D_PAD_LONG, D_PAD_CENTER_Y - D_PAD_SHORT / 2, D_PAD_LONG, D_PAD_SHORT); + _leftButton.contents = (id) [UIImage imageNamed:@"LeftButton"].CGImage; + [_view.layer addSublayer:_leftButton]; +} + +- (void)handleTouchDownEvent:(UIEvent*)event { + for (UITouch* touch in [event allTouches]) { + CGPoint touchLocation = [touch locationInView:_view]; + + if ([_aButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(A_FLAG, 1); + } else if ([_bButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(B_FLAG, 1); + } else if ([_xButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(X_FLAG, 1); + } else if ([_yButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(Y_FLAG, 1); + } else if ([_upButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(UP_FLAG, 1); + } else if ([_downButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(DOWN_FLAG, 1); + } else if ([_leftButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(LEFT_FLAG, 1); + } else if ([_rightButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(RIGHT_FLAG, 1); + } + /* + + UPDATE_BUTTON(LB_FLAG, gamepad.leftShoulder.pressed); + UPDATE_BUTTON(RB_FLAG, gamepad.rightShoulder.pressed); + + leftStickX = gamepad.leftThumbstick.xAxis.value * 0x7FFE; + leftStickY = gamepad.leftThumbstick.yAxis.value * 0x7FFE; + + rightStickX = gamepad.rightThumbstick.xAxis.value * 0x7FFE; + rightStickY = gamepad.rightThumbstick.yAxis.value * 0x7FFE; + + leftTrigger = gamepad.leftTrigger.value * 0xFF; + rightTrigger = gamepad.rightTrigger.value * 0xFF; + */ + // We call LiSendControllerEvent while holding a lock to prevent + // multiple simultaneous calls since this function isn't thread safe. + } + LiSendControllerEvent(buttonFlags, leftTrigger, rightTrigger, + leftStickX, leftStickY, rightStickX, rightStickY); +} + +- (void)handleTouchUpEvent:(UIEvent*)event { + + for (UITouch* touch in [event allTouches]) { + CGPoint touchLocation = [touch locationInView:_view]; + + if ([_aButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(A_FLAG, 0); + } else if ([_bButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(B_FLAG, 0); + } else if ([_xButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(X_FLAG, 0); + } else if ([_yButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(Y_FLAG, 0); + } else if ([_upButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(UP_FLAG, 0); + } else if ([_downButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(DOWN_FLAG, 0); + } else if ([_leftButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(LEFT_FLAG, 0); + } else if ([_rightButton.presentationLayer hitTest:touchLocation]) { + UPDATE_BUTTON(RIGHT_FLAG, 0); + } + /* + UPDATE_BUTTON(LB_FLAG, gamepad.leftShoulder.pressed); + UPDATE_BUTTON(RB_FLAG, gamepad.rightShoulder.pressed); + + leftStickX = gamepad.leftThumbstick.xAxis.value * 0x7FFE; + leftStickY = gamepad.leftThumbstick.yAxis.value * 0x7FFE; + + rightStickX = gamepad.rightThumbstick.xAxis.value * 0x7FFE; + rightStickY = gamepad.rightThumbstick.yAxis.value * 0x7FFE; + + leftTrigger = gamepad.leftTrigger.value * 0xFF; + rightTrigger = gamepad.rightTrigger.value * 0xFF; + */ + // We call LiSendControllerEvent while holding a lock to prevent + // multiple simultaneous calls since this function isn't thread safe. + } + LiSendControllerEvent(buttonFlags, leftTrigger, rightTrigger, + leftStickX, leftStickY, rightStickX, rightStickY); +} + + +@end diff --git a/Limelight/Input/StreamView.h b/Limelight/Input/StreamView.h index b722ed91..a7aa4e5f 100644 --- a/Limelight/Input/StreamView.h +++ b/Limelight/Input/StreamView.h @@ -10,4 +10,6 @@ @interface StreamView : UIView +- (void) setupOnScreenControls; + @end diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 905d84d3..748ed989 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -8,17 +8,23 @@ #import "StreamView.h" #include +#import "OnScreenControls.h" @implementation StreamView { CGPoint touchLocation; BOOL touchMoved; + OnScreenControls* onScreenControls; +} + +- (void) setupOnScreenControls { + onScreenControls = [[OnScreenControls alloc] initWithView:self]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; touchLocation = [touch locationInView:self]; touchMoved = false; - + [onScreenControls handleTouchDownEvent:event]; NSLog(@"Touch down"); } @@ -53,8 +59,7 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Touch up"); - - + [onScreenControls handleTouchUpEvent:event]; if (!touchMoved) { if ([[event allTouches] count] == 2) { NSLog(@"Sending right mouse button press"); diff --git a/Limelight/Stream/StreamManager.m b/Limelight/Stream/StreamManager.m index bc648009..8ccc07c5 100644 --- a/Limelight/Stream/StreamManager.m +++ b/Limelight/Stream/StreamManager.m @@ -10,6 +10,7 @@ #import "CryptoManager.h" #import "HttpManager.h" #import "Utils.h" +#import "OnScreenControls.h" @implementation StreamManager { StreamConfiguration* _config; diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 30c315ad..20b9ebe6 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -11,6 +11,7 @@ #import "VideoDecoderRenderer.h" #import "StreamManager.h" #import "ControllerSupport.h" +#import "StreamView.h" #include #include @@ -63,6 +64,7 @@ [self.stageLabel setText:@"Waiting for first frame..."]; [self.stageLabel sizeToFit]; }); + [(StreamView*)self.view setupOnScreenControls]; } - (void)connectionTerminated:(long)errorCode {