From b8bb6b3461a249bd9f5f1d385d25794b18f25caa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 25 Feb 2015 00:25:43 +0100 Subject: [PATCH] (iOS) Add internal GameController API headers --- apple/common/GameController/GCController.h | 161 ++++++++++++++++++ .../GameController/GCControllerAxisInput.h | 32 ++++ .../GameController/GCControllerButtonInput.h | 38 +++++ .../GameController/GCControllerDirectionPad.h | 36 ++++ .../GameController/GCControllerElement.h | 31 ++++ .../common/GameController/GCExtendedGamepad.h | 103 +++++++++++ .../GCExtendedGamepadSnapshot.h | 75 ++++++++ apple/common/GameController/GCGamepad.h | 84 +++++++++ .../common/GameController/GCGamepadSnapshot.h | 66 +++++++ apple/common/GameController/GameController.h | 30 ++++ apple/common/apple_gamecontroller.m | 4 +- .../RetroArch_iOS.xcodeproj/project.pbxproj | 4 +- 12 files changed, 659 insertions(+), 5 deletions(-) create mode 100644 apple/common/GameController/GCController.h create mode 100644 apple/common/GameController/GCControllerAxisInput.h create mode 100644 apple/common/GameController/GCControllerButtonInput.h create mode 100644 apple/common/GameController/GCControllerDirectionPad.h create mode 100644 apple/common/GameController/GCControllerElement.h create mode 100644 apple/common/GameController/GCExtendedGamepad.h create mode 100644 apple/common/GameController/GCExtendedGamepadSnapshot.h create mode 100644 apple/common/GameController/GCGamepad.h create mode 100644 apple/common/GameController/GCGamepadSnapshot.h create mode 100644 apple/common/GameController/GameController.h diff --git a/apple/common/GameController/GCController.h b/apple/common/GameController/GCController.h new file mode 100644 index 0000000000..fededc5ab3 --- /dev/null +++ b/apple/common/GameController/GCController.h @@ -0,0 +1,161 @@ +// +// GCController.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import + +/** + Use these constants with NSNotificationCenter to listen to connection and disconnection events. + + Use GCControllerDidConnectNotification for observing connections of controllers. + Use GCControllerDidDisconnectNotification for observing disconnections of controllers. + + Connections and disconnections of controllers will also be reflected in the controllers array + of the GCController class. + + The 'object' property of the notification will contain the GCController that was connected or disconnected. + For example: + + - (void)controllerDidConnect:(NSNotification *)note { + + GCController *controller = note.object; + + .... + } + + @see NSNotificationCenter + @see GCController.controllers + */ +GAMECONTROLLER_EXTERN NSString *const GCControllerDidConnectNotification; +GAMECONTROLLER_EXTERN NSString *const GCControllerDidDisconnectNotification; + +/** + This is the player index that a connected controller will have if it has never been assigned a player index on the current system. + Controllers retain the player index they have been assigned between game sessions, so if you wish to unset the player index of a + controller set it back to this value. + */ +enum { + GCControllerPlayerIndexUnset = -1, +}; + +/** + Controllers are available to an application that links to GameController.framework. There are 2 ways to access controllers + paired to the system, adopt both to ensure the best user experience: + + 1: Querying for the the current array or controllers using [GCController controllers]. + 2: Registering for Connection/Disconnection notifications from NSNotificationCenter. + + Only controllers that support one of the allowed profiles, such as GCGamepad, will be enumerated. Check for the profile + supported before using a controller in your application. Ignore a controller that doesn't support a profile that suits + your application, as the user will expect their controller to either be fully supported or not supported at all. + */ +GAMECONTROLLER_EXPORT +@interface GCController : NSObject + +/** + Set this block to be notified when a user intendeds to suspend or resume the current game state. A controller will have a button + dedicated to suspending and resuming play and invoking context sensitive actions. During event handling the system will + notify the application using this block such that the application can handle the suspension and resumption from the given controller. + + Use this to implement your canonical transition to a pause menu for example if that is your application's desired handling + of suspension in play. You may pause and resume base don game state as well so the event is only called each time the + pause/resume button is pressed. + + @param controller the controller that is suspending or resuming play. + */ +@property (copy) void (^controllerPausedHandler)(GCController *controller); + +/** + A vendor supplied name. May be nil, and is not guaranteed to be unique. This should not be used as a key in a dictionary, + but simply as a way to present some basic information about the controller in testing or to the user. + */ +@property (readonly, copy) NSString *vendorName; + +/** + A controller may be form fitting or otherwise closely attached to the device. This closeness to other inputs on the device + may suggest that interaction with the device may use other inputs easily. This is presented to developers to allow them to + make informed descisions about UI and interactions to choose for their game in this situation. + */ +@property (readonly, getter = isAttachedToDevice) BOOL attachedToDevice; + +/** + A player index for the controller, defaults to GCControllerPlayerIndexUnset, unless the controller previously had + a player index assigned to it on the current user's system. + + This can be set both for the application to keep track of controllers and as a signal to make a controller display a player + index on a set of LEDs or some other mechanism. + + A controller is not guranteed to have a visual display of the playerIndex, but the API will keep track of the playerIndex + for a controller while connected and in between being disconnected and connected again. Thus playerIndex persists for a controller + with regards to a system. This makes it useful for persisting player-controller assignments across game sessions. + + Negative values less than GCControllerPlayerIndexUnset will just map back to GCControllerPlayerIndexUnset when read back. + */ +@property (nonatomic) NSInteger playerIndex; + +/** + Gets the profile for the controller that suits current application. + + There are only two supported profiles. Each controller may be able to map its inputs into all profiles or just one kind of + profile. Query for the controller profile that suits your game, the simplest kind will be supported by the broadest variety + of controllers. A controller supporting the Extended Gamepad profile for example supports the Gamepad profile and more. + As such it can always be used just in the Gamepad profile if that suits the game. + + A physical controller that supports a profile must support it completely. That means that all buttons and axis inputs must + be valid inputs that a developer can utilize. + + If a controller does not support the given profile the returned value will be nil. Use this to filter controllers if the + application requires a specific kind of profile. + */ +@property (retain, readonly) GCGamepad *gamepad; +@property (retain, readonly) GCExtendedGamepad *extendedGamepad; + +/** + Get a list of controllers currently attached to the system. + + @see GCControllerDidConnectNotification + @see GCControllerDidDisconnectNotification + */ ++ (NSArray *)controllers; + +/** + Start discovery of new wireless controllers that are discoverable. This is an asynchronous and the supplied completionHandler + will get called once no more devices can be found. If there are already multiple controllers available for use, there + may be little reason to automatically start discovery of new wireless controllers. In this situation it may be best to + allow the user to start discovery manually via in-game UI. + + Once discovery has started new controllers will notify themselves as connected via GCControllerDidConnectNotification. + As the notification arrives the controller is also available in the controllers array. + + The completionHandler could be used to update UI and/or game state to indicate that no more controllers will be found + and the current set of controllers is what is available for use in the game. + + If a completionHandler was provided, it will be called once when discovery stops. Either from an explicit call to + stopWirelessControllerDiscovery or from timing out or stopping in its natural course of operation. Thus the + completionHandler will at most be called once per call to startWirelessControllerDiscoveryWithCompletionHandler:. + + The completionHandler may also not get called at all, if for example startWirelessControllerDiscoveryWithCompletionHandler: + is called multiple times during dicovery. For this case the net effect is that the completionHandler is replaced with each call + and only the last one set before discovery stops will be called. + + @param completionHandler an optional handler that is called when discovery stops. (may be nil, in which case you will not be notified when discovery stops) + @see stopWirelessControllerDiscovery + @see controllers + */ ++ (void)startWirelessControllerDiscoveryWithCompletionHandler:(void (^)(void))completionHandler; + +/** + If no more controllers are needed, depending on game state or number of controllers supported by a game, the discovery + process can be stopped. Calling stopWirelessControllerDiscovery when no discovery is currently in progress will return + immediately without any effect, thus it is safe to call even if the completionHandler of + startWirelessControllerDiscoveryWithCompletionHandler: has been called. + + @see startWirelessControllerDiscoveryWithCompletionHandler: + */ ++ (void)stopWirelessControllerDiscovery; + +@end + diff --git a/apple/common/GameController/GCControllerAxisInput.h b/apple/common/GameController/GCControllerAxisInput.h new file mode 100644 index 0000000000..1bb95f3003 --- /dev/null +++ b/apple/common/GameController/GCControllerAxisInput.h @@ -0,0 +1,32 @@ +// +// GCControllerAxisInput.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +GAMECONTROLLER_EXPORT +@interface GCControllerAxisInput : GCControllerElement + +/** + Set this block if you want to be notified when the value on this axis changes. + + @param axis the element that has been modified. + @param value the value the axis was set to at the time the valueChangedHandler fired. + */ +typedef void (^GCControllerAxisValueChangedHandler)(GCControllerAxisInput *axis, float value); +@property (copy) GCControllerAxisValueChangedHandler valueChangedHandler; + +/** + A normalized value for the input, between -1 and 1 for axis inputs. The values are deadzoned and saturated before they are returned + so there is no value ouside the range. Deadzoning does not remove values from the range, the full 0 to 1 magnitude of values + are possible from the input. + + As an axis is often used in a digital sense, you can rely on a value of 0 meaning the axis is inside the deadzone. + Any value greater than or less than zero is not in the deadzone. + */ +@property (readonly) float value; + +@end diff --git a/apple/common/GameController/GCControllerButtonInput.h b/apple/common/GameController/GCControllerButtonInput.h new file mode 100644 index 0000000000..65e977cee4 --- /dev/null +++ b/apple/common/GameController/GCControllerButtonInput.h @@ -0,0 +1,38 @@ +// +// GCControllerButtonInput.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +GAMECONTROLLER_EXPORT +@interface GCControllerButtonInput : GCControllerElement + +/** + Set this block if you want to be notified when the value on this button changes. + + @param button the element that has been modified. + @param value the value the button was set to at the time the valueChangedHandler fired. + @param pressed the pressed state of the button at the time the valueChangedHandler fired. + */ +typedef void (^GCControllerButtonValueChangedHandler)(GCControllerButtonInput *button, float value, BOOL pressed); +@property (copy) GCControllerButtonValueChangedHandler valueChangedHandler; + +/** + A normalized value for the input. Between 0 and 1 for button inputs. Values are saturated and thus never exceed the range of [0, 1]. + */ +@property (readonly) float value; + +/** + Buttons are mostly used in a digital sense, thus we have a recommended method for checking for pressed state instead of + interpreting the value. + + As a general guideline a button is pressed if the value exceeds 25%. However there may be hysterisis applied + to counter noisy input values, thus incidental values around the threshold value may not trigger a change + in pressed state. + */ +@property (readonly, getter = isPressed) BOOL pressed; + +@end diff --git a/apple/common/GameController/GCControllerDirectionPad.h b/apple/common/GameController/GCControllerDirectionPad.h new file mode 100644 index 0000000000..afb15b3c6d --- /dev/null +++ b/apple/common/GameController/GCControllerDirectionPad.h @@ -0,0 +1,36 @@ +// +// GCControllerDirectionPad.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +/** + A direction pad is a common grouping of 2 axis inputs where the input can also be interpreted as 2 sets of mutually exclusive button pairs. + Only one button in each pair, {up, down} and {left, right}, can be pressed at any one time. + */ +GAMECONTROLLER_EXPORT +@interface GCControllerDirectionPad : GCControllerElement + +/** + Set this block if you want to be notified when the value on this axis changes. + + @param dpad the direction pad collection whose axis have been modified. + @param xValue the value the x axis was set to at the time the valueChangedHandler fired. + @param yValue the value the y axis was set to at the time the valueChangedHandler fired. + */ +typedef void (^GCControllerDirectionPadValueChangedHandler)(GCControllerDirectionPad *dpad, float xValue, float yValue); +@property (copy) GCControllerDirectionPadValueChangedHandler valueChangedHandler; + +@property (readonly) GCControllerAxisInput *xAxis; +@property (readonly) GCControllerAxisInput *yAxis; + +@property (readonly) GCControllerButtonInput *up; +@property (readonly) GCControllerButtonInput *down; + +@property (readonly) GCControllerButtonInput *left; +@property (readonly) GCControllerButtonInput *right; + +@end diff --git a/apple/common/GameController/GCControllerElement.h b/apple/common/GameController/GCControllerElement.h new file mode 100644 index 0000000000..a7e9eb4e58 --- /dev/null +++ b/apple/common/GameController/GCControllerElement.h @@ -0,0 +1,31 @@ +// +// GCControllerElement.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +/** + Every controller element knows which collection it belongs to and whether its input value is analog or digital. + */ +GAMECONTROLLER_EXPORT +@interface GCControllerElement : NSObject + +/** + Each element can be part of a wider collection of inputs that map to a single logical element. A directional pad (dpad) + is a logical collection of two axis inputs and thus each axis belongs to the same collection element - the dpad. + */ +#if !__has_feature(objc_arc) +@property (assign, readonly) GCControllerElement *collection; +#else +@property (weak, readonly) GCControllerElement *collection; +#endif + +/** + Check if the element can support more than just digital values, such as decimal ranges between 0 and 1. + */ +@property (readonly, getter = isAnalog) BOOL analog; + +@end diff --git a/apple/common/GameController/GCExtendedGamepad.h b/apple/common/GameController/GCExtendedGamepad.h new file mode 100644 index 0000000000..00e4fcb0de --- /dev/null +++ b/apple/common/GameController/GCExtendedGamepad.h @@ -0,0 +1,103 @@ +// +// GCExtendedGamepad.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +@class GCController; +@class GCExtendedGamepadSnapshot; + +/** + Extended Gamepad profile. Has all the physical features of a Standard Gamepad and more. + + In comparison to the Standard gamepad, The directional pad on an Extended gamepad is optionally analog + as the two thumbsticks provided are required to be analog. + + All controller profiles provide a base level of information about the controller they belong to. + + A profile maps the hardware notion of a controller into a logical controller. One that a developer can + design for and depend on, no matter the underlying hardware. + */ +GAMECONTROLLER_EXPORT +@interface GCExtendedGamepad : NSObject + +/** + A profile keeps a reference to the controller that this profile is mapping input from. + */ +#if !__has_feature(objc_arc) +@property (readonly, assign) GCController *controller; +#else +@property (readonly, weak) GCController *controller; +#endif + +/** + Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called + for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus + will only call this once with the collection as the element. + + @param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons. + @param element the element that has been modified. + */ +typedef void (^GCExtendedGamepadValueChangedHandler)(GCExtendedGamepad *gamepad, GCControllerElement *element); +@property (copy) GCExtendedGamepadValueChangedHandler valueChangedHandler; + +/** + Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent + format that can be serialized and used at a later date. This is useful for features such as quality assurance, + save game or replay functionality among many. + + If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as + a snapshot will not change based on user input once it is taken. + */ +- (GCExtendedGamepadSnapshot *)saveSnapshot; + +/** + Required to be analog in the Extended profile. All the elements of this directional input are thus analog. + */ +@property (readonly) GCControllerDirectionPad *dpad; + +/** + All face buttons are required to be analog in the Extended profile. These must be arranged + in the diamond pattern given below: + + Y + / \ + X B + \ / + A + + */ +@property (readonly) GCControllerButtonInput *buttonA; +@property (readonly) GCControllerButtonInput *buttonB; +@property (readonly) GCControllerButtonInput *buttonX; +@property (readonly) GCControllerButtonInput *buttonY; + +/** + A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog. + */ +@property (readonly) GCControllerDirectionPad *leftThumbstick; + +/** + A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog. + */ +@property (readonly) GCControllerDirectionPad *rightThumbstick; + +/** + Shoulder buttons are required to be analog inputs. + */ +@property (readonly) GCControllerButtonInput *leftShoulder; +/** + Shoulder buttons are required to be analog inputs. + */ +@property (readonly) GCControllerButtonInput *rightShoulder; + +/** + Triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example. + */ +@property (readonly) GCControllerButtonInput *leftTrigger; +@property (readonly) GCControllerButtonInput *rightTrigger; + +@end diff --git a/apple/common/GameController/GCExtendedGamepadSnapshot.h b/apple/common/GameController/GCExtendedGamepadSnapshot.h new file mode 100644 index 0000000000..8f6cd125f1 --- /dev/null +++ b/apple/common/GameController/GCExtendedGamepadSnapshot.h @@ -0,0 +1,75 @@ +// +// GCExtendedGamepadSnapshot.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +/** + A GCExtendedGamepadSnapshot snapshot is a concrete GCExtendedGamepad implementation. It can be used directly in an + application to implement controller input replays. It is also returned as the result of polling a controller. + + The current snapshotData is readily available to access as NSData. A developer can serialize this to any + destination necessary using the NSData API. + + The data contains some version of a GCExtendedGamepadSnapShotData structure. + + @see -[GCExtendedGamepad saveSnapshot] + */ +GAMECONTROLLER_EXPORT +@interface GCExtendedGamepadSnapshot : GCExtendedGamepad +@property (copy) NSData *snapshotData; + +- (instancetype)initWithSnapshotData:(NSData *)data; +- (instancetype)initWithController:(GCController *)controller snapshotData:(NSData *)data; + +@end + +#pragma pack(push, 1) +typedef struct { + // Standard information + uint16_t version; //0x0100 + uint16_t size; //sizeof(GCExtendedGamepadSnapShotDataV100) or larger + + // Extended gamepad data + // Axes in the range [-1.0, 1.0] + float_t dpadX; + float_t dpadY; + + // Buttons in the range [0.0, 1.0] + float_t buttonA; + float_t buttonB; + float_t buttonX; + float_t buttonY; + float_t leftShoulder; + float_t rightShoulder; + + // Axes in the range [-1.0, 1.0] + float_t leftThumbstickX; + float_t leftThumbstickY; + float_t rightThumbstickX; + float_t rightThumbstickY; + + // Buttons in the range [0.0, 1.0] + float_t leftTrigger; + float_t rightTrigger; + +} GCExtendedGamepadSnapShotDataV100; +#pragma pack(pop) + +/**Fills out a v100 snapshot from any compatible NSData source + + @return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases. + */ +GAMECONTROLLER_EXPORT +BOOL GCExtendedGamepadSnapShotDataV100FromNSData(GCExtendedGamepadSnapShotDataV100 *snapshotData, NSData *data); + +/**Creates an NSData object from a v100 snapshot. + If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCExtendedGamepadSnapShotDataV100) set as the values implicitly. + + @return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCExtendedGamepadSnapshot.snapshotData + */ +GAMECONTROLLER_EXPORT +NSData *NSDataFromGCExtendedGamepadSnapShotDataV100(GCExtendedGamepadSnapShotDataV100 *snapshotData); diff --git a/apple/common/GameController/GCGamepad.h b/apple/common/GameController/GCGamepad.h new file mode 100644 index 0000000000..74de5c3558 --- /dev/null +++ b/apple/common/GameController/GCGamepad.h @@ -0,0 +1,84 @@ +// +// GCGamepad.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +@class GCController; +@class GCGamepadSnapshot; + +/** + Standard Gamepad profile. + + All controller profiles provide a base level of information about the controller they belong to. + + A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for + and depend on, no matter the underlying hardware. + */ +GAMECONTROLLER_EXPORT +@interface GCGamepad : NSObject + +/** + A profile keeps a reference to the controller that this profile is mapping input from. + */ +#if !__has_feature(objc_arc) +@property (readonly, assign) GCController *controller; +#else +@property (readonly, weak) GCController *controller; +#endif + +/** + Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called + for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus + will only call this once with the collection as the element. + + @param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons. + @param element the element that has been modified. + */ +typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerElement *element); +@property (copy) GCGamepadValueChangedHandler valueChangedHandler; + +/** + Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent + format that can be serialized and used at a later date. This is useful for features such as quality assurance, + save game or replay functionality among many. + + If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as + a snapshot will not change based on user input once it is taken. + */ +- (GCGamepadSnapshot *)saveSnapshot; + +/** + Required to be analog in the Standard profile. All the elements of this directional input are thus analog. + */ +@property (readonly) GCControllerDirectionPad *dpad; + +/** + All face buttons are required to be analog in the Standard profile. These must be arranged + in the diamond pattern given below: + + Y + / \ + X B + \ / + A + + */ +@property (readonly) GCControllerButtonInput *buttonA; +@property (readonly) GCControllerButtonInput *buttonB; +@property (readonly) GCControllerButtonInput *buttonX; +@property (readonly) GCControllerButtonInput *buttonY; + +/** + Shoulder buttons are required to be analog inputs. + */ +@property (readonly) GCControllerButtonInput *leftShoulder; +/** + Shoulder buttons are required to be analog inputs. + */ +@property (readonly) GCControllerButtonInput *rightShoulder; + +@end diff --git a/apple/common/GameController/GCGamepadSnapshot.h b/apple/common/GameController/GCGamepadSnapshot.h new file mode 100644 index 0000000000..b81922483c --- /dev/null +++ b/apple/common/GameController/GCGamepadSnapshot.h @@ -0,0 +1,66 @@ +// +// GCGamepadSnapshot.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import "GameController.h" + +/** + A GCGamepadSnapshot snapshot is a concrete GCGamepad implementation. It can be used directly in an + application to implement controller input replays. It is also returned as the result of polling + a controller. + + The current snapshotData is readily available to access as NSData. A developer can serialize this to any + destination necessary using the NSData API. + + The data contains some version of a GCGamepadSnapShotData structure. + + @see -[GCGamepad saveSnapshot] + */ +GAMECONTROLLER_EXPORT +@interface GCGamepadSnapshot : GCGamepad +@property (copy) NSData *snapshotData; + +- (instancetype)initWithSnapshotData:(NSData *)data; +- (instancetype)initWithController:(GCController *)controller snapshotData:(NSData *)data; + +@end + +#pragma pack(push, 1) +typedef struct { + // Standard information + uint16_t version; //0x0100 + uint16_t size; //sizeof(GCGamepadSnapShotDataV100) or larger + + // Standard gamepad data + // Axes in the range [-1.0, 1.0] + float_t dpadX; + float_t dpadY; + + // Buttons in the range [0.0, 1.0] + float_t buttonA; + float_t buttonB; + float_t buttonX; + float_t buttonY; + float_t leftShoulder; + float_t rightShoulder; + +} GCGamepadSnapShotDataV100; +#pragma pack(pop) + +/**Fills out a v100 snapshot from any compatible NSData source + + @return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases. + */ +GAMECONTROLLER_EXPORT +BOOL GCGamepadSnapShotDataV100FromNSData(GCGamepadSnapShotDataV100 *snapshotData, NSData *data); + +/**Creates an NSData object from a v100 snapshot. + If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCGamepadSnapShotDataV100) set as the values implicitly. + + @return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCGamepadSnapshot.snapshotData + */ +GAMECONTROLLER_EXPORT +NSData *NSDataFromGCGamepadSnapShotDataV100(GCGamepadSnapShotDataV100 *snapshotData); diff --git a/apple/common/GameController/GameController.h b/apple/common/GameController/GameController.h new file mode 100644 index 0000000000..6cdc03e229 --- /dev/null +++ b/apple/common/GameController/GameController.h @@ -0,0 +1,30 @@ +// +// GameController.h +// GameController +// +// Copyright (c) 2012 Apple Inc. All rights reserved. +// + +#import + +#ifdef __cplusplus +#define GAMECONTROLLER_EXTERN extern "C" __attribute__((visibility ("default"))) +#else +#define GAMECONTROLLER_EXTERN extern __attribute__((visibility ("default"))) +#endif + +#define GAMECONTROLLER_EXPORT NS_CLASS_AVAILABLE(10_9, 7_0) + +#import "GCControllerElement.h" + +#import "GCControllerAxisInput.h" +#import "GCControllerButtonInput.h" +#import "GCControllerDirectionPad.h" + +#import "GCGamepad.h" +#import "GCGamepadSnapshot.h" + +#import "GCExtendedGamepad.h" +#import "GCExtendedGamepadSnapshot.h" + +#import "GCController.h" \ No newline at end of file diff --git a/apple/common/apple_gamecontroller.m b/apple/common/apple_gamecontroller.m index ed01efacef..1dc35b2e26 100644 --- a/apple/common/apple_gamecontroller.m +++ b/apple/common/apple_gamecontroller.m @@ -15,9 +15,7 @@ #include #include "RetroArch_Apple.h" -#ifdef __IPHONE_7_0 -#import -#endif +#import "GameController/GameController.h" #include "apple_gamecontroller.h" #include "../../input/drivers/apple_input.h" diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index fc0be37286..d760975999 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ 84F9A9C81A87E250003AF12F /* cht in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A9C11A87E180003AF12F /* cht */; }; 96366C5516C9AC3300D64A22 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96366C5416C9AC3300D64A22 /* CoreAudio.framework */; }; 96366C5916C9ACF500D64A22 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96366C5816C9ACF500D64A22 /* AudioToolbox.framework */; }; - 963C3C34186E3DED00A6EB1E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963C3C33186E3DED00A6EB1E /* GameController.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 967894631788EBD800D6CA69 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 967894611788EBD800D6CA69 /* InfoPlist.strings */; }; 96AFAE2A16C1D4EA009DE44C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2916C1D4EA009DE44C /* UIKit.framework */; }; 96AFAE2C16C1D4EA009DE44C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2B16C1D4EA009DE44C /* Foundation.framework */; }; @@ -92,7 +91,6 @@ buildActionMask = 2147483647; files = ( 696012F219F3389A006A1088 /* CoreText.framework in Frameworks */, - 963C3C34186E3DED00A6EB1E /* GameController.framework in Frameworks */, 50CCC828185E0E7D001F5BC8 /* CoreLocation.framework in Frameworks */, 501881EE184BB54C006F665D /* CoreMedia.framework in Frameworks */, 501881EC184BAD6D006F665D /* AVFoundation.framework in Frameworks */, @@ -415,6 +413,7 @@ "-DWANT_MINIZ", "-DSINC_LOWER_QUALITY", ); + "OTHER_LDFLAGS[arch=*]" = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = "armv7 armv7s"; @@ -470,6 +469,7 @@ "-DWANT_MINIZ", "-DSINC_LOWER_QUALITY", ); + "OTHER_LDFLAGS[arch=*]" = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES;