added L3/R3 support to full on-screen controls

This commit is contained in:
Diego Waxemberg 2015-01-09 22:10:32 -05:00
parent 0a4fa5fc6c
commit 01902536ab
3 changed files with 31 additions and 6 deletions

View File

@ -384,15 +384,15 @@
FB290CFA19B2C406004C83CF /* Supporting Files */,
FB290D0219B2C406004C83CF /* AppDelegate.h */,
FB290D0319B2C406004C83CF /* AppDelegate.m */,
FBDE86DE19F7A837001C18A8 /* UIComputerView.h */,
FBDE86DF19F7A837001C18A8 /* UIComputerView.m */,
FBDE86E419F82297001C18A8 /* UIAppView.h */,
FBDE86E519F82297001C18A8 /* UIAppView.m */,
FB290E7819B37D81004C83CF /* iPad.storyboard */,
FB290E7A19B38036004C83CF /* iPhone.storyboard */,
FB89463719F6473800339C8A /* Launch Screen.xib */,
FB290D0819B2C406004C83CF /* Images.xcassets */,
FB290D0519B2C406004C83CF /* Limelight.xcdatamodeld */,
FBDE86DE19F7A837001C18A8 /* UIComputerView.h */,
FBDE86DF19F7A837001C18A8 /* UIComputerView.m */,
FBDE86E419F82297001C18A8 /* UIAppView.h */,
FBDE86E519F82297001C18A8 /* UIAppView.m */,
);
path = Limelight;
sourceTree = "<group>";

View File

@ -50,6 +50,9 @@
UITouch* _l1Touch;
UITouch* _l2Touch;
NSDate* l3TouchStart;
NSDate* r3TouchStart;
UIView* _view;
OnScreenControlsLevel _level;
@ -67,6 +70,7 @@ static const float D_PAD_DIST = 15;
static float D_PAD_CENTER_X;
static float D_PAD_CENTER_Y;
static const double STICK_CLICK_RATE = 100;
static const float STICK_INNER_SIZE = 80;
static const float STICK_OUTER_SIZE = 120;
static const float STICK_DEAD_ZONE = .1;
@ -528,9 +532,27 @@ static float L2_Y;
_r2Touch = touch;
updated = true;
} else if ([_leftStick.presentationLayer hitTest:touchLocation]) {
if (l3TouchStart != nil) {
// Find elapsed time and convert to milliseconds
// Use (-) modifier to conversion since receiver is earlier than now
double l3TouchTime = [l3TouchStart timeIntervalSinceNow] * -1000.0;
if (l3TouchTime < STICK_CLICK_RATE) {
[_controllerSupport setButtonFlag:LS_CLK_FLAG];
updated = true;
}
}
_lsTouch = touch;
stickTouch = true;
} else if ([_rightStick.presentationLayer hitTest:touchLocation]) {
if (r3TouchStart != nil) {
// Find elapsed time and convert to milliseconds
// Use (-) modifier to conversion since receiver is earlier than now
double r3TouchTime = [r3TouchStart timeIntervalSinceNow] * -1000.0;
if (r3TouchTime < STICK_CLICK_RATE) {
[_controllerSupport setButtonFlag:RS_CLK_FLAG];
updated = true;
}
}
_rsTouch = touch;
stickTouch = true;
}
@ -603,11 +625,15 @@ static float L2_Y;
} else if (touch == _lsTouch) {
_leftStick.frame = CGRectMake(LS_CENTER_X - STICK_INNER_SIZE / 2, LS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
[_controllerSupport updateLeftStick:0 y:0];
updated = true;
[_controllerSupport clearButtonFlag:LS_CLK_FLAG];
l3TouchStart = [NSDate date];
_lsTouch = nil;
updated = true;
} else if (touch == _rsTouch) {
_rightStick.frame = CGRectMake(RS_CENTER_X - STICK_INNER_SIZE / 2, RS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
[_controllerSupport updateRightStick:0 y:0];
[_controllerSupport clearButtonFlag:RS_CLK_FLAG];
r3TouchStart = [NSDate date];
_rsTouch = nil;
updated = true;
}

View File

@ -30,7 +30,6 @@
NSLog(@"Setting manual on-screen controls level: %d", (int)level);
[onScreenControls setLevel:level];
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {