Skip to content

GameController tvOS xcode14.0 beta2

tj_devel709 edited this page Aug 23, 2022 · 3 revisions

#GameController.framework https://github.com/xamarin/xamarin-macios/pull/15692

diff -ruN /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCDevicePhysicalInputState.h /Applications/Xcode_14.0.0-beta2.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCDevicePhysicalInputState.h
--- /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCDevicePhysicalInputState.h	2022-06-03 18:06:34.000000000 -0400
+++ /Applications/Xcode_14.0.0-beta2.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCDevicePhysicalInputState.h	2022-06-17 14:48:27.000000000 -0400
@@ -7,6 +7,7 @@
 
 #import <Foundation/Foundation.h>
 
+#import <GameController/GCInputNames.h>
 #import <GameController/GCPhysicalInputElement.h>
 #import <GameController/GCButtonElement.h>
 #import <GameController/GCAxisElement.h>
@@ -58,21 +59,21 @@
  The following properties allow for runtime lookup of any input element on a
  profile, when provided with a valid alias.
 
- @example input.elements["Button A"] == extendedGamepad.buttonA // YES
- @example input.dpads["Left Thumbstick"] == extendedGamepad.leftThumbstick // YES
- @example input.dpads["Button B"] // returns nil, "Button B" is not a DirectionPad
- */
-@property (readonly) NSDictionary<NSString *, id<GCPhysicalInputElement> > *elements;
-@property (readonly) NSDictionary<NSString *, id<GCButtonElement> > *buttons;
-@property (readonly) NSDictionary<NSString *, id<GCAxisElement> > *axes;
-@property (readonly) NSDictionary<NSString *, id<GCSwitchElement> > *switches;
-@property (readonly) NSDictionary<NSString *, id<GCDirectionPadElement> > *dpads;
+ @example input.elements[GCInputButtonA]
+ @example input.dpads[GCInputLeftThumbstick]
+ @example input.dpads[GCInputButtonB] // fails, "Button B" is not a DirectionPad
+ */
+@property (readonly) GCPhysicalInputElementCollection<GCInputElementName, id<GCPhysicalInputElement>> *elements NS_REFINED_FOR_SWIFT;
+@property (readonly) GCPhysicalInputElementCollection<GCInputButtonName, id<GCButtonElement>> *buttons NS_REFINED_FOR_SWIFT;
+@property (readonly) GCPhysicalInputElementCollection<GCInputAxisName, id<GCAxisElement>> *axes NS_REFINED_FOR_SWIFT;
+@property (readonly) GCPhysicalInputElementCollection<GCInputSwitchName, id<GCSwitchElement>> *switches NS_REFINED_FOR_SWIFT;
+@property (readonly) GCPhysicalInputElementCollection<GCInputDirectionPadName, id<GCDirectionPadElement>> *dpads NS_REFINED_FOR_SWIFT;
 
 /**
  Profile elements can be accessed using keyed subscript notation, with a valid alias of its inputs.
  
- @example physicalInput["Button A"] == extendedGamepad.buttonA // YES
- @example physicalInput["Button X"] == microGamepad.buttonX // YES
+ @example physicalInput[GCInputButtonA]
+ @example physicalInput[GCInputButtonX]
  @note Equivalent to -elements
  */
 - (__kindof id<GCPhysicalInputElement> _Nullable)objectForKeyedSubscript:(NSString *)key;
diff -ruN /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCInputNames.h /Applications/Xcode_14.0.0-beta2.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCInputNames.h
--- /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCInputNames.h	2022-06-03 18:06:34.000000000 -0400
+++ /Applications/Xcode_14.0.0-beta2.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCInputNames.h	2022-06-17 11:24:49.000000000 -0400
@@ -9,6 +9,34 @@
 
 #import <GameController/GCExtern.h>
 
