diff --git a/src/GameController/GCInput.cs b/src/GameController/GCInput.cs new file mode 100644 index 000000000000..f9e7ed96d1a5 --- /dev/null +++ b/src/GameController/GCInput.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#nullable enable + +using System; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +using CoreFoundation; +using CoreGraphics; +using Foundation; +using ObjCRuntime; + +namespace GameController { + public partial class GCInput { + [SupportedOSPlatform ("ios17.4")] + [SupportedOSPlatform ("macos14.4")] + [SupportedOSPlatform ("tvos17.4")] + [SupportedOSPlatform ("maccatalyst17.4")] + [DllImport (Constants.GameControllerLibrary)] + static extern IntPtr /* GCButtonElementName */ GCInputBackLeftButton (nint position); + + // A strongly-typed API (the GCInputButtonName enum) is not possible, because it's not an exhaustive enum, + // this method may return strings that aren't in the enum. + /// Get the name of the back left button on the controller for the specified position. + /// Zero-based position of the button. + /// The name of the back left button on the controller for the specified position. + [SupportedOSPlatform ("ios17.4")] + [SupportedOSPlatform ("macos14.4")] + [SupportedOSPlatform ("tvos17.4")] + [SupportedOSPlatform ("maccatalyst17.4")] + public static NSString? GetBackLeftButtonName (nint position) + { + return Runtime.GetNSObject (GCInputBackLeftButton (position)); + } + + [SupportedOSPlatform ("ios17.4")] + [SupportedOSPlatform ("macos14.4")] + [SupportedOSPlatform ("tvos17.4")] + [SupportedOSPlatform ("maccatalyst17.4")] + [DllImport (Constants.GameControllerLibrary)] + static extern IntPtr /* GCButtonElementName */ GCInputBackRightButton (nint position); + + // A strongly-typed API (the GCInputButtonName enum) is not possible, because it's not an exhaustive enum, + // this method may return strings that aren't in the enum. + /// Get the name of the back right button on the controller for the specified position. + /// Zero-based position of the button. + /// The name of the back rught button on the controller for the specified position. + [SupportedOSPlatform ("ios17.4")] + [SupportedOSPlatform ("macos14.4")] + [SupportedOSPlatform ("tvos17.4")] + [SupportedOSPlatform ("maccatalyst17.4")] + public static NSString? GetBackRightButtonName (nint position) + { + return Runtime.GetNSObject (GCInputBackRightButton (position)); + } + + // headers claim macOS 13.0 / iOS 16.0, but introspection says macOS 14.0 / iOS 17.0, so use that. + [SupportedOSPlatform ("ios17.0")] + [SupportedOSPlatform ("macos14.0")] + [SupportedOSPlatform ("tvos17.0")] + [SupportedOSPlatform ("maccatalyst17.0")] + [DllImport (Constants.GameControllerLibrary)] + static extern IntPtr /* GCButtonElementName */ GCInputArcadeButtonName (nint row, nint column); + + // A strongly-typed API (the GCInputButtonName enum) is not possible, because it's not an exhaustive enum, + // this method may return strings that aren't in the enum. + /// Get the name of the arcade button for the specified position. + /// The row of the arcade button. + /// The column of the arcade button. + /// The name of the arcade button on the controller for the specified position. + [SupportedOSPlatform ("ios17.0")] + [SupportedOSPlatform ("macos14.0")] + [SupportedOSPlatform ("tvos17.0")] + [SupportedOSPlatform ("maccatalyst17.0")] + public static NSString? GetArcadeButtonName (nint row, nint column) + { + return Runtime.GetNSObject (GCInputArcadeButtonName (row, column)); + } + } +} diff --git a/src/GameController/GCPhysicalInputElementCollection.cs b/src/GameController/GCPhysicalInputElementCollection.cs new file mode 100644 index 000000000000..60ab33856486 --- /dev/null +++ b/src/GameController/GCPhysicalInputElementCollection.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using System.Collections; +using System.Collections.Generic; + +using Foundation; +using ObjCRuntime; + +#nullable enable + +namespace GameController { + public partial class GCPhysicalInputElementCollection : IEnumerable { + #region IEnumerable + IEnumerator IEnumerable.GetEnumerator () + { + return new NSFastEnumerator (this); + } + #endregion + + #region IEnumerable implementation + IEnumerator IEnumerable.GetEnumerator () + { + return new NSFastEnumerator (this); + } + #endregion + } +} diff --git a/src/GameController/GCPoint2.cs b/src/GameController/GCPoint2.cs new file mode 100644 index 000000000000..a7ede5ca6445 --- /dev/null +++ b/src/GameController/GCPoint2.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#nullable enable + +using System; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +using CoreFoundation; +using CoreGraphics; +using Foundation; +using ObjCRuntime; + +namespace GameController { + /// Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimensional plane. + [SupportedOSPlatform ("ios")] + [SupportedOSPlatform ("maccatalyst")] + [SupportedOSPlatform ("macos")] + [SupportedOSPlatform ("tvos")] + public struct GCPoint2 +#if !COREBUILD + : IEquatable +#endif + { + float x; + float y; + + /// Gets or sets the x-coordinate of this . + /// The x-coordinate of this . + public float X { + get { return x; } + set { x = value; } + } + + /// Gets or sets the y-coordinate of this . + /// The y-coordinate of this . + public float Y { + get { return y; } + set { y = value; } + } + +#if !COREBUILD + /// Represents a new instance of the where both the and coordinates are 0. + public static readonly GCPoint2 Zero; + + /// Compares two values for equality. + /// The left-hand side of the comparison. + /// The right-hand side of the comparison. + /// if and are equal, otherwise . + public static bool operator == (GCPoint2 l, GCPoint2 r) + { + return l.Equals (r); + } + + /// Compares two values for inequality. + /// The left-hand side of the comparison. + /// The right-hand side of the comparison. + /// if and are not equal, otherwise . + public static bool operator != (GCPoint2 l, GCPoint2 r) + { + return !l.Equals (r); + } + + /// Gets a value indicating whether this is empty. + /// if both and are 0,, otherwise . + public bool IsEmpty { + get { return x == 0.0 && y == 0.0; } + } + + /// Initializes a new instance of the struct with the specified coordinates. + /// The X coordinate of the point. + /// The X coordinate of the point. + public GCPoint2 (float x, float y) + { + this.x = x; + this.y = y; + } + + /// Initializes a new instance of the struct from the specified . + /// The source point. + public GCPoint2 (GCPoint2 point) + { + this.x = point.x; + this.y = point.y; + } + + /// Specifies whether this contains the same coordinates as the specified . + /// The to compare with this object. + /// if is a with the same coordinates as this point, otherwise . + public override bool Equals (object? obj) + { + return (obj is GCPoint2 t) && Equals (t); + } + + /// Specifies whether this contains the same coordinates as the specified . + /// The to compare with this object. + /// if has the same coordinates as this point, otherwise . + public bool Equals (GCPoint2 point) + { + return point.x == x && point.y == y; + } + + /// Returns a hash code for this structure. + /// An integer value that specifies a hash value for this structure. + public override int GetHashCode () + { + return HashCode.Combine (x, y); + } + + /// Deconstructs by and . + /// Deconstructed parameter for . + /// Deconstructed parameter for . + public void Deconstruct (out nfloat x, out nfloat y) + { + x = X; + y = Y; + } + + /// Converts this to a human readable string. + /// A string that represents this . + public override string? ToString () + { + if (OperatingSystem.IsMacOSVersionAtLeast (14, 3) || + OperatingSystem.IsMacCatalystVersionAtLeast (17, 4) || + OperatingSystem.IsIOSVersionAtLeast (17, 4) || + OperatingSystem.IsTvOSVersionAtLeast (17, 4)) + return CFString.FromHandle (NSStringFromGCPoint2 (this)); + return $"{{{x}, {y}}}"; + } + + [SupportedOSPlatform ("ios17.4")] + [SupportedOSPlatform ("tvos17.4")] + [SupportedOSPlatform ("maccatalyst17.4")] + [SupportedOSPlatform ("macos14.3")] + [DllImport (Constants.GameControllerLibrary)] + extern static /* NSString* */ IntPtr NSStringFromGCPoint2 (/* GCPoint2 */ GCPoint2 point); +#endif // !COREBUILD + } +} diff --git a/src/frameworks.sources b/src/frameworks.sources index 5d5f59f1e72c..1cdcc189b693 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -947,12 +947,15 @@ GAMECONTROLLER_API_SOURCES = \ GAMECONTROLLER_CORE_SOURCES = \ GameController/GCController.cs \ GameController/GCMotion.cs \ + GameController/GCPoint2.cs \ GAMECONTROLLER_SOURCES = \ GameController/GCExtendedGamepadSnapshot.cs \ GameController/GCGamepadSnapshot.cs \ + GameController/GCInput.cs \ GameController/GCMicroGamepadSnapshot.cs \ GameController/GCMouse.cs \ + GameController/GCPhysicalInputElementCollection.cs \ # GameKit diff --git a/src/gamecontroller.cs b/src/gamecontroller.cs index 8dc15a963626..296e20661110 100644 --- a/src/gamecontroller.cs +++ b/src/gamecontroller.cs @@ -12,6 +12,7 @@ using System; using CoreFoundation; +using CoreGraphics; using Foundation; using ObjCRuntime; #if !NET @@ -37,6 +38,16 @@ namespace GameController { + [Flags] + [Native] + public enum GCPhysicalInputSourceDirection : ulong { + NotApplicable = 0x0, + Up = (1uL << 0), + Right = (1uL << 1), + Down = (1uL << 2), + Left = (1uL << 3), + } + /// The base class for input elements of a game controller. /// /// Apple documentation for GCControllerElement @@ -392,6 +403,7 @@ partial interface GCExtendedGamepad { /// To be added. /// To be added. [Export ("controller", ArgumentSemantic.Assign)] + [NullAllowed] GCController Controller { get; } /// To be added. @@ -743,6 +755,10 @@ partial interface GCController : GCDevice { [Static] [Export ("shouldMonitorBackgroundEvents")] bool ShouldMonitorBackgroundEvents { get; set; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Export ("input", ArgumentSemantic.Strong)] + GCControllerLiveInput Input { get; } } /// Holds position data of a game controller. @@ -907,6 +923,7 @@ interface GCMicroGamepad { /// The controller for this profile. /// To be added. [Export ("controller", ArgumentSemantic.Assign)] + [NullAllowed] GCController Controller { get; } /// Gets or sets a handler that is called whenever the state of any controller element changes @@ -1111,7 +1128,6 @@ interface GCDeviceHaptics { [Export ("supportedLocalities", ArgumentSemantic.Strong)] NSSet SupportedLocalities { get; } - [NoMac] // TODO: Remove [NoMac] when CoreHaptics can compile on Mac OSX: https://github.com/xamarin/maccore/issues/2261 [MacCatalyst (13, 1)] [Export ("createEngineWithLocality:")] [return: NullAllowed] @@ -1476,6 +1492,14 @@ interface GCInput { [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] [Field ("GCInputSteeringWheel")] NSString /* IGCAxisElementName */ SteeringWheel { get; } + + [TV (17, 4), Mac (14, 4), iOS (17, 4), MacCatalyst (17, 4)] + [Field ("GCInputLeftBumper")] + NSString /* GCButtonElementName */ LeftBumper { get; } + + [TV (17, 4), Mac (14, 4), iOS (17, 4), MacCatalyst (17, 4)] + [Field ("GCInputRightBumper")] + NSString /* GCButtonElementName */ RightBumper { get; } } [TV (14, 0), iOS (14, 0)] @@ -1499,6 +1523,125 @@ interface GCXboxGamepad : NSSecureCoding, NSCoding { GCControllerButtonInput ButtonShare { get; } } + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + public enum GCInputElementName { + [Field ("GCInputShifter")] + Shifter, + } + + [TV (14, 0), iOS (14, 0), MacCatalyst (14, 0)] + public enum GCInputButtonName { + [Field ("GCInputButtonA")] + ButtonA, + + [Field ("GCInputButtonB")] + ButtonB, + + [Field ("GCInputButtonX")] + ButtonX, + + [Field ("GCInputButtonY")] + ButtonY, + + [Field ("GCInputLeftThumbstickButton")] + LeftThumbstickButton, + + [Field ("GCInputRightThumbstickButton")] + RightThumbstickButton, + + [Field ("GCInputLeftShoulder")] + LeftShoulder, + + [Field ("GCInputRightShoulder")] + RightShoulder, + + [TV (17, 4), Mac (14, 4), iOS (17, 4), MacCatalyst (17, 4)] + [Field ("GCInputLeftBumper")] + LeftBumper, + + [TV (17, 4), Mac (14, 4), iOS (17, 4), MacCatalyst (17, 4)] + [Field ("GCInputRightBumper")] + RightBumper, + + [Field ("GCInputLeftTrigger")] + LeftTrigger, + + [Field ("GCInputRightTrigger")] + RightTrigger, + + [Field ("GCInputButtonHome")] + ButtonHome, + + [Field ("GCInputButtonMenu")] + ButtonMenu, + + [Field ("GCInputButtonOptions")] + ButtonOptions, + + [TV (15, 0), iOS (15, 0), MacCatalyst (15, 0)] + [Field ("GCInputButtonShare")] + ButtonShare, + + [Field ("GCInputXboxPaddleOne")] + PaddleOne, + + [Field ("GCInputXboxPaddleTwo")] + PaddleTwo, + + [Field ("GCInputXboxPaddleThree")] + PaddleThree, + + [Field ("GCInputXboxPaddleFour")] + PaddleFour, + + [Field ("GCInputDualShockTouchpadButton")] + DualShockTouchpadButton, + + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + [Field ("GCInputLeftPaddle")] + LeftPaddle, + + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + [Field ("GCInputPedalAccelerator")] + PedalAccelerator, + + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + [Field ("GCInputPedalBrake")] + PedalBrake, + + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + [Field ("GCInputPedalClutch")] + PedalClutch, + + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + [Field ("GCInputRightPaddle")] + RightPaddle, + } + + [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] + public enum GCInputAxisName { + [Field ("GCInputSteeringWheel")] + SteeringWheel, + } + + [TV (14, 0), iOS (14, 0), MacCatalyst (14, 0)] + public enum GCInputDirectionPadName { + [Field ("GCInputDirectionPad")] + DirectionPad, + + [Field ("GCInputLeftThumbstick")] + LeftThumbstick, + + [Field ("GCInputRightThumbstick")] + RightThumbstick, + + [Field ("GCInputDualShockTouchpadOne")] + DualShockTouchpadOne, + + [Field ("GCInputDualShockTouchpadTwo")] + DualShockTouchpadTwo, + } + [Static] [TV (14, 0), iOS (14, 0)] [MacCatalyst (14, 0)] @@ -2517,6 +2660,14 @@ interface GCVirtualController { [Export ("updateConfigurationForElement:configuration:")] void UpdateConfiguration (string element, GCVirtualControllerElementUpdateBlock configuration); + + [iOS (17, 0), MacCatalyst (17, 0)] + [Export ("setValue:forButtonElement:")] + void SetValue (nfloat value, string element); + + [iOS (17, 0), MacCatalyst (17, 0)] + [Export ("setPosition:forDirectionPadElement:")] + void SetPosition (CGPoint position, string element); } [NoTV, NoMac, iOS (15, 0), MacCatalyst (15, 0)] @@ -2580,9 +2731,20 @@ interface GCProductCategory { [Field ("GCProductCategoryKeyboard")] NSString Keyboard { get; } +#if !XAMCORE_5_0 + [Obsolete ("Use 'Hid' instead.")] [iOS (16, 0), Mac (13, 0), TV (16, 0), MacCatalyst (16, 0)] [Field ("GCProductCategoryHID")] NSString GCProductCategoryHid { get; } +#endif + + [iOS (16, 0), Mac (13, 0), TV (16, 0), MacCatalyst (16, 0)] + [Field ("GCProductCategoryHID")] + NSString Hid { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Field ("GCProductCategoryArcadeStick")] + NSString ArcadeStick { get; } } [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] @@ -2657,28 +2819,27 @@ interface GCSteeringWheelElement : GCAxisElement { float MaximumDegreesOfRotation { get; } } - // There are issues with the Generic Types listed here: https://github.com/dotnet/macios/issues/15725 - // [iOS (16,0), Mac (13,0), TV (16,0), MacCatalyst (16,0)] - // [BaseType (typeof (NSObject))] - // [DisableDefaultCtor] - // interface GCPhysicalInputElementCollection // : INSFastEnumeration // # no generator support for FastEnumeration - https://bugzilla.xamarin.com/show_bug.cgi?id=4391 - // where KeyIdentifierType : IGCPhysicalInputElementName /* NSString */ // there's currently not an conversion from GCPhysicalInputElementName, GCButtonElementName, and GCDirectionPadElementName to NSString - // where ElementIdentifierType : IGCPhysicalInputElement /* id> */ - // { - // [Export ("count")] - // nuint Count { get; } - - // [Export ("elementForAlias:")] - // [return: NullAllowed] - // IGCPhysicalInputElement GetElement (string alias); + [iOS (16, 0), Mac (13, 0), TV (16, 0), MacCatalyst (16, 0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface GCPhysicalInputElementCollection : INSFastEnumeration // # no generator support for FastEnumeration - https://github.com/dotnet/macios/issues/22516 + where KeyIdentifierType : NSString + where ElementIdentifierType : IGCPhysicalInputElement /* id> */ + { + [Export ("count")] + nuint Count { get; } + + [Export ("elementForAlias:")] + [return: NullAllowed] + IGCPhysicalInputElement GetElement (string alias); - // [Export ("objectForKeyedSubscript:")] - // [return: NullAllowed] - // IGCPhysicalInputElement GetObject (string key); + [Export ("objectForKeyedSubscript:")] + [return: NullAllowed] + IGCPhysicalInputElement GetObject (string key); - // [Export ("elementEnumerator")] - // NSEnumerator ElementEnumerator { get; } - // } + [Export ("elementEnumerator")] + NSEnumerator ElementEnumerator { get; } + } interface IGCDevicePhysicalInputState { } @@ -2697,30 +2858,25 @@ interface GCDevicePhysicalInputState { [Export ("lastEventLatency")] double LastEventLatency { get; } - // Issue with GCPhysicalInputElementCollection found here: https://github.com/dotnet/macios/issues/15725 - // [Abstract] - // [Export ("elements")] - // GCPhysicalInputElementCollection Elements { get; } + [Abstract] + [Export ("elements")] + GCPhysicalInputElementCollection Elements { get; } - // Issue with GCPhysicalInputElementCollection found here: https://github.com/dotnet/macios/issues/15725 - // [Abstract] - // [Export ("buttons")] - // GCPhysicalInputElementCollection Buttons { get; } + [Abstract] + [Export ("buttons")] + GCPhysicalInputElementCollection Buttons { get; } - // Issue with GCPhysicalInputElementCollection found here: https://github.com/dotnet/macios/issues/15725 - // [Abstract] - // [Export ("axes")] - // GCPhysicalInputElementCollection Axes { get; } + [Abstract] + [Export ("axes")] + GCPhysicalInputElementCollection Axes { get; } - // Issue with GCPhysicalInputElementCollection found here: https://github.com/dotnet/macios/issues/15725 - // [Abstract] - // [Export ("switches")] - // GCPhysicalInputElementCollection Switches { get; } + [Abstract] + [Export ("switches")] + GCPhysicalInputElementCollection Switches { get; } - // Issue with GCPhysicalInputElementCollection found here: https://github.com/dotnet/macios/issues/15725 - // [Abstract] - // [Export ("dpads")] - // GCPhysicalInputElementCollection Dpads { get; } + [Abstract] + [Export ("dpads")] + GCPhysicalInputElementCollection Dpads { get; } [Abstract] [Export ("objectForKeyedSubscript:")] @@ -2756,9 +2912,14 @@ interface GCAxisInput { [Abstract] [Export ("lastValueLatency")] double LastValueLatency { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } } - interface IGCAxisElement { } + interface IGCAxisElement : IGCPhysicalInputElement { } [Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), TV (16, 0)] [Protocol] @@ -2772,7 +2933,7 @@ interface GCAxisElement : GCPhysicalInputElement { IGCRelativeInput RelativeInput { get; } } - interface IGCButtonElement { } + interface IGCButtonElement : IGCPhysicalInputElement { } [Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), TV (16, 0)] [Protocol] @@ -2789,7 +2950,7 @@ interface GCButtonElement : GCPhysicalInputElement { delegate void ElementValueDidChangeHandler (IGCDevicePhysicalInput physicalInput, IGCPhysicalInputElement element); delegate void InputStateAvailableHandler (IGCDevicePhysicalInput physicalInput); - interface IGCDevicePhysicalInput { } + interface IGCDevicePhysicalInput : IGCPhysicalInputElement { } [Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), TV (16, 0)] [Protocol] @@ -2821,6 +2982,11 @@ interface GCDevicePhysicalInput : GCDevicePhysicalInputState { [Abstract] [NullAllowed, Export ("nextInputState")] NSObject NextInputState { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Abstract] + [NullAllowed, Export ("queue", ArgumentSemantic.Strong)] + DispatchQueue Queue { get; set; } } interface IGCDevicePhysicalInputStateDiff { } @@ -2837,7 +3003,7 @@ interface GCDevicePhysicalInputStateDiff { NSEnumerator ChangedElements { get; } } - interface IGCDirectionPadElement { } + interface IGCDirectionPadElement : IGCPhysicalInputElement { } [Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), TV (16, 0)] [Protocol] @@ -2865,6 +3031,11 @@ interface GCDirectionPadElement : GCPhysicalInputElement { [Abstract] [Export ("right")] NSObject Right { get; } + + [TV (17, 4), Mac (14, 3), iOS (17, 4), MacCatalyst (17, 4)] + [Abstract] + [Export ("xyAxes")] + IGCAxis2DInput XyAxes { get; } } interface IGCLinearInput { } @@ -2895,6 +3066,11 @@ interface GCLinearInput { [Abstract] [Export ("lastValueLatency")] double LastValueLatency { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } } interface IGCPhysicalInputElement { } @@ -2935,6 +3111,11 @@ interface GCPressedStateInput { [Abstract] [Export ("lastPressedStateLatency")] double LastPressedStateLatency { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } } interface IGCRelativeInput { } @@ -2961,9 +3142,14 @@ interface GCRelativeInput { [Abstract] [Export ("lastDeltaLatency")] double LastDeltaLatency { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 4)] + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } } - interface IGCSwitchElement { } + interface IGCSwitchElement : IGCPhysicalInputElement { } [Mac (13, 0), iOS (16, 0), MacCatalyst (16, 0), TV (16, 0)] [Protocol] @@ -3005,6 +3191,11 @@ interface GCSwitchPositionInput { [Abstract] [Export ("lastPositionLatency")] double LastPositionLatency { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } } interface IGCTouchedStateInput { } @@ -3027,6 +3218,11 @@ interface GCTouchedStateInput { [Abstract] [Export ("lastTouchedStateLatency")] double LastTouchedStateLatency { get; } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } } [NoiOS, Mac (13, 0), NoTV, MacCatalyst (16, 0)] @@ -3047,7 +3243,13 @@ interface GCControllerUserCustomizations { NSString DidChangeNotification { get; } } - [TV (18, 0), NoMac, iOS (18, 0), MacCatalyst (18, 0)] +#if !XAMCORE_5_0 + [TV (18, 0)] +#if __TVOS__ + [Obsolete ("This enum does not exist on this platform.")] +#endif +#endif + [NoMac, iOS (18, 0), MacCatalyst (18, 0)] [Native] enum GCUIEventTypes : ulong { None = 0U, @@ -3093,4 +3295,101 @@ interface UISceneConnectionOptions_GameController { [return: NullAllowed] GCGameControllerActivationContext GetGameControllerActivationContext (); } + + delegate void GCAxis2DInputValueDidChangeCallback (IGCPhysicalInputElement element, IGCAxis2DInput input, GCPoint2 point); + + [TV (17, 4), Mac (14, 3), iOS (17, 4), MacCatalyst (17, 4)] + [Protocol (BackwardsCompatibleCodeGeneration = false)] + interface GCAxis2DInput { + [Abstract] + [NullAllowed, Export ("valueDidChangeHandler", ArgumentSemantic.Copy)] + GCAxis2DInputValueDidChangeCallback ValueDidChangeHandler { get; set; } + + [Abstract] + [Export ("value")] + GCPoint2 Value { get; } + + [Abstract] + [Export ("analog")] + bool Analog { [Bind ("isAnalog")] get; } + + [Abstract] + [Export ("canWrap")] + bool CanWrap { get; } + + [Abstract] + [Export ("lastValueTimestamp")] + double LastValueTimestamp { get; } + + [Abstract] + [Export ("lastValueLatency")] + double LastValueLatency { get; } + + [Abstract] + [Export ("sources", ArgumentSemantic.Copy)] + NSSet Sources { get; } + } + + interface IGCAxis2DInput { } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [Protocol (BackwardsCompatibleCodeGeneration = false)] + interface GCPhysicalInputSource { + [Abstract] + [Export ("elementAliases", ArgumentSemantic.Copy)] + NSSet ElementAliases { get; } + + [Abstract] + [NullAllowed, Export ("elementLocalizedName")] + string ElementLocalizedName { get; } + + [Abstract] + [NullAllowed, Export ("sfSymbolsName")] + string SfSymbolsName { get; } + + [Abstract] + [Export ("direction")] + GCPhysicalInputSourceDirection Direction { get; } + } + + interface IGCPhysicalInputSource { } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [BaseType (typeof (GCControllerInputState))] + [DisableDefaultCtor] + interface GCControllerLiveInput : GCDevicePhysicalInput { + [NullAllowed, Export ("unmappedInput")] + GCControllerLiveInput UnmappedInput { get; } + + // 'new' because this is also implemented in GCDevicePhysicalInput, but with a less defined property type (IGCDevicePhysicalInputState) + [Export ("capture")] + new GCControllerInputState Capture { get; } + + [NullAllowed, Export ("nextInputState")] + // The property type is both GCControllerInputState + implements the GCDevicePhysicalInputStateDiff protocol, + // which can't be expressed in C#. Choosing to bind as GCControllerInputState. + // 'new' because this is also implemented in GCDevicePhysicalInput, but with a less defined property type (NSObject) + new GCControllerInputState NextInputState { get; } + } + + [TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)] + [BaseType (typeof (NSObject))] + [DisableDefaultCtor] + interface GCControllerInputState : GCDevicePhysicalInputState { + } +} + +namespace Foundation { + using GameController; + + partial interface NSValue { + [TV (17, 4), Mac (14, 3), iOS (17, 4), MacCatalyst (17, 4)] + [Static] + [Export ("valueWithGCPoint2:")] + NSValue FromGCPoint2 (GCPoint2 point); + + [TV (17, 4), Mac (14, 3), iOS (17, 4), MacCatalyst (17, 4)] + [Export ("GCPoint2Value")] + GCPoint2 GCPoint2Value { get; } + } } diff --git a/tests/cecil-tests/Documentation.KnownFailures.txt b/tests/cecil-tests/Documentation.KnownFailures.txt index 2ab521745518..84205f276b84 100644 --- a/tests/cecil-tests/Documentation.KnownFailures.txt +++ b/tests/cecil-tests/Documentation.KnownFailures.txt @@ -2843,14 +2843,52 @@ F:GameController.GCDualSenseAdaptiveTriggerStatus.WeaponFired F:GameController.GCDualSenseAdaptiveTriggerStatus.WeaponFiring F:GameController.GCDualSenseAdaptiveTriggerStatus.WeaponReady F:GameController.GCExtendedGamepadSnapshotData.SupportsClickableThumbsticks +F:GameController.GCInputAxisName.SteeringWheel +F:GameController.GCInputButtonName.ButtonA +F:GameController.GCInputButtonName.ButtonB +F:GameController.GCInputButtonName.ButtonHome +F:GameController.GCInputButtonName.ButtonMenu +F:GameController.GCInputButtonName.ButtonOptions +F:GameController.GCInputButtonName.ButtonShare +F:GameController.GCInputButtonName.ButtonX +F:GameController.GCInputButtonName.ButtonY +F:GameController.GCInputButtonName.DualShockTouchpadButton +F:GameController.GCInputButtonName.LeftBumper +F:GameController.GCInputButtonName.LeftPaddle +F:GameController.GCInputButtonName.LeftShoulder +F:GameController.GCInputButtonName.LeftThumbstickButton +F:GameController.GCInputButtonName.LeftTrigger +F:GameController.GCInputButtonName.PaddleFour +F:GameController.GCInputButtonName.PaddleOne +F:GameController.GCInputButtonName.PaddleThree +F:GameController.GCInputButtonName.PaddleTwo +F:GameController.GCInputButtonName.PedalAccelerator +F:GameController.GCInputButtonName.PedalBrake +F:GameController.GCInputButtonName.PedalClutch +F:GameController.GCInputButtonName.RightBumper +F:GameController.GCInputButtonName.RightPaddle +F:GameController.GCInputButtonName.RightShoulder +F:GameController.GCInputButtonName.RightThumbstickButton +F:GameController.GCInputButtonName.RightTrigger F:GameController.GCInputDirectional.CardinalDpad F:GameController.GCInputDirectional.CenterButton F:GameController.GCInputDirectional.Dpad F:GameController.GCInputDirectional.TouchSurfaceButton +F:GameController.GCInputDirectionPadName.DirectionPad +F:GameController.GCInputDirectionPadName.DualShockTouchpadOne +F:GameController.GCInputDirectionPadName.DualShockTouchpadTwo +F:GameController.GCInputDirectionPadName.LeftThumbstick +F:GameController.GCInputDirectionPadName.RightThumbstick +F:GameController.GCInputElementName.Shifter F:GameController.GCInputMicroGamepad.ButtonA F:GameController.GCInputMicroGamepad.ButtonMenu F:GameController.GCInputMicroGamepad.ButtonX F:GameController.GCInputMicroGamepad.Dpad +F:GameController.GCPhysicalInputSourceDirection.Down +F:GameController.GCPhysicalInputSourceDirection.Left +F:GameController.GCPhysicalInputSourceDirection.NotApplicable +F:GameController.GCPhysicalInputSourceDirection.Right +F:GameController.GCPhysicalInputSourceDirection.Up F:GameController.GCQuaternion.W F:GameController.GCQuaternion.X F:GameController.GCQuaternion.Y @@ -10883,6 +10921,7 @@ M:Foundation.NSUserNotificationCenter.Dispose(System.Boolean) M:Foundation.NSUserNotificationCenter.remove_DidActivateNotification(System.EventHandler{Foundation.UNCDidActivateNotificationEventArgs}) M:Foundation.NSUserNotificationCenter.remove_DidDeliverNotification(System.EventHandler{Foundation.UNCDidDeliverNotificationEventArgs}) M:Foundation.NSValue.FromCMVideoDimensions(CoreMedia.CMVideoDimensions) +M:Foundation.NSValue.FromGCPoint2(GameController.GCPoint2) M:Foundation.NSXpcConnection.CreateRemoteObjectProxy``1 M:Foundation.NSXpcConnection.CreateRemoteObjectProxy``1(System.Action{Foundation.NSError}) M:Foundation.NSXpcConnection.CreateSynchronousRemoteObjectProxy``1(System.Action{Foundation.NSError}) @@ -10900,6 +10939,10 @@ M:GameController.GCController.GetExtendedGamepadController M:GameController.GCController.GetMicroGamepadController M:GameController.GCControllerDirectionPad.SetValue(System.Single,System.Single) M:GameController.GCControllerElement.Dispose(System.Boolean) +M:GameController.GCControllerInputState.Dispose(System.Boolean) +M:GameController.GCControllerInputState.GetObject(System.String) +M:GameController.GCControllerLiveInput.Dispose(System.Boolean) +M:GameController.GCControllerLiveInput.GetObject(System.String) M:GameController.GCControllerTouchpad.SetValue(System.Single,System.Single,System.Boolean,System.Single) M:GameController.GCDeviceHaptics.CreateEngine(System.String) M:GameController.GCDualSenseAdaptiveTrigger.SetModeFeedback(GameController.GCDualSenseAdaptiveTriggerPositionalResistiveStrengths) @@ -10926,6 +10969,8 @@ M:GameController.GCMotion.SetGravity(GameController.GCAcceleration) M:GameController.GCMotion.SetRotationRate(GameController.GCRotationRate) M:GameController.GCMotion.SetState(GameController.GCMotion) M:GameController.GCMotion.SetUserAcceleration(GameController.GCAcceleration) +M:GameController.GCPhysicalInputElementCollection`2.GetElement(System.String) +M:GameController.GCPhysicalInputElementCollection`2.GetObject(System.String) M:GameController.GCPhysicalInputProfile.Capture M:GameController.GCPhysicalInputProfile.Dispose(System.Boolean) M:GameController.GCPhysicalInputProfile.GetMappedElementAlias(System.String) @@ -10944,6 +10989,8 @@ M:GameController.GCVirtualController.ConnectAsync M:GameController.GCVirtualController.Create(GameController.GCVirtualControllerConfiguration) M:GameController.GCVirtualController.Disconnect M:GameController.GCVirtualController.Dispose(System.Boolean) +M:GameController.GCVirtualController.SetPosition(CoreGraphics.CGPoint,System.String) +M:GameController.GCVirtualController.SetValue(System.Runtime.InteropServices.NFloat,System.String) M:GameController.GCVirtualController.UpdateConfiguration(System.String,GameController.GCVirtualControllerElementUpdateBlock) M:GameController.IGCDevicePhysicalInputState.GetObject(System.String) M:GameController.IGCDevicePhysicalInputStateDiff.GetChange(GameController.IGCPhysicalInputElement) @@ -19853,6 +19900,7 @@ P:Foundation.NSUrlSessionTaskTransactionMetrics.Multipath P:Foundation.NSUserActivity.AppClipActivationPayload P:Foundation.NSUserActivity.TargetContentIdentifier P:Foundation.NSValue.CMVideoDimensionsValue +P:Foundation.NSValue.GCPoint2Value P:Foundation.NSXpcListener.Delegate P:Foundation.ProxyConfigurationDictionary.HttpEnable P:Foundation.ProxyConfigurationDictionary.HttpProxyHost @@ -19868,6 +19916,7 @@ P:GameController.GCColor.Red P:GameController.GCController.Battery P:GameController.GCController.Current P:GameController.GCController.Haptics +P:GameController.GCController.Input P:GameController.GCController.Light P:GameController.GCController.PhysicalInputProfile P:GameController.GCController.ProductCategory @@ -19882,6 +19931,29 @@ P:GameController.GCControllerElement.PreferredSystemGestureState P:GameController.GCControllerElement.SfSymbolsName P:GameController.GCControllerElement.UnmappedLocalizedName P:GameController.GCControllerElement.UnmappedSfSymbolsName +P:GameController.GCControllerInputState.Axes +P:GameController.GCControllerInputState.Buttons +P:GameController.GCControllerInputState.Device +P:GameController.GCControllerInputState.Dpads +P:GameController.GCControllerInputState.Elements +P:GameController.GCControllerInputState.LastEventLatency +P:GameController.GCControllerInputState.LastEventTimestamp +P:GameController.GCControllerInputState.Switches +P:GameController.GCControllerLiveInput.Axes +P:GameController.GCControllerLiveInput.Buttons +P:GameController.GCControllerLiveInput.Capture +P:GameController.GCControllerLiveInput.Device +P:GameController.GCControllerLiveInput.Dpads +P:GameController.GCControllerLiveInput.Elements +P:GameController.GCControllerLiveInput.ElementValueDidChangeHandler +P:GameController.GCControllerLiveInput.InputStateAvailableHandler +P:GameController.GCControllerLiveInput.InputStateQueueDepth +P:GameController.GCControllerLiveInput.LastEventLatency +P:GameController.GCControllerLiveInput.LastEventTimestamp +P:GameController.GCControllerLiveInput.NextInputState +P:GameController.GCControllerLiveInput.Queue +P:GameController.GCControllerLiveInput.Switches +P:GameController.GCControllerLiveInput.UnmappedInput P:GameController.GCControllerTouchpad.Button P:GameController.GCControllerTouchpad.ReportsAbsoluteTouchSurfaceValues P:GameController.GCControllerTouchpad.TouchDown @@ -19942,6 +20014,8 @@ P:GameController.GCMouseInput.MiddleButton P:GameController.GCMouseInput.MouseMovedHandler P:GameController.GCMouseInput.RightButton P:GameController.GCMouseInput.Scroll +P:GameController.GCPhysicalInputElementCollection`2.Count +P:GameController.GCPhysicalInputElementCollection`2.ElementEnumerator P:GameController.GCPhysicalInputProfile.AllAxes P:GameController.GCPhysicalInputProfile.AllButtons P:GameController.GCPhysicalInputProfile.AllDpads @@ -19965,23 +20039,34 @@ P:GameController.GCRacingWheel.ProductCategory P:GameController.GCRacingWheel.Snapshot P:GameController.GCRacingWheel.VendorName P:GameController.GCRacingWheel.WheelInput +P:GameController.GCRacingWheelInput.Axes +P:GameController.GCRacingWheelInput.Buttons P:GameController.GCRacingWheelInput.Capture P:GameController.GCRacingWheelInput.Device +P:GameController.GCRacingWheelInput.Dpads +P:GameController.GCRacingWheelInput.Elements P:GameController.GCRacingWheelInput.ElementValueDidChangeHandler P:GameController.GCRacingWheelInput.InputStateAvailableHandler P:GameController.GCRacingWheelInput.InputStateQueueDepth P:GameController.GCRacingWheelInput.LastEventLatency P:GameController.GCRacingWheelInput.LastEventTimestamp P:GameController.GCRacingWheelInput.NextInputState +P:GameController.GCRacingWheelInput.Queue +P:GameController.GCRacingWheelInput.Switches P:GameController.GCRacingWheelInput.WheelInputCapture P:GameController.GCRacingWheelInput.WheelInputNextInputState P:GameController.GCRacingWheelInputState.AcceleratorPedal +P:GameController.GCRacingWheelInputState.Axes P:GameController.GCRacingWheelInputState.BrakePedal +P:GameController.GCRacingWheelInputState.Buttons P:GameController.GCRacingWheelInputState.ClutchPedal P:GameController.GCRacingWheelInputState.Device +P:GameController.GCRacingWheelInputState.Dpads +P:GameController.GCRacingWheelInputState.Elements P:GameController.GCRacingWheelInputState.LastEventLatency P:GameController.GCRacingWheelInputState.LastEventTimestamp P:GameController.GCRacingWheelInputState.Shifter +P:GameController.GCRacingWheelInputState.Switches P:GameController.GCRacingWheelInputState.Wheel P:GameController.GCSteeringWheelElement.AbsoluteInput P:GameController.GCSteeringWheelElement.Aliases @@ -20000,12 +20085,20 @@ P:GameController.GCXboxGamepad.PaddleButton1 P:GameController.GCXboxGamepad.PaddleButton2 P:GameController.GCXboxGamepad.PaddleButton3 P:GameController.GCXboxGamepad.PaddleButton4 +P:GameController.IGCAxis2DInput.Analog +P:GameController.IGCAxis2DInput.CanWrap +P:GameController.IGCAxis2DInput.LastValueLatency +P:GameController.IGCAxis2DInput.LastValueTimestamp +P:GameController.IGCAxis2DInput.Sources +P:GameController.IGCAxis2DInput.Value +P:GameController.IGCAxis2DInput.ValueDidChangeHandler P:GameController.IGCAxisElement.AbsoluteInput P:GameController.IGCAxisElement.RelativeInput P:GameController.IGCAxisInput.Analog P:GameController.IGCAxisInput.CanWrap P:GameController.IGCAxisInput.LastValueLatency P:GameController.IGCAxisInput.LastValueTimestamp +P:GameController.IGCAxisInput.Sources P:GameController.IGCAxisInput.Value P:GameController.IGCAxisInput.ValueDidChangeHandler P:GameController.IGCButtonElement.PressedInput @@ -20020,34 +20113,48 @@ P:GameController.IGCDevicePhysicalInput.ElementValueDidChangeHandler P:GameController.IGCDevicePhysicalInput.InputStateAvailableHandler P:GameController.IGCDevicePhysicalInput.InputStateQueueDepth P:GameController.IGCDevicePhysicalInput.NextInputState +P:GameController.IGCDevicePhysicalInput.Queue +P:GameController.IGCDevicePhysicalInputState.Axes +P:GameController.IGCDevicePhysicalInputState.Buttons P:GameController.IGCDevicePhysicalInputState.Device +P:GameController.IGCDevicePhysicalInputState.Dpads +P:GameController.IGCDevicePhysicalInputState.Elements P:GameController.IGCDevicePhysicalInputState.LastEventLatency P:GameController.IGCDevicePhysicalInputState.LastEventTimestamp +P:GameController.IGCDevicePhysicalInputState.Switches P:GameController.IGCDevicePhysicalInputStateDiff.ChangedElements P:GameController.IGCDirectionPadElement.Down P:GameController.IGCDirectionPadElement.Left P:GameController.IGCDirectionPadElement.Right P:GameController.IGCDirectionPadElement.Up P:GameController.IGCDirectionPadElement.XAxis +P:GameController.IGCDirectionPadElement.XyAxes P:GameController.IGCDirectionPadElement.YAxis P:GameController.IGCLinearInput.Analog P:GameController.IGCLinearInput.CanWrap P:GameController.IGCLinearInput.LastValueLatency P:GameController.IGCLinearInput.LastValueTimestamp +P:GameController.IGCLinearInput.Sources P:GameController.IGCLinearInput.Value P:GameController.IGCLinearInput.ValueDidChangeHandler P:GameController.IGCPhysicalInputElement.Aliases P:GameController.IGCPhysicalInputElement.LocalizedName P:GameController.IGCPhysicalInputElement.SfSymbolsName +P:GameController.IGCPhysicalInputSource.Direction +P:GameController.IGCPhysicalInputSource.ElementAliases +P:GameController.IGCPhysicalInputSource.ElementLocalizedName +P:GameController.IGCPhysicalInputSource.SfSymbolsName P:GameController.IGCPressedStateInput.LastPressedStateLatency P:GameController.IGCPressedStateInput.LastPressedStateTimestamp P:GameController.IGCPressedStateInput.Pressed P:GameController.IGCPressedStateInput.PressedDidChangeHandler +P:GameController.IGCPressedStateInput.Sources P:GameController.IGCRelativeInput.Analog P:GameController.IGCRelativeInput.Delta P:GameController.IGCRelativeInput.DeltaDidChangeHandler P:GameController.IGCRelativeInput.LastDeltaLatency P:GameController.IGCRelativeInput.LastDeltaTimestamp +P:GameController.IGCRelativeInput.Sources P:GameController.IGCSwitchElement.PositionInput P:GameController.IGCSwitchPositionInput.CanWrap P:GameController.IGCSwitchPositionInput.LastPositionLatency @@ -20056,8 +20163,10 @@ P:GameController.IGCSwitchPositionInput.Position P:GameController.IGCSwitchPositionInput.PositionDidChangeHandler P:GameController.IGCSwitchPositionInput.PositionRange P:GameController.IGCSwitchPositionInput.Sequential +P:GameController.IGCSwitchPositionInput.Sources P:GameController.IGCTouchedStateInput.LastTouchedStateLatency P:GameController.IGCTouchedStateInput.LastTouchedStateTimestamp +P:GameController.IGCTouchedStateInput.Sources P:GameController.IGCTouchedStateInput.Touched P:GameController.IGCTouchedStateInput.TouchedDidChangeHandler P:GameKit.GKAccessPoint.Active @@ -26140,8 +26249,11 @@ T:Foundation.RegisterObjectRepresentationLoadHandler T:Foundation.UNCShouldPresentNotification T:GameController.ElementValueDidChangeHandler T:GameController.GCAcceleration +T:GameController.GCAxis2DInputValueDidChangeCallback T:GameController.GCColor T:GameController.GCControllerButtonTouchedChanged +T:GameController.GCControllerInputState +T:GameController.GCControllerLiveInput T:GameController.GCControllerTouchpad T:GameController.GCControllerTouchpadHandler T:GameController.GCControllerUserCustomizations @@ -26166,7 +26278,11 @@ T:GameController.GCGameControllerSceneDelegate T:GameController.GCGearShifterElement T:GameController.GCHapticsLocality T:GameController.GCInput +T:GameController.GCInputAxisName +T:GameController.GCInputButtonName T:GameController.GCInputDirectional +T:GameController.GCInputDirectionPadName +T:GameController.GCInputElementName T:GameController.GCInputMicroGamepad T:GameController.GCInputXbox T:GameController.GCKey @@ -26178,7 +26294,9 @@ T:GameController.GCMicroGamepadSnapshotDataVersion T:GameController.GCMouse T:GameController.GCMouseInput T:GameController.GCMouseMoved +T:GameController.GCPhysicalInputElementCollection`2 T:GameController.GCPhysicalInputProfile +T:GameController.GCPhysicalInputSourceDirection T:GameController.GCProductCategory T:GameController.GCQuaternion T:GameController.GCRacingWheel @@ -26194,6 +26312,7 @@ T:GameController.GCVirtualControllerConfiguration T:GameController.GCVirtualControllerElementConfiguration T:GameController.GCVirtualControllerElementUpdateBlock T:GameController.GCXboxGamepad +T:GameController.IGCAxis2DInput T:GameController.IGCAxisElement T:GameController.IGCAxisInput T:GameController.IGCButtonElement @@ -26205,6 +26324,7 @@ T:GameController.IGCDirectionPadElement T:GameController.IGCGameControllerSceneDelegate T:GameController.IGCLinearInput T:GameController.IGCPhysicalInputElement +T:GameController.IGCPhysicalInputSource T:GameController.IGCPressedStateInput T:GameController.IGCRelativeInput T:GameController.IGCSwitchElement diff --git a/tests/monotouch-test/GameController/GCControllerTest.cs b/tests/monotouch-test/GameController/GCControllerTest.cs new file mode 100644 index 000000000000..ab7d3d68e6d4 --- /dev/null +++ b/tests/monotouch-test/GameController/GCControllerTest.cs @@ -0,0 +1,24 @@ +using System; + +using Foundation; +using GameController; + +using NUnit.Framework; + +namespace MonoTouchFixtures.GameController { + [TestFixture] + [Preserve (AllMembers = true)] + public class GCControllerTest { + [Test] + public void TheTest () + { + var controllers = GCController.Controllers; + Assert.That (controllers, Is.Not.Null, $"Null"); + if (controllers.Length == 0) + Assert.Ignore ("No controllers!"); + for (var i = 0; i < controllers.Length; i++) { + Assert.That (controllers [i], Is.Not.Null, $"#{i} NotNull"); + } + } + } +} diff --git a/tests/monotouch-test/GameController/GCInputTest.cs b/tests/monotouch-test/GameController/GCInputTest.cs new file mode 100644 index 000000000000..42691e574e3d --- /dev/null +++ b/tests/monotouch-test/GameController/GCInputTest.cs @@ -0,0 +1,31 @@ +using System; + +using Foundation; +using GameController; + +using NUnit.Framework; + +namespace MonoTouchFixtures.GameController { + [TestFixture] + [Preserve (AllMembers = true)] + public class GCInputTest { + [Test] + public void ButtonNames () + { + Assert.Multiple (() => { + if (TestRuntime.CheckXcodeVersion (15, 3)) { + AssertButtonName (GCInput.GetBackLeftButtonName (0), "Back Left Button 0", "BackLeftButtonName"); + AssertButtonName (GCInput.GetBackRightButtonName (0), "Back Right Button 0", "BackRightButtonName"); + } + if (TestRuntime.CheckXcodeVersion (15, 0)) + AssertButtonName (GCInput.GetArcadeButtonName (0, 0), "Arcade Button 0, 0", "ArcadeButtonName"); + }); + } + + void AssertButtonName (NSString? name, string expected, string message) + { + Assert.That (name, Is.Not.Null, $"{message}: null"); + Assert.That (name.ToString (), Is.EqualTo (expected), $"{message}: value"); + } + } +} diff --git a/tests/monotouch-test/GameController/GCPoint2Test.cs b/tests/monotouch-test/GameController/GCPoint2Test.cs new file mode 100644 index 000000000000..22bbb730f0b7 --- /dev/null +++ b/tests/monotouch-test/GameController/GCPoint2Test.cs @@ -0,0 +1,60 @@ +using System; + +using Foundation; +using GameController; + +using NUnit.Framework; + +namespace MonoTouchFixtures.GameController { + [TestFixture] + [Preserve (AllMembers = true)] + public class GCPoint2Test { + [Test] + public void TheTest () + { + Assert.Multiple (() => { + var pnt = new GCPoint2 (1, 2); + Assert.That (pnt.X, Is.EqualTo (1), "X"); + Assert.That (pnt.Y, Is.EqualTo (2), "Y"); + + pnt.X = 3; + Assert.That (pnt.X, Is.EqualTo (3), "X#2"); + Assert.That (pnt.Y, Is.EqualTo (2), "Y#2"); + + pnt.Y = 4; + Assert.That (pnt.X, Is.EqualTo (3), "X#3"); + Assert.That (pnt.Y, Is.EqualTo (4), "Y#3"); + + Assert.That (GCPoint2.Zero.X, Is.EqualTo (0), "Z.X"); + Assert.That (GCPoint2.Zero.Y, Is.EqualTo (0), "Z.Y"); + + Assert.That (pnt == GCPoint2.Zero, Is.EqualTo (false), "== A"); + Assert.That (pnt != GCPoint2.Zero, Is.EqualTo (true), "!= A"); + + var pnt2 = new GCPoint2 (3, 4); + Assert.That (pnt == pnt2, Is.EqualTo (true), "== B"); + Assert.That (pnt != pnt2, Is.EqualTo (false), "!= B"); + + Assert.That (pnt.IsEmpty, Is.EqualTo (false), "IsEmpty A"); + Assert.That (GCPoint2.Zero.IsEmpty, Is.EqualTo (true), "IsEmpty B"); + + var pnt3 = new GCPoint2 (pnt2); + Assert.That (pnt3.X, Is.EqualTo (3), "X#4"); + Assert.That (pnt3.Y, Is.EqualTo (4), "Y#4"); + + Assert.That (pnt.Equals ((object) pnt3), Is.EqualTo (true), "Equals A"); + Assert.That (pnt.Equals ((object) GCPoint2.Zero), Is.EqualTo (false), "Equals B"); + + Assert.That (pnt.Equals (pnt3), Is.EqualTo (true), "Equals C"); + Assert.That (pnt.Equals (GCPoint2.Zero), Is.EqualTo (false), "Equals D"); + + pnt.Deconstruct (out var x, out var y); + Assert.That (x, Is.EqualTo ((nfloat) 3), "X#5"); + Assert.That (y, Is.EqualTo ((nfloat) 4), "Y#5"); + + Assert.AreEqual (pnt.ToString (), "{3, 4}", "ToString A"); + Assert.AreEqual (GCPoint2.Zero.ToString (), "{0, 0}", "ToString B"); + }); + } + } +} diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-GameController.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-GameController.todo deleted file mode 100644 index a1d4195bae7e..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-GameController.todo +++ /dev/null @@ -1,47 +0,0 @@ -!missing-enum! GCPhysicalInputSourceDirection not bound -!missing-field! GCInputLeftBumper not bound -!missing-field! GCInputRightBumper not bound -!missing-field! GCPoint2Zero not bound -!missing-field! GCProductCategoryArcadeStick not bound -!missing-pinvoke! GCInputArcadeButtonName is not bound -!missing-pinvoke! GCInputBackLeftButton is not bound -!missing-pinvoke! GCInputBackRightButton is not bound -!missing-pinvoke! NSStringFromGCPoint2 is not bound -!missing-protocol! GCAxis2DInput not bound -!missing-protocol! GCAxisElementName not bound -!missing-protocol! GCButtonElementName not bound -!missing-protocol! GCDirectionPadElementName not bound -!missing-protocol! GCPhysicalInputElementName not bound -!missing-protocol! GCPhysicalInputSource not bound -!missing-protocol! GCSwitchElementName not bound -!missing-protocol-member! GCAxisInput::sources not found -!missing-protocol-member! GCDevicePhysicalInput::queue not found -!missing-protocol-member! GCDevicePhysicalInput::setQueue: not found -!missing-protocol-member! GCDevicePhysicalInputState::axes not found -!missing-protocol-member! GCDevicePhysicalInputState::buttons not found -!missing-protocol-member! GCDevicePhysicalInputState::dpads not found -!missing-protocol-member! GCDevicePhysicalInputState::elements not found -!missing-protocol-member! GCDevicePhysicalInputState::switches not found -!missing-protocol-member! GCDirectionPadElement::xyAxes not found -!missing-protocol-member! GCLinearInput::sources not found -!missing-protocol-member! GCPressedStateInput::sources not found -!missing-protocol-member! GCRelativeInput::sources not found -!missing-protocol-member! GCSwitchPositionInput::sources not found -!missing-protocol-member! GCTouchedStateInput::sources not found -!missing-selector! +NSValue::valueWithGCPoint2: not bound -!missing-selector! GCController::input not bound -!missing-selector! GCControllerLiveInput::capture not bound -!missing-selector! GCControllerLiveInput::nextInputState not bound -!missing-selector! GCControllerLiveInput::unmappedInput not bound -!missing-selector! GCPhysicalInputElementCollection::count not bound -!missing-selector! GCPhysicalInputElementCollection::elementEnumerator not bound -!missing-selector! GCPhysicalInputElementCollection::elementForAlias: not bound -!missing-selector! GCPhysicalInputElementCollection::objectForKeyedSubscript: not bound -!missing-selector! GCVirtualController::setPosition:forDirectionPadElement: not bound -!missing-selector! GCVirtualController::setValue:forButtonElement: not bound -!missing-selector! NSValue::GCPoint2Value not bound -!missing-type! GCControllerInputState not bound -!missing-type! GCControllerLiveInput not bound -!missing-type! GCPhysicalInputElementCollection not bound -!missing-null-allowed! 'GameController.GCController GameController.GCExtendedGamepad::get_Controller()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'GameController.GCController GameController.GCMicroGamepad::get_Controller()' is missing an [NullAllowed] on return type diff --git a/tests/xtro-sharpie/api-annotations-dotnet/common-GameController.ignore b/tests/xtro-sharpie/api-annotations-dotnet/common-GameController.ignore index e38952468a2b..8fe538dee624 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/common-GameController.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/common-GameController.ignore @@ -1,7 +1,12 @@ -# There are issues with the Generic Types listed here: https://github.com/dotnet/macios/issues/15725 +# no generator support for FastEnumeration +!missing-protocol-conformance! GCPhysicalInputElementCollection should conform to NSFastEnumeration -# After GCPhysicalInputElementCollection is fixed, we can uncomment the below -# !missing-protocol-conformance! GCPhysicalInputElementCollection should conform to NSFastEnumeration +# Replicated in managed code, no need to bind +!missing-field! GCPoint2Zero not bound -# Ignore these protocols since they are marked with 'objc_non_runtime_protocol' -# and are being used as NSStrings +# These are bound as enums +!missing-protocol! GCAxisElementName not bound +!missing-protocol! GCButtonElementName not bound +!missing-protocol! GCDirectionPadElementName not bound +!missing-protocol! GCPhysicalInputElementName not bound +!missing-protocol! GCSwitchElementName not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-GameController.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-GameController.todo deleted file mode 100644 index 44de8ba3e8e0..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-GameController.todo +++ /dev/null @@ -1,47 +0,0 @@ -!missing-enum! GCPhysicalInputSourceDirection not bound -!missing-field! GCProductCategoryArcadeStick not bound -!missing-pinvoke! GCInputArcadeButtonName is not bound -!missing-protocol! GCAxisElementName not bound -!missing-protocol! GCButtonElementName not bound -!missing-protocol! GCDirectionPadElementName not bound -!missing-protocol! GCPhysicalInputElementName not bound -!missing-protocol! GCPhysicalInputSource not bound -!missing-protocol! GCSwitchElementName not bound -!missing-protocol-member! GCAxisInput::sources not found -!missing-protocol-member! GCDevicePhysicalInput::queue not found -!missing-protocol-member! GCDevicePhysicalInput::setQueue: not found -!missing-protocol-member! GCDevicePhysicalInputState::axes not found -!missing-protocol-member! GCDevicePhysicalInputState::buttons not found -!missing-protocol-member! GCDevicePhysicalInputState::dpads not found -!missing-protocol-member! GCDevicePhysicalInputState::elements not found -!missing-protocol-member! GCDevicePhysicalInputState::switches not found -!missing-protocol-member! GCLinearInput::sources not found -!missing-protocol-member! GCPressedStateInput::sources not found -!missing-protocol-member! GCRelativeInput::sources not found -!missing-protocol-member! GCSwitchPositionInput::sources not found -!missing-protocol-member! GCTouchedStateInput::sources not found -!missing-selector! GCController::input not bound -!missing-selector! GCControllerLiveInput::capture not bound -!missing-selector! GCControllerLiveInput::nextInputState not bound -!missing-selector! GCControllerLiveInput::unmappedInput not bound -!missing-selector! GCPhysicalInputElementCollection::count not bound -!missing-selector! GCPhysicalInputElementCollection::elementEnumerator not bound -!missing-selector! GCPhysicalInputElementCollection::elementForAlias: not bound -!missing-selector! GCPhysicalInputElementCollection::objectForKeyedSubscript: not bound -!missing-selector! GCVirtualController::setPosition:forDirectionPadElement: not bound -!missing-selector! GCVirtualController::setValue:forButtonElement: not bound -!missing-type! GCControllerInputState not bound -!missing-type! GCControllerLiveInput not bound -!missing-type! GCPhysicalInputElementCollection not bound -!missing-field! GCInputLeftBumper not bound -!missing-field! GCInputRightBumper not bound -!missing-field! GCPoint2Zero not bound -!missing-pinvoke! GCInputBackLeftButton is not bound -!missing-pinvoke! GCInputBackRightButton is not bound -!missing-pinvoke! NSStringFromGCPoint2 is not bound -!missing-protocol! GCAxis2DInput not bound -!missing-protocol-member! GCDirectionPadElement::xyAxes not found -!missing-selector! +NSValue::valueWithGCPoint2: not bound -!missing-selector! NSValue::GCPoint2Value not bound -!missing-null-allowed! 'GameController.GCController GameController.GCExtendedGamepad::get_Controller()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'GameController.GCController GameController.GCMicroGamepad::get_Controller()' is missing an [NullAllowed] on return type diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.ignore b/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.ignore index b8fd6d44cc30..f3e85b19f5e8 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.ignore @@ -1,3 +1,2 @@ -# Dependency on HIDDriverKit: (BOOL)supportsHIDDevice:(IOHIDDeviceRef)device - -# Dependency on CoreHaptics updates for Xcode 12 beta 3 +# This requires binding the HIDDriverKit framework, which we haven't done +!missing-selector! +GCController::supportsHIDDevice: not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.todo deleted file mode 100644 index ee07d349dfe8..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-GameController.todo +++ /dev/null @@ -1,47 +0,0 @@ -!missing-enum! GCPhysicalInputSourceDirection not bound -!missing-field! GCProductCategoryArcadeStick not bound -!missing-pinvoke! GCInputArcadeButtonName is not bound -!missing-protocol! GCAxisElementName not bound -!missing-protocol! GCButtonElementName not bound -!missing-protocol! GCDirectionPadElementName not bound -!missing-protocol! GCPhysicalInputElementName not bound -!missing-protocol! GCPhysicalInputSource not bound -!missing-protocol! GCSwitchElementName not bound -!missing-protocol-member! GCAxisInput::sources not found -!missing-protocol-member! GCDevicePhysicalInput::queue not found -!missing-protocol-member! GCDevicePhysicalInput::setQueue: not found -!missing-protocol-member! GCDevicePhysicalInputState::axes not found -!missing-protocol-member! GCDevicePhysicalInputState::buttons not found -!missing-protocol-member! GCDevicePhysicalInputState::dpads not found -!missing-protocol-member! GCDevicePhysicalInputState::elements not found -!missing-protocol-member! GCDevicePhysicalInputState::switches not found -!missing-protocol-member! GCLinearInput::sources not found -!missing-protocol-member! GCPressedStateInput::sources not found -!missing-protocol-member! GCRelativeInput::sources not found -!missing-protocol-member! GCSwitchPositionInput::sources not found -!missing-protocol-member! GCTouchedStateInput::sources not found -!missing-selector! +GCController::supportsHIDDevice: not bound -!missing-selector! GCController::input not bound -!missing-selector! GCControllerLiveInput::capture not bound -!missing-selector! GCControllerLiveInput::nextInputState not bound -!missing-selector! GCControllerLiveInput::unmappedInput not bound -!missing-selector! GCDeviceHaptics::createEngineWithLocality: not bound -!missing-selector! GCPhysicalInputElementCollection::count not bound -!missing-selector! GCPhysicalInputElementCollection::elementEnumerator not bound -!missing-selector! GCPhysicalInputElementCollection::elementForAlias: not bound -!missing-selector! GCPhysicalInputElementCollection::objectForKeyedSubscript: not bound -!missing-type! GCControllerInputState not bound -!missing-type! GCControllerLiveInput not bound -!missing-type! GCPhysicalInputElementCollection not bound -!missing-field! GCInputLeftBumper not bound -!missing-field! GCInputRightBumper not bound -!missing-field! GCPoint2Zero not bound -!missing-pinvoke! GCInputBackLeftButton is not bound -!missing-pinvoke! GCInputBackRightButton is not bound -!missing-pinvoke! NSStringFromGCPoint2 is not bound -!missing-protocol! GCAxis2DInput not bound -!missing-protocol-member! GCDirectionPadElement::xyAxes not found -!missing-selector! +NSValue::valueWithGCPoint2: not bound -!missing-selector! NSValue::GCPoint2Value not bound -!missing-null-allowed! 'GameController.GCController GameController.GCExtendedGamepad::get_Controller()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'GameController.GCController GameController.GCMicroGamepad::get_Controller()' is missing an [NullAllowed] on return type diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameController.ignore b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameController.ignore deleted file mode 100644 index 3c178e8691e0..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameController.ignore +++ /dev/null @@ -1,15 +0,0 @@ -!missing-protocol-member! GCDevicePhysicalInputState::axes not found -!missing-protocol-member! GCDevicePhysicalInputState::buttons not found -!missing-protocol-member! GCDevicePhysicalInputState::dpads not found -!missing-protocol-member! GCDevicePhysicalInputState::elements not found -!missing-protocol-member! GCDevicePhysicalInputState::switches not found -!missing-selector! GCPhysicalInputElementCollection::count not bound -!missing-selector! GCPhysicalInputElementCollection::elementEnumerator not bound -!missing-selector! GCPhysicalInputElementCollection::elementForAlias: not bound -!missing-selector! GCPhysicalInputElementCollection::objectForKeyedSubscript: not bound -!missing-type! GCPhysicalInputElementCollection not bound -!missing-protocol! GCAxisElementName not bound -!missing-protocol! GCButtonElementName not bound -!missing-protocol! GCDirectionPadElementName not bound -!missing-protocol! GCPhysicalInputElementName not bound -!missing-protocol! GCSwitchElementName not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameController.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameController.todo deleted file mode 100644 index 218b8e52cabd..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameController.todo +++ /dev/null @@ -1,31 +0,0 @@ -!missing-enum! GCPhysicalInputSourceDirection not bound -!missing-field! GCProductCategoryArcadeStick not bound -!missing-pinvoke! GCInputArcadeButtonName is not bound -!missing-protocol! GCPhysicalInputSource not bound -!missing-protocol-member! GCAxisInput::sources not found -!missing-protocol-member! GCDevicePhysicalInput::queue not found -!missing-protocol-member! GCDevicePhysicalInput::setQueue: not found -!missing-protocol-member! GCLinearInput::sources not found -!missing-protocol-member! GCPressedStateInput::sources not found -!missing-protocol-member! GCRelativeInput::sources not found -!missing-protocol-member! GCSwitchPositionInput::sources not found -!missing-protocol-member! GCTouchedStateInput::sources not found -!missing-selector! GCController::input not bound -!missing-selector! GCControllerLiveInput::capture not bound -!missing-selector! GCControllerLiveInput::nextInputState not bound -!missing-selector! GCControllerLiveInput::unmappedInput not bound -!missing-type! GCControllerInputState not bound -!missing-type! GCControllerLiveInput not bound -!missing-field! GCInputLeftBumper not bound -!missing-field! GCInputRightBumper not bound -!missing-field! GCPoint2Zero not bound -!missing-pinvoke! GCInputBackLeftButton is not bound -!missing-pinvoke! GCInputBackRightButton is not bound -!missing-pinvoke! NSStringFromGCPoint2 is not bound -!missing-protocol! GCAxis2DInput not bound -!missing-protocol-member! GCDirectionPadElement::xyAxes not found -!missing-selector! +NSValue::valueWithGCPoint2: not bound -!missing-selector! NSValue::GCPoint2Value not bound -!missing-null-allowed! 'GameController.GCController GameController.GCExtendedGamepad::get_Controller()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'GameController.GCController GameController.GCMicroGamepad::get_Controller()' is missing an [NullAllowed] on return type -!unknown-native-enum! GCUIEventTypes bound