Skip to content

Commit

Permalink
(iOS) Some backwards compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Feb 24, 2015
1 parent 91fe5c5 commit 6545aa8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apple/common/apple_gamecontroller.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@
#include "RetroArch_Apple.h"
#ifdef __IPHONE_7_0
#import <GameController/GameController.h>
#endif
#include "apple_gamecontroller.h"
#include "../../input/drivers/apple_input.h"

enum
{
GCCONTROLLER_PLAYER_INDEX_UNSET = -1,
};

static BOOL apple_gamecontroller_available(void)
{
if (get_ios_version_major() <= 6)
Expand Down Expand Up @@ -119,7 +125,7 @@ static void apple_gamecontroller_connect(GCController *controller)
{
int32_t slot = apple_joypad_connect_gcapi(slots);

controller.playerIndex = (slot >= 0 && slot < MAX_USERS) ? slot : GCControllerPlayerIndexUnset;
controller.playerIndex = (slot >= 0 && slot < MAX_USERS) ? slot : GCCONTROLLER_PLAYER_INDEX_UNSET;

if (controller.playerIndex == GCControllerPlayerIndexUnset)
return;
Expand All @@ -130,19 +136,17 @@ static void apple_gamecontroller_connect(GCController *controller)
static void apple_gamecontroller_disconnect(GCController* controller)
{
unsigned pad = (uint32_t)controller.playerIndex;
if (pad == GCControllerPlayerIndexUnset)
if (pad == GCCONTROLLER_PLAYER_INDEX_UNSET)
return;

pad_connection_pad_deinit(&slots[pad], pad);
}
#endif

void apple_gamecontroller_init(void)
{
if (!apple_gamecontroller_available())
return;
#ifdef __IPHONE_7_0
if (!apple_gamecontroller_available())
return;

[[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification
object:nil
queue:[NSOperationQueue mainQueue]
Expand Down

0 comments on commit 6545aa8

Please sign in to comment.