From 72beeba8b044fc73ec84eed2425a042bb71e7234 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 May 2014 23:30:43 +0200 Subject: [PATCH] (Apple) Fix OSX build --- apple/RetroArch_OSX.xcodeproj/project.pbxproj | 5 +---- apple/common/apple_gamecontroller.m | 21 ++++++++----------- input/apple_input.c | 10 +++++++++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/apple/RetroArch_OSX.xcodeproj/project.pbxproj b/apple/RetroArch_OSX.xcodeproj/project.pbxproj index 0fe7320cf7..bead1847f6 100644 --- a/apple/RetroArch_OSX.xcodeproj/project.pbxproj +++ b/apple/RetroArch_OSX.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 50535530185E0F4000926C26 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5053552F185E0F4000926C26 /* CoreLocation.framework */; }; - 50DC494B186F2DCE003AEF87 /* apple_gamecontroller.m in Sources */ = {isa = PBXBuildFile; fileRef = 50DC494A186F2DCE003AEF87 /* apple_gamecontroller.m */; }; 9620F663178FD4D3001B3B81 /* settings.m in Sources */ = {isa = PBXBuildFile; fileRef = 9620F662178FD4D3001B3B81 /* settings.m */; }; 962EE0E2178B3DF6004224FF /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 962EE0E1178B3DF6004224FF /* IOKit.framework */; }; 96355CE31788E72A0010DBFA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96355CE21788E72A0010DBFA /* Cocoa.framework */; }; @@ -30,7 +29,6 @@ /* Begin PBXFileReference section */ 5053552F185E0F4000926C26 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; - 50DC494A186F2DCE003AEF87 /* apple_gamecontroller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = apple_gamecontroller.m; sourceTree = ""; }; 9620F662178FD4D3001B3B81 /* settings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = settings.m; path = OSX/settings.m; sourceTree = SOURCE_ROOT; }; 962EE0E1178B3DF6004224FF /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = ../../../../../../../System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; 96355CDF1788E72A0010DBFA /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -112,7 +110,6 @@ 96355CE81788E72A0010DBFA /* common */ = { isa = PBXGroup; children = ( - 50DC494A186F2DCE003AEF87 /* apple_gamecontroller.m */, 9646869617BBC14E00C5EA69 /* platform.m */, 9620F662178FD4D3001B3B81 /* settings.m */, 967894A01788F07D00D6CA69 /* griffin.c */, @@ -174,6 +171,7 @@ }; buildConfigurationList = 96355CD81788E6E00010DBFA /* Build configuration list for PBXProject "RetroArch_OSX" */; compatibilityVersion = "Xcode 3.0"; + developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, @@ -209,7 +207,6 @@ buildActionMask = 2147483647; files = ( 967894961788ED1100D6CA69 /* main.m in Sources */, - 50DC494B186F2DCE003AEF87 /* apple_gamecontroller.m in Sources */, 9678949D1788F02600D6CA69 /* RAGameView.m in Sources */, 9678949F1788F02600D6CA69 /* utility.m in Sources */, 967894A11788F07D00D6CA69 /* griffin.c in Sources */, diff --git a/apple/common/apple_gamecontroller.m b/apple/common/apple_gamecontroller.m index bb24a6b6e7..8e9ea19064 100644 --- a/apple/common/apple_gamecontroller.m +++ b/apple/common/apple_gamecontroller.m @@ -32,9 +32,8 @@ static inline uint32_t joypad_value_for_id(uint32_t joypad_id) static void apple_gamecontroller_poll(GCController *controller) { - if (!controller || controller.playerIndex == MAX_PLAYERS) { + if (!controller || controller.playerIndex == MAX_PLAYERS) return; - } uint32_t slot = (uint32_t)controller.playerIndex; @@ -46,7 +45,8 @@ static void apple_gamecontroller_poll(GCController *controller) g_current_input_data.pad_buttons[slot] |= pause; - if (controller.extendedGamepad) { + if (controller.extendedGamepad) + { GCExtendedGamepad *gp = (GCExtendedGamepad *)controller.extendedGamepad; g_current_input_data.pad_buttons[slot] |= gp.dpad.up.pressed ? joypad_value_for_id(RETRO_DEVICE_ID_JOYPAD_UP) : 0; g_current_input_data.pad_buttons[slot] |= gp.dpad.down.pressed ? joypad_value_for_id(RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; @@ -65,7 +65,9 @@ static void apple_gamecontroller_poll(GCController *controller) g_current_input_data.pad_axis[slot][1] = gp.leftThumbstick.yAxis.value * 32767.0f; g_current_input_data.pad_axis[slot][2] = gp.rightThumbstick.xAxis.value * 32767.0f; g_current_input_data.pad_axis[slot][3] = gp.rightThumbstick.yAxis.value * 32767.0f; - } else if (controller.gamepad) { + } + else if (controller.gamepad) + { GCGamepad *gp = (GCGamepad *)controller.gamepad; g_current_input_data.pad_buttons[slot] |= gp.dpad.up.pressed ? joypad_value_for_id(RETRO_DEVICE_ID_JOYPAD_UP) : 0; g_current_input_data.pad_buttons[slot] |= gp.dpad.down.pressed ? joypad_value_for_id(RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; @@ -82,13 +84,11 @@ static void apple_gamecontroller_poll(GCController *controller) void apple_gamecontroller_poll_all(void) { - if (!apple_gamecontroller_available()) { + if (!apple_gamecontroller_available()) return; - } - for (GCController *controller in [GCController controllers]) { + for (GCController *controller in [GCController controllers]) apple_gamecontroller_poll(controller); - } } static void apple_gamecontroller_register(GCGamepad *gamepad) @@ -97,8 +97,6 @@ static void apple_gamecontroller_register(GCGamepad *gamepad) apple_gamecontroller_poll(updateGamepad.controller); }; - - gamepad.controller.controllerPausedHandler = ^(GCController *controller) { uint32_t slot = (uint32_t)controller.playerIndex; @@ -119,9 +117,8 @@ static void apple_gamecontroller_connect(GCController *controller) controller.playerIndex = (slot >= 0 && slot < MAX_PLAYERS) ? slot : GCControllerPlayerIndexUnset; - if (controller.playerIndex == GCControllerPlayerIndexUnset) { + if (controller.playerIndex == GCControllerPlayerIndexUnset) return; - } apple_gamecontroller_register(controller.gamepad); } diff --git a/input/apple_input.c b/input/apple_input.c index b1ea98cc4a..0be77ed51d 100644 --- a/input/apple_input.c +++ b/input/apple_input.c @@ -229,7 +229,9 @@ const char* apple_keycode_hidusage_to_name(uint32_t hid_usage) return "nul"; } +#ifdef IOS extern void apple_gamecontroller_poll_all(void); +#endif enum input_devices { @@ -420,7 +422,9 @@ int32_t apple_input_find_any_key(void) { unsigned i; +#ifdef IOS apple_gamecontroller_poll_all(); +#endif input_init_keyboard_lut(apple_key_map_hidusage); for (i = 0; apple_key_name_map[i].hid_id; i++) @@ -433,7 +437,9 @@ int32_t apple_input_find_any_key(void) int32_t apple_input_find_any_button(uint32_t port) { unsigned i, buttons; +#ifdef IOS apple_gamecontroller_poll_all(); +#endif buttons = g_current_input_data.pad_buttons[port] | ((port == 0) ? apple_input_get_icade_buttons() : 0); @@ -448,7 +454,9 @@ int32_t apple_input_find_any_button(uint32_t port) int32_t apple_input_find_any_axis(uint32_t port) { +#ifdef IOS apple_gamecontroller_poll_all(); +#endif for (int i = 0; i < 4; i++) { @@ -488,7 +496,9 @@ static void apple_input_poll(void *data) int i; (void)data; +#ifdef IOS apple_gamecontroller_poll_all(); +#endif for (i = 0; i < g_current_input_data.touch_count; i ++) {