From a26482d302a06f76e9f2557d5e1456af8f725810 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 17 Nov 2015 08:29:21 +0100 Subject: [PATCH] (mfi_joypad.m) Use local headers --- input/drivers_joypad/mfi_joypad.m | 21 ++++++++----------- .../GameController/GCController.h | 0 .../GameController/GCControllerAxisInput.h | 0 .../GameController/GCControllerButtonInput.h | 0 .../GameController/GCControllerDirectionPad.h | 0 .../GameController/GCControllerElement.h | 0 .../GameController/GCExtendedGamepad.h | 0 .../GCExtendedGamepadSnapshot.h | 0 .../GameController/GCGamepad.h | 0 .../GameController/GCGamepadSnapshot.h | 0 .../GameController/GameController.h | 0 11 files changed, 9 insertions(+), 12 deletions(-) rename input/{inc => include}/GameController/GCController.h (100%) rename input/{inc => include}/GameController/GCControllerAxisInput.h (100%) rename input/{inc => include}/GameController/GCControllerButtonInput.h (100%) rename input/{inc => include}/GameController/GCControllerDirectionPad.h (100%) rename input/{inc => include}/GameController/GCControllerElement.h (100%) rename input/{inc => include}/GameController/GCExtendedGamepad.h (100%) rename input/{inc => include}/GameController/GCExtendedGamepadSnapshot.h (100%) rename input/{inc => include}/GameController/GCGamepad.h (100%) rename input/{inc => include}/GameController/GCGamepadSnapshot.h (100%) rename input/{inc => include}/GameController/GameController.h (100%) diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index 86efef63c8..b31548894f 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -22,7 +22,7 @@ #include #include -#import +#import "../include/GameController/GameController.h" #ifndef MAX_MFI_CONTROLLERS #define MAX_MFI_CONTROLLERS 4 @@ -56,17 +56,14 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller) if (!controller) return; - slot = (uint32_t)controller.playerIndex; + slot = (uint32_t)controller.playerIndex; + buttons = &mfi_buttons[slot]; /* retain the start (pause) value */ - pause = mfi_buttons[slot] & (1 << RETRO_DEVICE_ID_JOYPAD_START); - - mfi_buttons[slot] = 0; + pause = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_START); + *buttons = 0 | pause; + memset(mfi_axes[slot], 0, sizeof(mfi_axes[0])); - mfi_buttons[slot] |= pause; - - buttons = &mfi_buttons[slot]; - if (controller.extendedGamepad) { GCExtendedGamepad *gp = (GCExtendedGamepad *)controller.extendedGamepad; @@ -125,8 +122,7 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad) gamepad.controller.controllerPausedHandler = ^(GCController *controller) { - uint32_t slot = (uint32_t)controller.playerIndex; - + uint32_t slot = (uint32_t)controller.playerIndex; mfi_buttons[slot] |= (1 << RETRO_DEVICE_ID_JOYPAD_START); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ @@ -139,7 +135,7 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad) static void apple_gamecontroller_joypad_connect(GCController *controller) { signed desired_index = (int32_t)controller.playerIndex; - desired_index = (desired_index >= 0 && desired_index < MAX_MFI_CONTROLLERS) + desired_index = (desired_index >= 0 && desired_index < MAX_MFI_CONTROLLERS) ? desired_index : 0; /* prevent same controller getting set twice */ @@ -155,6 +151,7 @@ static void apple_gamecontroller_joypad_connect(GCController *controller) { /* find a new slot for this controller that's unused */ unsigned i; + for (i = 0; i < MAX_MFI_CONTROLLERS; ++i) { if (mfi_controllers[i]) diff --git a/input/inc/GameController/GCController.h b/input/include/GameController/GCController.h similarity index 100% rename from input/inc/GameController/GCController.h rename to input/include/GameController/GCController.h diff --git a/input/inc/GameController/GCControllerAxisInput.h b/input/include/GameController/GCControllerAxisInput.h similarity index 100% rename from input/inc/GameController/GCControllerAxisInput.h rename to input/include/GameController/GCControllerAxisInput.h diff --git a/input/inc/GameController/GCControllerButtonInput.h b/input/include/GameController/GCControllerButtonInput.h similarity index 100% rename from input/inc/GameController/GCControllerButtonInput.h rename to input/include/GameController/GCControllerButtonInput.h diff --git a/input/inc/GameController/GCControllerDirectionPad.h b/input/include/GameController/GCControllerDirectionPad.h similarity index 100% rename from input/inc/GameController/GCControllerDirectionPad.h rename to input/include/GameController/GCControllerDirectionPad.h diff --git a/input/inc/GameController/GCControllerElement.h b/input/include/GameController/GCControllerElement.h similarity index 100% rename from input/inc/GameController/GCControllerElement.h rename to input/include/GameController/GCControllerElement.h diff --git a/input/inc/GameController/GCExtendedGamepad.h b/input/include/GameController/GCExtendedGamepad.h similarity index 100% rename from input/inc/GameController/GCExtendedGamepad.h rename to input/include/GameController/GCExtendedGamepad.h diff --git a/input/inc/GameController/GCExtendedGamepadSnapshot.h b/input/include/GameController/GCExtendedGamepadSnapshot.h similarity index 100% rename from input/inc/GameController/GCExtendedGamepadSnapshot.h rename to input/include/GameController/GCExtendedGamepadSnapshot.h diff --git a/input/inc/GameController/GCGamepad.h b/input/include/GameController/GCGamepad.h similarity index 100% rename from input/inc/GameController/GCGamepad.h rename to input/include/GameController/GCGamepad.h diff --git a/input/inc/GameController/GCGamepadSnapshot.h b/input/include/GameController/GCGamepadSnapshot.h similarity index 100% rename from input/inc/GameController/GCGamepadSnapshot.h rename to input/include/GameController/GCGamepadSnapshot.h diff --git a/input/inc/GameController/GameController.h b/input/include/GameController/GameController.h similarity index 100% rename from input/inc/GameController/GameController.h rename to input/include/GameController/GameController.h