/************************** TAKING SNAPSHOTS ***************************/ ////////////////////////////////////////////////////////////////////////// /// @brief Take a snapshot of all Gamepad input values into a provided GCGamepadSnapShotDataV100 variable. ////////////////////////////////////////////////////////////////////////// public static bool GetGamepadSnapshot(int nController, ref GCGamepadSnapShotDataV100 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 = _GCGetGamepadSnapshotV100(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); }
/************************** TAKING SNAPSHOTS ***************************/ ////////////////////////////////////////////////////////////////////////// /// @brief Take a snapshot of all Gamepad input values into a provided GCGamepadSnapShotDataV100 variable. ////////////////////////////////////////////////////////////////////////// public static bool GetGamepadSnapshot(int nController, ref GCGamepadSnapShotDataV100 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 = _GCGetGamepadSnapshotV100(nController, handle.AddrOfPinnedObject()); handle.Free(); return( bSuccess ); } #endif // UNITY_IPHONE return(false); }
public void Nullability() { if (!TestRuntime.CheckXcodeVersion(5, 0, 1)) { Assert.Inconclusive("GameController is iOS7+ or macOS 10.9+"); } GCGamepadSnapShotDataV100 data; Assert.False(GCGamepadSnapshot.TryGetSnapshotData(null, out data), "TryGetSnapshotData"); Assert.True(data.Version == 0, "Version"); Assert.True(data.Size == 0, "Size"); data = new GCGamepadSnapShotDataV100(); Assert.True(data.Version == 0, "Version-2"); Assert.True(data.Size == 0, "Size-2"); using (var nsd = data.ToNSData()) { Assert.True(GCGamepadSnapshot.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 (!UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { Assert.Inconclusive("GameController is iOS7+"); } GCGamepadSnapShotDataV100 data; Assert.False(GCGamepadSnapshot.TryGetSnapshotData(null, out data), "TryGetSnapshotData"); Assert.True(data.Version == 0, "Version"); Assert.True(data.Size == 0, "Size"); data = new GCGamepadSnapShotDataV100(); Assert.True(data.Version == 0, "Version-2"); Assert.True(data.Size == 0, "Size-2"); using (var nsd = data.ToNSData()) { Assert.True(GCGamepadSnapshot.TryGetSnapshotData(nsd, out data), "TryGetSnapshotData-2"); Assert.True(data.Version == 0x100, "Version-3"); Assert.True(data.Size == nsd.Length, "Size-3"); } }