added l3/r3 support to simple on-screen controls
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 60 KiB |
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x",
|
||||||
|
"filename" : "L3.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x",
|
||||||
|
"filename" : "L3-1.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x",
|
||||||
|
"filename" : "L3-2.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 68 KiB |
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x",
|
||||||
|
"filename" : "R3.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x",
|
||||||
|
"filename" : "R3-1.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x",
|
||||||
|
"filename" : "R3-2.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 91 KiB |
@@ -30,8 +30,10 @@
|
|||||||
CALayer* _selectButton;
|
CALayer* _selectButton;
|
||||||
CALayer* _r1Button;
|
CALayer* _r1Button;
|
||||||
CALayer* _r2Button;
|
CALayer* _r2Button;
|
||||||
|
CALayer* _r3Button;
|
||||||
CALayer* _l1Button;
|
CALayer* _l1Button;
|
||||||
CALayer* _l2Button;
|
CALayer* _l2Button;
|
||||||
|
CALayer* _l3Button;
|
||||||
|
|
||||||
UITouch* _aTouch;
|
UITouch* _aTouch;
|
||||||
UITouch* _bTouch;
|
UITouch* _bTouch;
|
||||||
@@ -47,12 +49,17 @@
|
|||||||
UITouch* _selectTouch;
|
UITouch* _selectTouch;
|
||||||
UITouch* _r1Touch;
|
UITouch* _r1Touch;
|
||||||
UITouch* _r2Touch;
|
UITouch* _r2Touch;
|
||||||
|
UITouch* _r3Touch;
|
||||||
UITouch* _l1Touch;
|
UITouch* _l1Touch;
|
||||||
UITouch* _l2Touch;
|
UITouch* _l2Touch;
|
||||||
|
UITouch* _l3Touch;
|
||||||
|
|
||||||
NSDate* l3TouchStart;
|
NSDate* l3TouchStart;
|
||||||
NSDate* r3TouchStart;
|
NSDate* r3TouchStart;
|
||||||
|
|
||||||
|
BOOL l3Set;
|
||||||
|
BOOL r3Set;
|
||||||
|
|
||||||
UIView* _view;
|
UIView* _view;
|
||||||
OnScreenControlsLevel _level;
|
OnScreenControlsLevel _level;
|
||||||
|
|
||||||
@@ -89,17 +96,22 @@ static const float SELECT_HEIGHT = 30;
|
|||||||
static float SELECT_X;
|
static float SELECT_X;
|
||||||
static float SELECT_Y;
|
static float SELECT_Y;
|
||||||
|
|
||||||
static const float BUMPER_SIZE = 70;
|
static const float BUMPER_SIZE = 45;
|
||||||
static const float TRIGGER_SIZE = 80;
|
static const float TRIGGER_SIZE = 60;
|
||||||
|
static const float L3R3_SIZE = 80;
|
||||||
|
|
||||||
static float R1_X;
|
static float R1_X;
|
||||||
static float R1_Y;
|
static float R1_Y;
|
||||||
static float R2_X;
|
static float R2_X;
|
||||||
static float R2_Y;
|
static float R2_Y;
|
||||||
|
static float R3_X;
|
||||||
|
static float R3_Y;
|
||||||
static float L1_X;
|
static float L1_X;
|
||||||
static float L1_Y;
|
static float L1_Y;
|
||||||
static float L2_X;
|
static float L2_X;
|
||||||
static float L2_Y;
|
static float L2_Y;
|
||||||
|
static float L3_X;
|
||||||
|
static float L3_Y;
|
||||||
|
|
||||||
- (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport {
|
- (id) initWithView:(UIView*)view controllerSup:(ControllerSupport*)controllerSupport {
|
||||||
self = [self init];
|
self = [self init];
|
||||||
@@ -118,6 +130,8 @@ static float L2_Y;
|
|||||||
_r1Button = [CALayer layer];
|
_r1Button = [CALayer layer];
|
||||||
_l2Button = [CALayer layer];
|
_l2Button = [CALayer layer];
|
||||||
_r2Button = [CALayer layer];
|
_r2Button = [CALayer layer];
|
||||||
|
_l3Button = [CALayer layer];
|
||||||
|
_r3Button = [CALayer layer];
|
||||||
_startButton = [CALayer layer];
|
_startButton = [CALayer layer];
|
||||||
_selectButton = [CALayer layer];
|
_selectButton = [CALayer layer];
|
||||||
_leftStickBackground = [CALayer layer];
|
_leftStickBackground = [CALayer layer];
|
||||||
@@ -141,6 +155,7 @@ static float L2_Y;
|
|||||||
[self hideTriggers];
|
[self hideTriggers];
|
||||||
[self hideStartSelect];
|
[self hideStartSelect];
|
||||||
[self hideSticks];
|
[self hideSticks];
|
||||||
|
[self hideL3R3];
|
||||||
break;
|
break;
|
||||||
case OnScreenControlsLevelAutoGCGamepad:
|
case OnScreenControlsLevelAutoGCGamepad:
|
||||||
// GCGamepad is missing triggers, both analog sticks,
|
// GCGamepad is missing triggers, both analog sticks,
|
||||||
@@ -152,7 +167,7 @@ static float L2_Y;
|
|||||||
[self drawTriggers];
|
[self drawTriggers];
|
||||||
[self drawStartSelect];
|
[self drawStartSelect];
|
||||||
[self drawSticks];
|
[self drawSticks];
|
||||||
// TODO: Draw L3 and R3 buttons
|
[self drawL3R3];
|
||||||
break;
|
break;
|
||||||
case OnScreenControlsLevelAutoGCExtendedGamepad:
|
case OnScreenControlsLevelAutoGCExtendedGamepad:
|
||||||
// GCExtendedGamepad is missing R3, L3, and select
|
// GCExtendedGamepad is missing R3, L3, and select
|
||||||
@@ -163,7 +178,7 @@ static float L2_Y;
|
|||||||
[self hideTriggers];
|
[self hideTriggers];
|
||||||
[self drawStartSelect];
|
[self drawStartSelect];
|
||||||
[self hideSticks];
|
[self hideSticks];
|
||||||
// TODO: Draw L3 and R3 buttons
|
[self drawL3R3];
|
||||||
break;
|
break;
|
||||||
case OnScreenControlsLevelSimple:
|
case OnScreenControlsLevelSimple:
|
||||||
[self setupSimpleControls];
|
[self setupSimpleControls];
|
||||||
@@ -173,6 +188,7 @@ static float L2_Y;
|
|||||||
[self hideButtons];
|
[self hideButtons];
|
||||||
[self hideBumpers];
|
[self hideBumpers];
|
||||||
[self hideSticks];
|
[self hideSticks];
|
||||||
|
[self hideL3R3];
|
||||||
break;
|
break;
|
||||||
case OnScreenControlsLevelFull:
|
case OnScreenControlsLevelFull:
|
||||||
[self setupComplexControls];
|
[self setupComplexControls];
|
||||||
@@ -182,6 +198,7 @@ static float L2_Y;
|
|||||||
[self drawBumpers];
|
[self drawBumpers];
|
||||||
[self drawTriggers];
|
[self drawTriggers];
|
||||||
[self drawSticks];
|
[self drawSticks];
|
||||||
|
[self hideL3R3]; // Full controls don't need these they have the sticks
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NSLog(@"Unknown on-screen controls level: %d", (int)_level);
|
NSLog(@"Unknown on-screen controls level: %d", (int)_level);
|
||||||
@@ -196,8 +213,6 @@ static float L2_Y;
|
|||||||
|
|
||||||
START_Y = _view.frame.size.height * .9;
|
START_Y = _view.frame.size.height * .9;
|
||||||
SELECT_Y = _view.frame.size.height * .9;
|
SELECT_Y = _view.frame.size.height * .9;
|
||||||
|
|
||||||
// TODO: Position L3 and R3 at the bottom of the screen
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For GCGamepad controls we move triggers, start, and select
|
// For GCGamepad controls we move triggers, start, and select
|
||||||
@@ -248,6 +263,10 @@ static float L2_Y;
|
|||||||
R1_Y = _view.frame.size.height * .25;
|
R1_Y = _view.frame.size.height * .25;
|
||||||
R2_X = _view.frame.size.width * .85;
|
R2_X = _view.frame.size.width * .85;
|
||||||
R2_Y = _view.frame.size.height * .1;
|
R2_Y = _view.frame.size.height * .1;
|
||||||
|
L3_X = _view.frame.size.width * .25;
|
||||||
|
L3_Y = _view.frame.size.height * .85;
|
||||||
|
R3_X = _view.frame.size.width * .75;
|
||||||
|
R3_Y = _view.frame.size.height * .85;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawButtons {
|
- (void) drawButtons {
|
||||||
@@ -334,7 +353,6 @@ static float L2_Y;
|
|||||||
_leftStickBackground.contents = (id) [UIImage imageNamed:@"StickOuter"].CGImage;
|
_leftStickBackground.contents = (id) [UIImage imageNamed:@"StickOuter"].CGImage;
|
||||||
[_view.layer addSublayer:_leftStickBackground];
|
[_view.layer addSublayer:_leftStickBackground];
|
||||||
|
|
||||||
_leftStick = [CALayer layer];
|
|
||||||
_leftStick.frame = CGRectMake(LS_CENTER_X - STICK_INNER_SIZE / 2, LS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
|
_leftStick.frame = CGRectMake(LS_CENTER_X - STICK_INNER_SIZE / 2, LS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
|
||||||
_leftStick.contents = (id) [UIImage imageNamed:@"StickInner"].CGImage;
|
_leftStick.contents = (id) [UIImage imageNamed:@"StickInner"].CGImage;
|
||||||
[_view.layer addSublayer:_leftStick];
|
[_view.layer addSublayer:_leftStick];
|
||||||
@@ -344,12 +362,25 @@ static float L2_Y;
|
|||||||
_rightStickBackground.contents = (id) [UIImage imageNamed:@"StickOuter"].CGImage;
|
_rightStickBackground.contents = (id) [UIImage imageNamed:@"StickOuter"].CGImage;
|
||||||
[_view.layer addSublayer:_rightStickBackground];
|
[_view.layer addSublayer:_rightStickBackground];
|
||||||
|
|
||||||
_rightStick = [CALayer layer];
|
|
||||||
_rightStick.frame = CGRectMake(RS_CENTER_X - STICK_INNER_SIZE / 2, RS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
|
_rightStick.frame = CGRectMake(RS_CENTER_X - STICK_INNER_SIZE / 2, RS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
|
||||||
_rightStick.contents = (id) [UIImage imageNamed:@"StickInner"].CGImage;
|
_rightStick.contents = (id) [UIImage imageNamed:@"StickInner"].CGImage;
|
||||||
[_view.layer addSublayer:_rightStick];
|
[_view.layer addSublayer:_rightStick];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) drawL3R3 {
|
||||||
|
_l3Button.frame = CGRectMake(L3_X - L3R3_SIZE / 2, L3_Y - L3R3_SIZE / 2, L3R3_SIZE, L3R3_SIZE);
|
||||||
|
_l3Button.contents = (id) [UIImage imageNamed:@"L3"].CGImage;
|
||||||
|
_l3Button.cornerRadius = L3R3_SIZE / 2;
|
||||||
|
_l3Button.borderColor = [UIColor colorWithRed:15.f/255 green:160.f/255 blue:40.f/255 alpha:1.f].CGColor;
|
||||||
|
[_view.layer addSublayer:_l3Button];
|
||||||
|
|
||||||
|
_r3Button.frame = CGRectMake(R3_X - L3R3_SIZE / 2, R3_Y - L3R3_SIZE / 2, L3R3_SIZE, L3R3_SIZE);
|
||||||
|
_r3Button.contents = (id) [UIImage imageNamed:@"R3"].CGImage;
|
||||||
|
_r3Button.cornerRadius = L3R3_SIZE / 2;
|
||||||
|
_r3Button.borderColor = [UIColor colorWithRed:15.f/255 green:160.f/255 blue:40.f/255 alpha:1.f].CGColor;
|
||||||
|
[_view.layer addSublayer:_r3Button];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) hideButtons {
|
- (void) hideButtons {
|
||||||
[_aButton removeFromSuperlayer];
|
[_aButton removeFromSuperlayer];
|
||||||
[_bButton removeFromSuperlayer];
|
[_bButton removeFromSuperlayer];
|
||||||
@@ -383,6 +414,11 @@ static float L2_Y;
|
|||||||
[_rightStick removeFromSuperlayer];
|
[_rightStick removeFromSuperlayer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) hideL3R3 {
|
||||||
|
[_l3Button removeFromSuperlayer];
|
||||||
|
[_r3Button removeFromSuperlayer];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) handleTouchMovedEvent:touches {
|
- (BOOL) handleTouchMovedEvent:touches {
|
||||||
BOOL updated = false;
|
BOOL updated = false;
|
||||||
BOOL buttonTouch = false;
|
BOOL buttonTouch = false;
|
||||||
@@ -461,6 +497,10 @@ static float L2_Y;
|
|||||||
buttonTouch = true;
|
buttonTouch = true;
|
||||||
} else if (touch == _r2Touch) {
|
} else if (touch == _r2Touch) {
|
||||||
buttonTouch = true;
|
buttonTouch = true;
|
||||||
|
} else if (touch == _l3Touch) {
|
||||||
|
buttonTouch = true;
|
||||||
|
} else if (touch == _r3Touch) {
|
||||||
|
buttonTouch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updated) {
|
if (updated) {
|
||||||
@@ -531,6 +571,28 @@ static float L2_Y;
|
|||||||
[_controllerSupport updateRightTrigger:0xFF];
|
[_controllerSupport updateRightTrigger:0xFF];
|
||||||
_r2Touch = touch;
|
_r2Touch = touch;
|
||||||
updated = true;
|
updated = true;
|
||||||
|
} else if ([_l3Button.presentationLayer hitTest:touchLocation]) {
|
||||||
|
if (l3Set) {
|
||||||
|
[_controllerSupport clearButtonFlag:LS_CLK_FLAG];
|
||||||
|
_l3Button.borderWidth = 0.0f;
|
||||||
|
} else {
|
||||||
|
[_controllerSupport setButtonFlag:LS_CLK_FLAG];
|
||||||
|
_l3Button.borderWidth = 2.0f;
|
||||||
|
}
|
||||||
|
l3Set = !l3Set;
|
||||||
|
_l3Touch = touch;
|
||||||
|
updated = true;
|
||||||
|
} else if ([_r3Button.presentationLayer hitTest:touchLocation]) {
|
||||||
|
if (r3Set) {
|
||||||
|
[_controllerSupport clearButtonFlag:RS_CLK_FLAG];
|
||||||
|
_r3Button.borderWidth = 0.0f;
|
||||||
|
} else {
|
||||||
|
[_controllerSupport setButtonFlag:RS_CLK_FLAG];
|
||||||
|
_r3Button.borderWidth = 2.0f;
|
||||||
|
}
|
||||||
|
r3Set = !r3Set;
|
||||||
|
_r3Touch = touch;
|
||||||
|
updated = true;
|
||||||
} else if ([_leftStick.presentationLayer hitTest:touchLocation]) {
|
} else if ([_leftStick.presentationLayer hitTest:touchLocation]) {
|
||||||
if (l3TouchStart != nil) {
|
if (l3TouchStart != nil) {
|
||||||
// Find elapsed time and convert to milliseconds
|
// Find elapsed time and convert to milliseconds
|
||||||
|
|||||||