mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #19191 from hrydgard/more-ios-polish
More iOS polish: Improved gamepad mappings, enable ARC for all the files
This commit is contained in:
commit
d097b9debc
7 changed files with 77 additions and 37 deletions
|
@ -1326,14 +1326,19 @@ elseif(IOS AND NOT LIBRETRO)
|
|||
set(nativeExtraLibs ${nativeExtraLibs} iconv)
|
||||
endif()
|
||||
|
||||
# TODO: Enable arc globally?
|
||||
set_source_files_properties(ios/AppDelegate.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/ViewController.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/ViewControllerMetal.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/iOSCoreAudio.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/PPSSPPUIApplication.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/iCade/iCadeReaderView.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/main.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/CameraHelper.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/AudioEngine.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/LocationHelper.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/DisplayManager.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(ios/Controls.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(UI/DarwinFileSystemServices.mm PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
set_source_files_properties(Common/Battery/AppleBatteryClient.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
|
||||
|
||||
|
|
|
@ -741,6 +741,8 @@ void RestoreDefault() {
|
|||
} else {
|
||||
SetDefaultKeyMap(DEFAULT_MAPPING_ANDROID_PAD, false);
|
||||
}
|
||||
#elif PPSSPP_PLATFORM(IOS)
|
||||
SetDefaultKeyMap(DEFAULT_MAPPING_IOS_PAD, false);
|
||||
#else
|
||||
SetDefaultKeyMap(DEFAULT_MAPPING_KEYBOARD, true);
|
||||
SetDefaultKeyMap(DEFAULT_MAPPING_PAD, false);
|
||||
|
|
|
@ -275,6 +275,27 @@ static const DefMappingStruct defaultPadMap[] = {
|
|||
{VIRTKEY_PAUSE , NKCODE_BUTTON_L2 },
|
||||
};
|
||||
|
||||
static const DefMappingStruct defaultPadMapIOS[] = {
|
||||
{CTRL_CROSS , NKCODE_BUTTON_2},
|
||||
{CTRL_CIRCLE , NKCODE_BUTTON_3},
|
||||
{CTRL_SQUARE , NKCODE_BUTTON_4},
|
||||
{CTRL_TRIANGLE , NKCODE_BUTTON_1},
|
||||
{CTRL_UP , NKCODE_DPAD_UP},
|
||||
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
||||
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
||||
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
||||
{CTRL_START , NKCODE_BUTTON_START},
|
||||
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
|
||||
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
||||
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
||||
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
||||
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
||||
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
||||
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
||||
{VIRTKEY_PAUSE , NKCODE_BUTTON_THUMBL },
|
||||
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_RTRIGGER, +1},
|
||||
};
|
||||
|
||||
static const DefMappingStruct defaultOuyaMap[] = {
|
||||
{CTRL_CROSS , NKCODE_BUTTON_A},
|
||||
{CTRL_CIRCLE , NKCODE_BUTTON_B},
|
||||
|
@ -382,6 +403,9 @@ void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
|
|||
case DEFAULT_MAPPING_ANDROID_PAD:
|
||||
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMapAndroid, ARRAY_SIZE(defaultPadMapAndroid), replace);
|
||||
break;
|
||||
case DEFAULT_MAPPING_IOS_PAD:
|
||||
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMapIOS, ARRAY_SIZE(defaultPadMapIOS), replace);
|
||||
break;
|
||||
case DEFAULT_MAPPING_OUYA:
|
||||
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultOuyaMap, ARRAY_SIZE(defaultOuyaMap), replace);
|
||||
break;
|
||||
|
|
|
@ -6,6 +6,7 @@ enum DefaultMaps {
|
|||
DEFAULT_MAPPING_KEYBOARD,
|
||||
DEFAULT_MAPPING_PAD,
|
||||
DEFAULT_MAPPING_ANDROID_PAD,
|
||||
DEFAULT_MAPPING_IOS_PAD,
|
||||
DEFAULT_MAPPING_XINPUT,
|
||||
DEFAULT_MAPPING_ANDROID_XBOX, // XBox controller or similar on Android
|
||||
DEFAULT_MAPPING_SHIELD,
|
||||
|
|
|
@ -164,7 +164,8 @@
|
|||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
exit(0);
|
||||
// Seems like a bad idea.
|
||||
// exit(0);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,20 +15,20 @@ static void controllerButtonPressed(BOOL pressed, InputKeyCode keyCode) {
|
|||
NativeKey(key);
|
||||
}
|
||||
|
||||
static void analogTriggerPressed(InputAxis axis, float value) {
|
||||
AxisInput axisInput;
|
||||
axisInput.deviceId = DEVICE_ID_PAD_0;
|
||||
axisInput.axisId = axis;
|
||||
axisInput.value = value;
|
||||
NativeAxis(&axisInput, 1);
|
||||
}
|
||||
|
||||
bool SetupController(GCController *controller) {
|
||||
GCExtendedGamepad *extendedProfile = controller.extendedGamepad;
|
||||
if (extendedProfile == nil) {
|
||||
return false;
|
||||
}
|
||||
|
||||
controller.controllerPausedHandler = ^(GCController *controller) {
|
||||
KeyInput key;
|
||||
key.flags = KEY_DOWN;
|
||||
key.keyCode = NKCODE_ESCAPE;
|
||||
key.deviceId = DEVICE_ID_KEYBOARD;
|
||||
NativeKey(key);
|
||||
};
|
||||
|
||||
extendedProfile.buttonA.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_2); // Cross
|
||||
};
|
||||
|
@ -46,11 +46,11 @@ bool SetupController(GCController *controller) {
|
|||
};
|
||||
|
||||
extendedProfile.leftShoulder.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_7); // LTrigger
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_L1); // LTrigger
|
||||
};
|
||||
|
||||
extendedProfile.rightShoulder.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_8); // RTrigger
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_R1); // RTrigger
|
||||
};
|
||||
|
||||
extendedProfile.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
|
@ -70,34 +70,36 @@ bool SetupController(GCController *controller) {
|
|||
};
|
||||
|
||||
extendedProfile.leftTrigger.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_9); // Select
|
||||
INFO_LOG(SYSTEM, "ltrigger: %f %d", value, (int)pressed);
|
||||
analogTriggerPressed(JOYSTICK_AXIS_LTRIGGER, value);
|
||||
};
|
||||
|
||||
extendedProfile.rightTrigger.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_10); // Start
|
||||
INFO_LOG(SYSTEM, "rtrigger: %f %d", value, (int)pressed);
|
||||
analogTriggerPressed(JOYSTICK_AXIS_RTRIGGER, value);
|
||||
};
|
||||
|
||||
#if defined(__IPHONE_12_1) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_1
|
||||
if ([extendedProfile respondsToSelector:@selector(leftThumbstickButton)] && extendedProfile.leftThumbstickButton != nil) {
|
||||
extendedProfile.leftThumbstickButton.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_11);
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_THUMBL);
|
||||
};
|
||||
}
|
||||
if ([extendedProfile respondsToSelector:@selector(rightThumbstickButton)] && extendedProfile.rightThumbstickButton != nil) {
|
||||
extendedProfile.rightThumbstickButton.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_12);
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_THUMBR);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
|
||||
if ([extendedProfile respondsToSelector:@selector(buttonOptions)] && extendedProfile.buttonOptions != nil) {
|
||||
extendedProfile.buttonOptions.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_13);
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_SELECT);
|
||||
};
|
||||
}
|
||||
if ([extendedProfile respondsToSelector:@selector(buttonMenu)] && extendedProfile.buttonMenu != nil) {
|
||||
extendedProfile.buttonMenu.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) {
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_14);
|
||||
controllerButtonPressed(pressed, NKCODE_BUTTON_START);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -143,7 +145,7 @@ bool SetupController(GCController *controller) {
|
|||
NativeAxis(&axisInput, 1);
|
||||
};
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TouchTracker::SendTouchEvent(float x, float y, int code, int pointerId) {
|
||||
|
@ -203,7 +205,7 @@ void TouchTracker::Began(NSSet *touches, UIView *view) {
|
|||
}
|
||||
|
||||
void TouchTracker::Moved(NSSet *touches, UIView *view) {
|
||||
for (UITouch* touch in touches) {
|
||||
for (UITouch* touch in touches) {
|
||||
CGPoint point = [touch locationInView:view];
|
||||
int touchId = ToTouchID(touch, true);
|
||||
SendTouchEvent(point.x, point.y, 0, touchId);
|
||||
|
@ -211,40 +213,40 @@ void TouchTracker::Moved(NSSet *touches, UIView *view) {
|
|||
}
|
||||
|
||||
void TouchTracker::Ended(NSSet *touches, UIView *view) {
|
||||
for (UITouch* touch in touches) {
|
||||
for (UITouch* touch in touches) {
|
||||
CGPoint point = [touch locationInView:view];
|
||||
int touchId = ToTouchID(touch, false);
|
||||
if (touchId >= 0) {
|
||||
SendTouchEvent(point.x, point.y, 2, touchId);
|
||||
SendTouchEvent(point.x, point.y, 2, touchId);
|
||||
touches_[touchId] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TouchTracker::Cancelled(NSSet *touches, UIView *view) {
|
||||
for (UITouch* touch in touches) {
|
||||
for (UITouch* touch in touches) {
|
||||
CGPoint point = [touch locationInView:view];
|
||||
int touchId = ToTouchID(touch, false);
|
||||
if (touchId >= 0) {
|
||||
SendTouchEvent(point.x, point.y, 2, touchId);
|
||||
SendTouchEvent(point.x, point.y, 2, touchId);
|
||||
touches_[touchId] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ICadeTracker::InitKeyMap() {
|
||||
iCadeToKeyMap[iCadeJoystickUp] = NKCODE_DPAD_UP;
|
||||
iCadeToKeyMap[iCadeJoystickRight] = NKCODE_DPAD_RIGHT;
|
||||
iCadeToKeyMap[iCadeJoystickDown] = NKCODE_DPAD_DOWN;
|
||||
iCadeToKeyMap[iCadeJoystickLeft] = NKCODE_DPAD_LEFT;
|
||||
iCadeToKeyMap[iCadeButtonA] = NKCODE_BUTTON_9; // Select
|
||||
iCadeToKeyMap[iCadeButtonB] = NKCODE_BUTTON_7; // LTrigger
|
||||
iCadeToKeyMap[iCadeButtonC] = NKCODE_BUTTON_10; // Start
|
||||
iCadeToKeyMap[iCadeButtonD] = NKCODE_BUTTON_8; // RTrigger
|
||||
iCadeToKeyMap[iCadeButtonE] = NKCODE_BUTTON_4; // Square
|
||||
iCadeToKeyMap[iCadeButtonF] = NKCODE_BUTTON_2; // Cross
|
||||
iCadeToKeyMap[iCadeButtonG] = NKCODE_BUTTON_1; // Triangle
|
||||
iCadeToKeyMap[iCadeButtonH] = NKCODE_BUTTON_3; // Circle
|
||||
iCadeToKeyMap[iCadeJoystickUp] = NKCODE_DPAD_UP;
|
||||
iCadeToKeyMap[iCadeJoystickRight] = NKCODE_DPAD_RIGHT;
|
||||
iCadeToKeyMap[iCadeJoystickDown] = NKCODE_DPAD_DOWN;
|
||||
iCadeToKeyMap[iCadeJoystickLeft] = NKCODE_DPAD_LEFT;
|
||||
iCadeToKeyMap[iCadeButtonA] = NKCODE_BUTTON_9; // Select
|
||||
iCadeToKeyMap[iCadeButtonB] = NKCODE_BUTTON_7; // LTrigger
|
||||
iCadeToKeyMap[iCadeButtonC] = NKCODE_BUTTON_10; // Start
|
||||
iCadeToKeyMap[iCadeButtonD] = NKCODE_BUTTON_8; // RTrigger
|
||||
iCadeToKeyMap[iCadeButtonE] = NKCODE_BUTTON_4; // Square
|
||||
iCadeToKeyMap[iCadeButtonF] = NKCODE_BUTTON_2; // Cross
|
||||
iCadeToKeyMap[iCadeButtonG] = NKCODE_BUTTON_1; // Triangle
|
||||
iCadeToKeyMap[iCadeButtonH] = NKCODE_BUTTON_3; // Circle
|
||||
}
|
||||
|
||||
void ICadeTracker::ButtonDown(iCadeState button) {
|
||||
|
@ -290,7 +292,7 @@ void ICadeTracker::ButtonDown(iCadeState button) {
|
|||
}
|
||||
|
||||
void ICadeTracker::ButtonUp(iCadeState button) {
|
||||
if (!iCadeConnectNotified) {
|
||||
if (!iCadeConnectNotified) {
|
||||
iCadeConnectNotified = true;
|
||||
KeyMap::NotifyPadConnected(DEVICE_ID_PAD_0, "iCade");
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ bool IOSVulkanContext::InitFromRenderThread(CAMetalLayer *layer, int desiredBack
|
|||
return false;
|
||||
}
|
||||
|
||||
VkResult res = g_Vulkan->InitSurface(WINDOWSYSTEM_METAL_EXT, (void *)layer, nullptr);
|
||||
VkResult res = g_Vulkan->InitSurface(WINDOWSYSTEM_METAL_EXT, (__bridge void *)layer, nullptr);
|
||||
if (res != VK_SUCCESS) {
|
||||
ERROR_LOG(G3D, "g_Vulkan->InitSurface failed: '%s'", VulkanResultToString(res));
|
||||
return false;
|
||||
|
@ -231,6 +231,11 @@ static std::thread g_renderLoopThread;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)appWillTerminate:(NSNotification *)notification
|
||||
{
|
||||
[self shutdown];
|
||||
}
|
||||
|
||||
// Should be very similar to the Android one, probably mergeable.
|
||||
void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLayer) {
|
||||
SetCurrentThreadName("EmuThreadVulkan");
|
||||
|
|
Loading…
Add table
Reference in a new issue