+__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
+@protocol GCPhysicalInputElementName
+@end
+
+__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
+@protocol GCButtonElementName <GCPhysicalInputElementName>
+@end
+
+__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
+@protocol GCAxisElementName <GCPhysicalInputElementName>
+@end
+
+__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
+@protocol GCSwitchElementName <GCPhysicalInputElementName>
+@end
+
+__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
+@protocol GCDirectionPadElementName <GCPhysicalInputElementName>
+@end
+
+
+typedef NSString<GCPhysicalInputElementName> *const GCInputElementName NS_TYPED_EXTENSIBLE_ENUM NS_REFINED_FOR_SWIFT;
+typedef NSString<GCButtonElementName> *const GCInputButtonName NS_TYPED_EXTENSIBLE_ENUM NS_REFINED_FOR_SWIFT;
+typedef NSString<GCAxisElementName> *const GCInputAxisName NS_TYPED_EXTENSIBLE_ENUM NS_REFINED_FOR_SWIFT;
+typedef NSString<GCSwitchElementName> *const GCInputSwitchName NS_TYPED_EXTENSIBLE_ENUM NS_REFINED_FOR_SWIFT;
+typedef NSString<GCDirectionPadElementName> *const GCInputDirectionPadName NS_TYPED_EXTENSIBLE_ENUM NS_REFINED_FOR_SWIFT;
+
+
 /**
 A set of commonly used strings that can be used to access controller buttons
  
@@ -18,26 +46,26 @@
 @see GCPhysicalInputProfile.h
 */
 
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonA API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonB API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonX API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonY API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-
-GAMECONTROLLER_EXTERN NSString *const GCInputDirectionPad API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputLeftThumbstick API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputRightThumbstick API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-
-GAMECONTROLLER_EXTERN NSString *const GCInputLeftShoulder API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputRightShoulder API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputLeftTrigger API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputRightTrigger API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputLeftThumbstickButton API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputRightThumbstickButton API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonHome API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonMenu API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonOptions API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputButtonShare API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonA NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonB NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonX NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonY NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+
+GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputDirectionPad NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputLeftThumbstick NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputRightThumbstick NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftShoulder NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightShoulder NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftTrigger NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightTrigger NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftThumbstickButton NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightThumbstickButton NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonHome NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonMenu NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonOptions NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonShare NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
 
 /**
 A set of strings commonly used to access Xbox buttons
@@ -47,10 +75,10 @@
 @see GCController.h
 @see GCPhysicalInputProfile.h
 */
-GAMECONTROLLER_EXTERN NSString *const GCInputXboxPaddleOne API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputXboxPaddleTwo API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputXboxPaddleThree API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputXboxPaddleFour API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleOne NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleTwo NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleThree NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleFour NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
 
 /**
 A set of strings commonly used to access DualShock buttons
@@ -60,17 +88,17 @@
 @see GCController.h
 @see GCPhysicalInputProfile.h
 */
-GAMECONTROLLER_EXTERN NSString *const GCInputDualShockTouchpadOne API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputDualShockTouchpadTwo API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputDualShockTouchpadButton API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputDualShockTouchpadOne NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputDualShockTouchpadTwo NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputDualShockTouchpadButton NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
 
 /**
 A set of strings commonly used by racing wheels.
 */
-GAMECONTROLLER_EXTERN NSString *const GCInputSteeringWheel API_AVAILABLE(macos(13.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputShifter API_AVAILABLE(macos(13.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputPedalAccelerator API_AVAILABLE(macos(13.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputPedalBrake API_AVAILABLE(macos(13.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputPedalClutch API_AVAILABLE(macos(13.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputLeftPaddle API_AVAILABLE(macos(13.0));
-GAMECONTROLLER_EXTERN NSString *const GCInputRightPaddle API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputAxisName GCInputSteeringWheel NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputElementName GCInputShifter NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputPedalAccelerator NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputPedalBrake NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputPedalClutch NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftPaddle NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
+GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightPaddle NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0));
diff -ruN /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCPhysicalInputElement.h /Applications/Xcode_14.0.0-beta2.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCPhysicalInputElement.h
--- /Applications/Xcode_14.0.0-beta.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCPhysicalInputElement.h	2022-06-03 18:06:36.000000000 -0400
+++ /Applications/Xcode_14.0.0-beta2.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/GameController.framework/Headers/GCPhysicalInputElement.h	2022-06-17 14:48:29.000000000 -0400
@@ -23,11 +23,44 @@
 @property (readonly, nullable) NSString *localizedName;
 
 /**
- A set of aliases that can be used to access this element with keyed subscript
+ The set of aliases that can be used to access this element with keyed subscript
  notation.
  */
 @property (readonly) NSSet<NSString *> *aliases;
 
 @end
 
+
+
+/**
+ An instance of \c GCPhysicalInputElementCollection contains the collection of
+ input elements found in a device's physical input profile.
+ */
+API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0)) NS_REFINED_FOR_SWIFT
+@interface GCPhysicalInputElementCollection<Key: NSString*, Element: id<GCPhysicalInputElement>> : NSObject <NSFastEnumeration>
+
++ (instancetype)new NS_UNAVAILABLE;
+- (instancetype)init NS_UNAVAILABLE;
+
+/** The number of elements in the collection. */
+@property (readonly) NSUInteger count;
+
+/**
+ Returns the element associated with a given alias.
+ 
+ @param alias
+ The alias for which to return the corresponding element.  Typically, you
+ pass one of the constants defined in \c GCInputNames.h.
+ 
+ @return
+ The element associated with \a alias, or nil if no element is associated
+ with \a alias.
+ */
+- (Element _Nullable)elementForAlias:(Key)alias;
+- (Element _Nullable)objectForKeyedSubscript:(Key)key;
+
+- (NSEnumerator<Element> *)elementEnumerator;
+
+@end
+
 NS_ASSUME_NONNULL_END
Clone this wiki locally