Example #1
0
    //////////////////////////////////////////////////////////////////////////
    /// @brief	Take a snapshot of all ExtendedGamepad input values into a provided GCExtendedGamepadSnapShotDataV100 variable.
    //////////////////////////////////////////////////////////////////////////
    public static bool GetExtendedGamepadSnapshot(int nController, ref GCExtendedGamepadSnapShotDataV100 snapshot)
    {
        bool bSuccess = false;

#if UNITY_IPHONE
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
#if DIRECTMEMORYSNAPSHOTS
            // Create a pinned GCHandle to stop the Garbage Collector moving the snapshot data during this call.
            GCHandle handle = GCHandle.Alloc(snapshot, GCHandleType.Pinned);
            bSuccess = _GCGetExtendedGamepadSnapshotV100(nController, handle.AddrOfPinnedObject());
            handle.Free();
#else // DIRECTMEMORYSNAPSHOTS
            // Set each input's value in the snapshot one-by-one
            for (int i = 0; i < (int)GCInput.Last; i++)
            {
                snapshot.SetInputValue((GCInput)i, GetInputValue(nController, (GCInput)i));
            }
            bSuccess = true;
#endif // DIRECTMEMORYSNAPSHOTS
        }
#endif // UNITY_IPHONE

        return(bSuccess);
    }
    //////////////////////////////////////////////////////////////////////////
    /// @brief	Take a snapshot of all ExtendedGamepad input values into a provided GCExtendedGamepadSnapShotDataV100 variable.
    //////////////////////////////////////////////////////////////////////////
    public static bool GetExtendedGamepadSnapshot(int nController, ref GCExtendedGamepadSnapShotDataV100 snapshot)
    {
        #if UNITY_IPHONE
        if( Application.platform == RuntimePlatform.IPhonePlayer )
        {
            // Create a pinned GCHandle to stop the Garbage Collector moving the snapshot data during this call.
            GCHandle handle = GCHandle.Alloc(snapshot, GCHandleType.Pinned);
            bool bSuccess = _GCGetExtendedGamepadSnapshotV100(nController, handle.AddrOfPinnedObject());
            handle.Free();

            return( bSuccess );
        }
        #endif // UNITY_IPHONE

        return(false);
    }
Example #3
0
        public void Nullability()
        {
            if (!UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                Assert.Inconclusive("GameController is iOS7+");
            }

            GCExtendedGamepadSnapShotDataV100 data;

            Assert.False(GCExtendedGamepadSnapshot.TryGetSnapShotData(null, out data), "TryGetSnapshotData");
            Assert.True(data.Version == 0, "Version");
            Assert.True(data.Size == 0, "Size");

            data = new GCExtendedGamepadSnapShotDataV100();
            Assert.True(data.Version == 0, "Version-2");
            Assert.True(data.Size == 0, "Size-2");

            using (var nsd = data.ToNSData()) {
                Assert.True(GCExtendedGamepadSnapshot.TryGetSnapShotData(nsd, out data), "TryGetSnapshotData-2");
                Assert.True(data.Version == 0x100, "Version-3");
                Assert.True(data.Size == nsd.Length, "Size-3");
            }
        }
        public void Nullability()
        {
            if (!TestRuntime.CheckXcodeVersion(5, 0, 1))
            {
                Assert.Inconclusive("GameController is iOS7+ or macOS 10.9+");
            }

            GCExtendedGamepadSnapShotDataV100 data;

            Assert.False(GCExtendedGamepadSnapshot.TryGetSnapShotData(null, out data), "TryGetSnapshotData");
            Assert.True(data.Version == 0, "Version");
            Assert.True(data.Size == 0, "Size");

            data = new GCExtendedGamepadSnapShotDataV100();
            Assert.True(data.Version == 0, "Version-2");
            Assert.True(data.Size == 0, "Size-2");

            using (var nsd = data.ToNSData()) {
                Assert.True(GCExtendedGamepadSnapshot.TryGetSnapShotData(nsd, out data), "TryGetSnapshotData-2");
                Assert.True(data.Version == 0x100, "Version-3");
                Assert.True(data.Size == nsd.Length, "Size-3");
            }
        }