ios: diagonal DPad buttons. Pan between buttons. Help tip for menu

Add diagonal DPad buttons
Allow switching virtual button without lifting finger.
Display help tip on first startup about pausing/opening menu.
This commit is contained in:
Flyinghead 2022-05-27 18:32:55 +02:00
parent db8508cefc
commit 22ad95cbfe
3 changed files with 156 additions and 141 deletions

View File

@ -27,6 +27,7 @@
UITouch *joyTouch;
CGPoint joyBias;
std::shared_ptr<IOSVirtualGamepad> virtualGamepad;
NSMutableDictionary *touchToButton;
}
@end
@ -38,10 +39,23 @@
[super viewDidLoad];
virtualGamepad = std::make_shared<IOSVirtualGamepad>();
GamepadDevice::Register(virtualGamepad);
touchToButton = [[NSMutableDictionary alloc] init];
}
- (void)showController:(UIView *)parentView
{
if (!cfgLoadBool("help", "PauseGameTip", false))
{
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Help Tip"
message:@"To pause the game, press Up+Down or Left+Right on the virtual DPad."
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
cfgSaveBool("help", "PauseGameTip", true);
}];
[alert addAction:defaultAction];
}
[parentView addSubview:self.view];
}
@ -55,16 +69,6 @@
return self.view.window != nil;
}
- (IBAction)keycodeDown:(id)sender
{
virtualGamepad->gamepad_btn_input((u32)((UIButton *)sender).tag, true);
}
- (IBAction)keycodeUp:(id)sender
{
virtualGamepad->gamepad_btn_input((u32)((UIButton *)sender).tag, false);
}
- (void)resetTouch
{
joyTouch = nil;
@ -76,29 +80,42 @@
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
{
if (joyTouch == nil) {
for (UITouch *touch in touches) {
CGPoint loc = [touch locationInView:[self joystickBackground]];
for (UITouch *touch in touches) {
if (joyTouch == nil) {
CGPoint loc = [touch locationInView:self.joystickBackground];
if ([self.joystickBackground pointInside:loc withEvent:event]) {
joyTouch = touch;
joyBias = loc;
virtualGamepad->gamepad_axis_input(IOS_AXIS_LX, 0);
virtualGamepad->gamepad_axis_input(IOS_AXIS_LY, 0);
break;
continue;
}
}
CGPoint point = [touch locationInView:self.view];
UIView *touchedView = [self.view hitTest:point withEvent:nil];
NSValue *key = [NSValue valueWithPointer:(const void *)touch];
if (touchedView.tag != 0 && touchToButton[key] == nil) {
touchToButton[key] = touchedView;
// button down
virtualGamepad->gamepad_btn_input((u32)touchedView.tag, true);
}
}
[super touchesBegan:touches withEvent:event];
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
{
if (joyTouch != nil) {
for (UITouch *touch in touches) {
if (touch == joyTouch) {
[self resetTouch];
break;
}
for (UITouch *touch in touches) {
if (touch == joyTouch) {
[self resetTouch];
continue;
}
NSValue *key = [NSValue valueWithPointer:(const void *)touch];
UIView *button = touchToButton[key];
if (button != nil) {
[touchToButton removeObjectForKey:key];
// button up
virtualGamepad->gamepad_btn_input((u32)button.tag, false);
}
}
[super touchesEnded:touches withEvent:event];
@ -106,20 +123,35 @@
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
{
if (joyTouch != nil) {
for (UITouch *touch in touches) {
if (touch == joyTouch) {
CGPoint pos = [touch locationInView:[self joystickBackground]];
pos.x -= joyBias.x;
pos.y -= joyBias.y;
pos.x = std::max<CGFloat>(std::min<CGFloat>(25.0, pos.x), -25.0);
pos.y = std::max<CGFloat>(std::min<CGFloat>(25.0, pos.y), -25.0);
self.joyXConstraint.constant = pos.x;
self.joyYConstraint.constant = pos.y;
virtualGamepad->gamepad_axis_input(IOS_AXIS_LX, (s8)std::round(pos.x * 32767.0 / 25.0));
virtualGamepad->gamepad_axis_input(IOS_AXIS_LY, (s8)std::round(pos.y * 32767.0 / 25.0));
break;
}
for (UITouch *touch in touches) {
if (touch == joyTouch) {
CGPoint pos = [touch locationInView:[self joystickBackground]];
pos.x -= joyBias.x;
pos.y -= joyBias.y;
pos.x = std::max<CGFloat>(std::min<CGFloat>(25.0, pos.x), -25.0);
pos.y = std::max<CGFloat>(std::min<CGFloat>(25.0, pos.y), -25.0);
self.joyXConstraint.constant = pos.x;
self.joyYConstraint.constant = pos.y;
virtualGamepad->gamepad_axis_input(IOS_AXIS_LX, (s8)std::round(pos.x * 32767.0 / 25.0));
virtualGamepad->gamepad_axis_input(IOS_AXIS_LY, (s8)std::round(pos.y * 32767.0 / 25.0));
continue;
}
CGPoint point = [touch locationInView:self.view];
UIView *touchedView = [self.view hitTest:point withEvent:nil];
NSValue *key = [NSValue valueWithPointer:(const void *)touch];
UIView *button = touchToButton[key];
if (button != nil && touchedView.tag != button.tag) {
// button up
virtualGamepad->gamepad_btn_input((u32)button.tag, false);
touchToButton[key] = touchedView;
// button down
virtualGamepad->gamepad_btn_input((u32)touchedView.tag, true);
}
else if (button == nil && touchedView.tag != 0)
{
touchToButton[key] = touchedView;
// button down
virtualGamepad->gamepad_btn_input((u32)touchedView.tag, true);
}
}
[super touchesMoved:touches withEvent:event];
@ -127,12 +159,17 @@
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
{
if (joyTouch != nil) {
for (UITouch *touch in touches) {
if (touch == joyTouch) {
[self resetTouch];
break;
}
for (UITouch *touch in touches) {
if (touch == joyTouch) {
[self resetTouch];
continue;
}
NSValue *key = [NSValue valueWithPointer:(const void *)touch];
UIView *button = touchToButton[key];
if (button != nil) {
[touchToButton removeObjectForKey:key];
// button up
virtualGamepad->gamepad_btn_input((u32)button.tag, false);
}
}
[super touchesCancelled:touches withEvent:event];

View File

@ -21,16 +21,9 @@
<view multipleTouchEnabled="YES" alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3M7-1s-N5r">
<rect key="frame" x="0.0" y="0.0" width="812" height="375"/>
<subviews>
<button opaque="NO" multipleTouchEnabled="YES" tag="14" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8Gl-Iv-u8L" userLabel="LT-Button">
<view opaque="NO" multipleTouchEnabled="YES" tag="14" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8Gl-Iv-u8L" userLabel="LT-Button">
<rect key="frame" x="598" y="146" width="80" height="40"/>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="34L-sO-g81"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="iDv-U3-6OX"/>
</connections>
</button>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="RTrigger" translatesAutoresizingMaskIntoConstraints="NO" id="Cjn-zx-eSs">
<rect key="frame" x="688" y="146" width="80" height="40"/>
<constraints>
@ -38,16 +31,9 @@
<constraint firstAttribute="height" constant="40" id="uA3-z1-wS7"/>
</constraints>
</imageView>
<button opaque="NO" multipleTouchEnabled="YES" tag="15" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="V8J-vG-dlF" userLabel="RT-Button">
<view opaque="NO" multipleTouchEnabled="YES" tag="15" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="V8J-vG-dlF" userLabel="RT-Button">
<rect key="frame" x="688" y="146" width="80" height="40"/>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="vPf-qF-m13"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="hQh-8f-5jG"/>
</connections>
</button>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="JoystickButton" translatesAutoresizingMaskIntoConstraints="NO" id="ivh-8r-bw3" userLabel="JoystickThumbpad">
<rect key="frame" x="64" y="255" width="100" height="100"/>
<constraints>
@ -65,62 +51,43 @@
<constraint firstAttribute="height" constant="140" id="fly-c3-Ajo"/>
</constraints>
</imageView>
<button opaque="NO" multipleTouchEnabled="YES" tag="7" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rp6-Nd-1qa" userLabel="L-Button">
<view opaque="NO" multipleTouchEnabled="YES" tag="10" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bc4-Lc-Ghm" userLabel="UR-Button">
<rect key="frame" x="134" y="85" width="50" height="50"/>
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="11" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7rQ-cq-4t8" userLabel="UL-Button">
<rect key="frame" x="44" y="85" width="50" height="50"/>
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="12" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="f6y-OJ-0oT" userLabel="DL-Button">
<rect key="frame" x="44" y="175" width="50" height="50"/>
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="7" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rp6-Nd-1qa" userLabel="L-Button">
<rect key="frame" x="44" y="135" width="46" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="46" id="MX4-af-OJg"/>
<constraint firstAttribute="height" constant="40" id="yGw-c7-7x8"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="3Yw-AP-xVf"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="5gI-j0-ANf"/>
</connections>
</button>
<button opaque="NO" multipleTouchEnabled="YES" tag="8" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CVH-hw-R8F" userLabel="R-Button">
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="8" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CVH-hw-R8F" userLabel="R-Button">
<rect key="frame" x="138" y="135" width="46" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="9OW-42-b64"/>
<constraint firstAttribute="width" constant="46" id="grQ-i7-YHe"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="2Dv-zb-f8V"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="woi-3Y-IfD"/>
</connections>
</button>
<button opaque="NO" multipleTouchEnabled="YES" tag="5" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WMD-Fv-ibu" userLabel="U-Button">
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WMD-Fv-ibu" userLabel="U-Button">
<rect key="frame" x="94" y="85" width="40" height="46"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="2gU-xW-ddx"/>
<constraint firstAttribute="width" constant="40" id="oUv-ex-E9I"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="kT6-yy-ZtY"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="R0R-dl-GAG"/>
</connections>
</button>
<button opaque="NO" multipleTouchEnabled="YES" tag="6" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="s7g-nq-lRU" userLabel="D-Button">
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="6" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="s7g-nq-lRU" userLabel="D-Button">
<rect key="frame" x="94" y="179" width="40" height="46"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="3IG-k8-ER3"/>
<constraint firstAttribute="height" constant="46" id="4vu-3O-H8J"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="Wck-mk-4Py"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="Qox-hz-p3A"/>
</connections>
</button>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ABXYPad" translatesAutoresizingMaskIntoConstraints="NO" id="xbP-E4-fCE">
<rect key="frame" x="608" y="205" width="160" height="160"/>
<constraints>
@ -128,62 +95,34 @@
<constraint firstAttribute="height" constant="160" id="lVn-RY-tWm"/>
</constraints>
</imageView>
<button opaque="NO" multipleTouchEnabled="YES" tag="3" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iwO-7q-c8H" userLabel="X-Button">
<view opaque="NO" multipleTouchEnabled="YES" tag="3" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iwO-7q-c8H" userLabel="X-Button">
<rect key="frame" x="608" y="255" width="60" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="4Yf-ri-Ccb"/>
<constraint firstAttribute="width" constant="60" id="mnO-1S-Phd"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="IBH-TK-vfV"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="dhr-NT-lcF"/>
</connections>
</button>
<button opaque="NO" multipleTouchEnabled="YES" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7LB-OY-vh3" userLabel="B-Button">
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="2" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7LB-OY-vh3" userLabel="B-Button">
<rect key="frame" x="708" y="255" width="60" height="60"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="1YC-G4-kwg"/>
<constraint firstAttribute="height" constant="60" id="LHC-wi-Yap"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="dhg-58-L8C"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="zqg-KK-Wxb"/>
</connections>
</button>
<button opaque="NO" multipleTouchEnabled="YES" tag="4" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hGZ-v7-VA5" userLabel="Y-Button">
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="4" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hGZ-v7-VA5" userLabel="Y-Button">
<rect key="frame" x="658" y="205" width="60" height="60"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="gv4-it-7ly"/>
<constraint firstAttribute="height" constant="60" id="hx2-N9-Lba"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="tyb-H4-TqJ"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="oai-Xb-scl"/>
</connections>
</button>
<button opaque="NO" multipleTouchEnabled="YES" tag="1" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iKO-3z-Ias" userLabel="A-Button">
</view>
<view opaque="NO" multipleTouchEnabled="YES" tag="1" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iKO-3z-Ias" userLabel="A-Button">
<rect key="frame" x="658" y="305" width="60" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="Dgi-6d-cHy"/>
<constraint firstAttribute="width" constant="60" id="L1S-2O-QBB"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="Ysa-m4-KnN"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="MTf-ND-WNy"/>
</connections>
</button>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Start" translatesAutoresizingMaskIntoConstraints="NO" id="9K0-cV-7zu">
<rect key="frame" x="366" y="310" width="80" height="40"/>
<constraints>
@ -191,20 +130,13 @@
<constraint firstAttribute="width" constant="80" id="BpH-iH-but"/>
</constraints>
</imageView>
<button opaque="NO" multipleTouchEnabled="YES" tag="9" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VtI-tC-PSX" userLabel="S-Button">
<view opaque="NO" multipleTouchEnabled="YES" tag="9" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VtI-tC-PSX" userLabel="S-Button">
<rect key="frame" x="379" y="310" width="54" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="54" id="HjR-fP-Q1s"/>
<constraint firstAttribute="height" constant="40" id="MK6-rm-vpj"/>
</constraints>
<state key="normal">
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="keycodeDown:" destination="-1" eventType="touchDown" id="kwd-jB-5Wn"/>
<action selector="keycodeUp:" destination="-1" eventType="touchUpInside" id="gHx-tA-QlF"/>
</connections>
</button>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LTrigger" translatesAutoresizingMaskIntoConstraints="NO" id="H57-MD-elm">
<rect key="frame" x="598" y="146" width="80" height="40"/>
<constraints>
@ -212,25 +144,37 @@
<constraint firstAttribute="width" constant="80" id="Pj7-YU-3Ze"/>
</constraints>
</imageView>
<view opaque="NO" multipleTouchEnabled="YES" tag="13" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ccY-OZ-Jlp" userLabel="DR-Button">
<rect key="frame" x="134" y="175" width="50" height="50"/>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="DJj-LJ-xnv"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="WMD-Fv-ibu" firstAttribute="leading" secondItem="7rQ-cq-4t8" secondAttribute="trailing" id="1Qw-rO-H58"/>
<constraint firstItem="f6y-OJ-0oT" firstAttribute="top" secondItem="rp6-Nd-1qa" secondAttribute="bottom" id="2bH-uq-Rdf"/>
<constraint firstItem="f6y-OJ-0oT" firstAttribute="leading" secondItem="FLe-Gr-hny" secondAttribute="leading" id="2hm-bn-5R6"/>
<constraint firstItem="s7g-nq-lRU" firstAttribute="centerX" secondItem="FLe-Gr-hny" secondAttribute="centerX" id="4bj-Mc-SN7"/>
<constraint firstItem="7rQ-cq-4t8" firstAttribute="leading" secondItem="FLe-Gr-hny" secondAttribute="leading" id="4xu-d6-7ej"/>
<constraint firstItem="bc4-Lc-Ghm" firstAttribute="trailing" secondItem="FLe-Gr-hny" secondAttribute="trailing" id="6Hu-3B-LKi"/>
<constraint firstItem="V8J-vG-dlF" firstAttribute="height" secondItem="Cjn-zx-eSs" secondAttribute="height" id="77t-Hb-AxC"/>
<constraint firstItem="DJj-LJ-xnv" firstAttribute="trailing" secondItem="xbP-E4-fCE" secondAttribute="trailing" id="84h-PU-NtS"/>
<constraint firstItem="OMP-L6-n0A" firstAttribute="top" secondItem="FLe-Gr-hny" secondAttribute="bottom" constant="20" id="9o9-R0-BDC"/>
<constraint firstItem="ivh-8r-bw3" firstAttribute="centerY" secondItem="OMP-L6-n0A" secondAttribute="centerY" id="AGO-kZ-c5L"/>
<constraint firstItem="8Gl-Iv-u8L" firstAttribute="height" secondItem="H57-MD-elm" secondAttribute="height" id="BMW-0T-VdJ"/>
<constraint firstItem="ccY-OZ-Jlp" firstAttribute="bottom" secondItem="FLe-Gr-hny" secondAttribute="bottom" id="CKI-9B-7L9"/>
<constraint firstItem="8Gl-Iv-u8L" firstAttribute="width" secondItem="H57-MD-elm" secondAttribute="width" id="DV9-P9-Sxd"/>
<constraint firstItem="Cjn-zx-eSs" firstAttribute="leading" secondItem="H57-MD-elm" secondAttribute="trailing" constant="10" id="ENl-Fx-mge"/>
<constraint firstItem="iwO-7q-c8H" firstAttribute="centerY" secondItem="xbP-E4-fCE" secondAttribute="centerY" id="Eo6-Na-ui9"/>
<constraint firstItem="xbP-E4-fCE" firstAttribute="top" secondItem="Cjn-zx-eSs" secondAttribute="bottom" constant="19" id="FSR-y8-8rc"/>
<constraint firstItem="Cjn-zx-eSs" firstAttribute="centerY" secondItem="V8J-vG-dlF" secondAttribute="centerY" id="FfW-WI-ybP"/>
<constraint firstItem="CVH-hw-R8F" firstAttribute="trailing" secondItem="FLe-Gr-hny" secondAttribute="trailing" id="Ftp-zB-WsM"/>
<constraint firstItem="ccY-OZ-Jlp" firstAttribute="trailing" secondItem="FLe-Gr-hny" secondAttribute="trailing" id="GAa-0J-bbN"/>
<constraint firstItem="7rQ-cq-4t8" firstAttribute="top" secondItem="FLe-Gr-hny" secondAttribute="top" id="GJc-OP-hcg"/>
<constraint firstItem="FLe-Gr-hny" firstAttribute="leading" secondItem="DJj-LJ-xnv" secondAttribute="leading" id="Gw8-6c-aZQ"/>
<constraint firstItem="rp6-Nd-1qa" firstAttribute="centerY" secondItem="FLe-Gr-hny" secondAttribute="centerY" id="HGb-0C-429"/>
<constraint firstItem="hGZ-v7-VA5" firstAttribute="centerX" secondItem="xbP-E4-fCE" secondAttribute="centerX" id="IgA-69-RT3"/>
<constraint firstItem="CVH-hw-R8F" firstAttribute="top" secondItem="bc4-Lc-Ghm" secondAttribute="bottom" id="Isi-K8-3p0"/>
<constraint firstItem="7LB-OY-vh3" firstAttribute="trailing" secondItem="xbP-E4-fCE" secondAttribute="trailing" id="JtE-KF-Pdd"/>
<constraint firstItem="7LB-OY-vh3" firstAttribute="centerY" secondItem="xbP-E4-fCE" secondAttribute="centerY" id="LG8-OE-Xe1"/>
<constraint firstItem="H57-MD-elm" firstAttribute="centerY" secondItem="8Gl-Iv-u8L" secondAttribute="centerY" id="Mhe-dn-JZ9"/>
@ -238,11 +182,17 @@
<constraint firstItem="iKO-3z-Ias" firstAttribute="centerX" secondItem="xbP-E4-fCE" secondAttribute="centerX" id="UCC-w9-GvH"/>
<constraint firstItem="Cjn-zx-eSs" firstAttribute="centerY" secondItem="H57-MD-elm" secondAttribute="centerY" id="UEI-il-naq"/>
<constraint firstItem="9K0-cV-7zu" firstAttribute="centerX" secondItem="3M7-1s-N5r" secondAttribute="centerX" id="VeR-d1-FAy"/>
<constraint firstItem="f6y-OJ-0oT" firstAttribute="bottom" secondItem="FLe-Gr-hny" secondAttribute="bottom" id="X7u-ha-keM"/>
<constraint firstItem="ccY-OZ-Jlp" firstAttribute="top" secondItem="CVH-hw-R8F" secondAttribute="bottom" id="YVx-Ts-phy"/>
<constraint firstItem="s7g-nq-lRU" firstAttribute="bottom" secondItem="FLe-Gr-hny" secondAttribute="bottom" id="Ygo-58-kU2"/>
<constraint firstItem="WMD-Fv-ibu" firstAttribute="top" secondItem="FLe-Gr-hny" secondAttribute="top" id="YzW-LZ-S7F"/>
<constraint firstItem="s7g-nq-lRU" firstAttribute="leading" secondItem="f6y-OJ-0oT" secondAttribute="trailing" id="axe-4o-r6w"/>
<constraint firstItem="bc4-Lc-Ghm" firstAttribute="top" secondItem="FLe-Gr-hny" secondAttribute="top" id="eXk-0E-XgT"/>
<constraint firstAttribute="bottom" secondItem="OMP-L6-n0A" secondAttribute="bottom" constant="10" id="gDw-g8-7jn"/>
<constraint firstItem="bc4-Lc-Ghm" firstAttribute="leading" secondItem="WMD-Fv-ibu" secondAttribute="trailing" id="gHk-lh-K78"/>
<constraint firstItem="iKO-3z-Ias" firstAttribute="bottom" secondItem="xbP-E4-fCE" secondAttribute="bottom" id="gba-91-EY6"/>
<constraint firstItem="iwO-7q-c8H" firstAttribute="leading" secondItem="xbP-E4-fCE" secondAttribute="leading" id="iBC-eZ-hcV"/>
<constraint firstItem="rp6-Nd-1qa" firstAttribute="top" secondItem="7rQ-cq-4t8" secondAttribute="bottom" id="kbU-bz-reP"/>
<constraint firstItem="VtI-tC-PSX" firstAttribute="centerX" secondItem="9K0-cV-7zu" secondAttribute="centerX" id="lJs-z7-uYy"/>
<constraint firstItem="Cjn-zx-eSs" firstAttribute="centerX" secondItem="V8J-vG-dlF" secondAttribute="centerX" id="lmY-iZ-lW5"/>
<constraint firstAttribute="bottom" secondItem="xbP-E4-fCE" secondAttribute="bottom" constant="10" id="ner-TB-GTz"/>
@ -250,6 +200,7 @@
<constraint firstItem="DJj-LJ-xnv" firstAttribute="trailing" secondItem="Cjn-zx-eSs" secondAttribute="trailing" id="qTc-91-kbO"/>
<constraint firstItem="H57-MD-elm" firstAttribute="centerX" secondItem="8Gl-Iv-u8L" secondAttribute="centerX" id="sNB-9U-qXY"/>
<constraint firstItem="V8J-vG-dlF" firstAttribute="width" secondItem="Cjn-zx-eSs" secondAttribute="width" id="sxe-fC-pvB"/>
<constraint firstItem="ccY-OZ-Jlp" firstAttribute="leading" secondItem="s7g-nq-lRU" secondAttribute="trailing" id="t0o-uL-23I"/>
<constraint firstItem="DJj-LJ-xnv" firstAttribute="bottom" secondItem="9K0-cV-7zu" secondAttribute="bottom" constant="4" id="wWR-HB-aLq"/>
<constraint firstItem="WMD-Fv-ibu" firstAttribute="centerX" secondItem="FLe-Gr-hny" secondAttribute="centerX" id="xqT-1Z-AQx"/>
<constraint firstItem="rp6-Nd-1qa" firstAttribute="leading" secondItem="FLe-Gr-hny" secondAttribute="leading" id="zVb-6D-06l"/>
@ -257,7 +208,7 @@
<constraint firstItem="CVH-hw-R8F" firstAttribute="centerY" secondItem="FLe-Gr-hny" secondAttribute="centerY" id="zjZ-0S-Tq9"/>
<constraint firstItem="OMP-L6-n0A" firstAttribute="centerX" secondItem="FLe-Gr-hny" secondAttribute="centerX" id="zow-El-03l"/>
</constraints>
<point key="canvasLocation" x="608.69565217391312" y="48.214285714285715"/>
<point key="canvasLocation" x="608.12807881773404" y="47.200000000000003"/>
</view>
</objects>
<resources>

View File

@ -50,7 +50,13 @@ enum IOSButton {
IOS_BTN_PADDLE4,
IOS_BTN_TOUCHPAD,
IOS_BTN_MAX
IOS_BTN_MAX,
IOS_BTN_UP_RIGHT = 10,
IOS_BTN_UP_LEFT,
IOS_BTN_DOWN_LEFT,
IOS_BTN_DOWN_RIGHT,
};
enum IOSAxis {
IOS_AXIS_L1 = 1,
@ -555,6 +561,27 @@ public:
if (code == IOS_BTN_Y)
code = IOS_BTN_X; // btn3
}
switch (code)
{
case IOS_BTN_UP_RIGHT:
GamepadDevice::gamepad_btn_input(IOS_BTN_UP, pressed);
code = IOS_BTN_RIGHT;
break;
case IOS_BTN_DOWN_RIGHT:
GamepadDevice::gamepad_btn_input(IOS_BTN_DOWN, pressed);
code = IOS_BTN_RIGHT;
break;
case IOS_BTN_DOWN_LEFT:
GamepadDevice::gamepad_btn_input(IOS_BTN_DOWN, pressed);
code = IOS_BTN_LEFT;
break;
case IOS_BTN_UP_LEFT:
GamepadDevice::gamepad_btn_input(IOS_BTN_UP, pressed);
code = IOS_BTN_LEFT;
break;
default:
break;
}
return GamepadDevice::gamepad_btn_input(code, pressed);
}