test
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84ba8e63f115487ca072084bbebf0e55
|
||||
timeCreated: 1517014866
|
@@ -0,0 +1,32 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Command to tell the runtime to no longer send events for the given device.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public struct DisableDeviceCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('D', 'S', 'B', 'L'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static DisableDeviceCommand Create()
|
||||
{
|
||||
return new DisableDeviceCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aad56faafe6d9d3458c93a9e43759461
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,32 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Command to re-enable a device that has been disabled with <see cref="DisableDeviceCommand"/>.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public struct EnableDeviceCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('E', 'N', 'B', 'L'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static EnableDeviceCommand Create()
|
||||
{
|
||||
return new EnableDeviceCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d76c8b08c287594c9bf5d6c70fb8699
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,44 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Device Command that enables IME Composition within the application. Primarily handled by Keyboard devices.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = InputDeviceCommand.kBaseCommandSize + sizeof(byte))]
|
||||
public unsafe struct EnableIMECompositionCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('I', 'M', 'E', 'M'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + +sizeof(uint);
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true, and if true, Input Method Editors will be used while typing.
|
||||
/// </summary>
|
||||
public bool imeEnabled
|
||||
{
|
||||
get { return m_ImeEnabled != 0; }
|
||||
}
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
byte m_ImeEnabled;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static EnableIMECompositionCommand Create(bool enabled)
|
||||
{
|
||||
return new EnableIMECompositionCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, InputDeviceCommand.kBaseCommandSize + sizeof(byte)),
|
||||
m_ImeEnabled = enabled ? byte.MaxValue : (byte)0
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e0ea5a9f932f6541962b1bf7934f7c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface implemented by all input device command structs which reports the data format identifier of the command.
|
||||
/// </summary>
|
||||
public interface IInputDeviceCommandInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The data format identifier of the device command as a <see cref="FourCC"/> code.
|
||||
/// </summary>
|
||||
FourCC typeStatic { get; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2339479d3a44fcb902e62c60f0a05af
|
||||
timeCreated: 1517015727
|
@@ -0,0 +1,58 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Device command to instruct the underlying platform to pair a user account to the targeted device.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// If successful, the platform should then send an <see cref="DeviceConfigurationEvent"/>
|
||||
/// to signal that the device configuration has been changed. In response, a <see cref="QueryUserIdCommand"/>
|
||||
/// may be sent to fetch the paired user ID from the device.
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public struct InitiateUserAccountPairingCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('P', 'A', 'I', 'R'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Justification = "Enum values mandated by native code")]
|
||||
public enum Result
|
||||
{
|
||||
/// <summary>
|
||||
/// User pairing UI has been successfully opened.
|
||||
/// </summary>
|
||||
SuccessfullyInitiated = 1,
|
||||
|
||||
/// <summary>
|
||||
/// System does not support application-invoked user pairing.
|
||||
/// </summary>
|
||||
ErrorNotSupported = (int)InputDeviceCommand.GenericFailure,
|
||||
|
||||
/// <summary>
|
||||
/// There already is a pairing operation in progress and the system does not support
|
||||
/// pairing multiple devices at the same time.
|
||||
/// </summary>
|
||||
ErrorAlreadyInProgress = -2,
|
||||
}
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static InitiateUserAccountPairingCommand Create()
|
||||
{
|
||||
return new InitiateUserAccountPairingCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b200cbcb815aa44418fe8ada8cb78696
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,91 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
using Unity.Collections;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
////REVIEW: why is this passing the command by pointer instead of by ref?
|
||||
/// <summary>
|
||||
/// Delegate used by <see cref="InputSystem.onDeviceCommand"/>.
|
||||
/// </summary>
|
||||
public unsafe delegate long? InputDeviceCommandDelegate(InputDevice device, InputDeviceCommand* command);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate for executing <see cref="InputDeviceCommand"/>s inside <see cref="InputSystem.onFindLayoutForDevice"/>.
|
||||
/// </summary>
|
||||
/// <param name="command">Command to execute.</param>
|
||||
/// <seealso cref="InputSystem.onFindLayoutForDevice"/>
|
||||
/// <seealso cref="Layouts.InputDeviceFindControlLayoutDelegate"/>
|
||||
public delegate long InputDeviceExecuteCommandDelegate(ref InputDeviceCommand command);
|
||||
|
||||
/// <summary>
|
||||
/// Data header for a command send to an <see cref="InputDevice"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Commands are essentially synchronously processed events send directly
|
||||
/// to a specific device. Their primary use is to expose device-specific
|
||||
/// functions without having to extend the C# API used to communicate
|
||||
/// between input code and backend device implementations (which may sit
|
||||
/// in native code).
|
||||
///
|
||||
/// Like input events, device commands use <see cref="FourCC"/> codes
|
||||
/// to indicate their type.
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kBaseCommandSize)]
|
||||
public struct InputDeviceCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
////TODO: Remove kBaseCommandSize
|
||||
internal const int kBaseCommandSize = 8;
|
||||
public const int BaseCommandSize = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Generic failure code for <see cref="InputDevice.ExecuteCommand{TCommand}"/> calls.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Any negative return value for an <see cref="InputDevice.ExecuteCommand{TCommand}"/> call should be considered failure.
|
||||
/// </remarks>
|
||||
public const long GenericFailure = -1;
|
||||
|
||||
public const long GenericSuccess = 1;
|
||||
|
||||
[FieldOffset(0)] public FourCC type;
|
||||
[FieldOffset(4)] public int sizeInBytes;
|
||||
|
||||
public int payloadSizeInBytes => sizeInBytes - kBaseCommandSize;
|
||||
|
||||
public unsafe void* payloadPtr
|
||||
{
|
||||
get
|
||||
{
|
||||
fixed(void* thisPtr = &this)
|
||||
{
|
||||
return ((byte*)thisPtr) + kBaseCommandSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InputDeviceCommand(FourCC type, int sizeInBytes = kBaseCommandSize)
|
||||
{
|
||||
this.type = type;
|
||||
this.sizeInBytes = sizeInBytes;
|
||||
}
|
||||
|
||||
public static unsafe NativeArray<byte> AllocateNative(FourCC type, int payloadSize)
|
||||
{
|
||||
var sizeInBytes = payloadSize + kBaseCommandSize;
|
||||
var buffer = new NativeArray<byte>(sizeInBytes, Allocator.Temp);
|
||||
|
||||
var commandPtr = (InputDeviceCommand*)NativeArrayUnsafeUtility.GetUnsafePtr(buffer);
|
||||
commandPtr->type = type;
|
||||
commandPtr->sizeInBytes = sizeInBytes;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return new FourCC(); }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2158c2dfcbb94a3092caa77d698d5010
|
||||
timeCreated: 1517014875
|
@@ -0,0 +1,34 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Queries to see if this device is able to continue to send updates and state changes when the application is not if focus.
|
||||
/// </summary>
|
||||
/// <seealso cref="InputDevice.canRunInBackground"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = InputDeviceCommand.kBaseCommandSize + sizeof(bool))]
|
||||
public struct QueryCanRunInBackground : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('Q', 'R', 'I', 'B');
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(bool);
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public bool canRunInBackground;
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static QueryCanRunInBackground Create()
|
||||
{
|
||||
return new QueryCanRunInBackground
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
canRunInBackground = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a10a64abdfd8f6340a5b6b54bf28812a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,38 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Query dimensions of a device.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is usually used to query screen dimensions from pointer devices.
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public struct QueryDimensionsCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('D', 'I', 'M', 'S'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float) * 2;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public Vector2 outDimensions;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static QueryDimensionsCommand Create()
|
||||
{
|
||||
return new QueryDimensionsCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8ce1fd8f845226439f6b4ee991c9f78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,35 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
////REVIEW: This mechanism sucks. We should have this conversion without the device having to support it through an IOCTL. A Pointer
|
||||
//// should just inherently have this conversion mechanism on its controls that operate in screen space.
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
internal struct QueryEditorWindowCoordinatesCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('E', 'W', 'P', 'S');
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float) * 2;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public Vector2 inOutCoordinates;
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static QueryEditorWindowCoordinatesCommand Create(Vector2 playerWindowCoordinates)
|
||||
{
|
||||
return new QueryEditorWindowCoordinatesCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
inOutCoordinates = playerWindowCoordinates
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // UNITY_EDITOR
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c764fcc1188a6e489f8c305ff4077a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,32 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Command to find out whether a device is currently enabled or not.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public struct QueryEnabledStateCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('Q', 'E', 'N', 'B');
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(bool);
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public bool isEnabled;
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static QueryEnabledStateCommand Create()
|
||||
{
|
||||
return new QueryEnabledStateCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e6d0cbdd012f434392878fdc293f974
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Command to query the current name of a key according to the current keyboard layout.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public unsafe struct QueryKeyNameCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('K', 'Y', 'C', 'F');
|
||||
|
||||
internal const int kMaxNameLength = 256;
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + kMaxNameLength + 4;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public int scanOrKeyCode;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize + 4)]
|
||||
public fixed byte nameBuffer[kMaxNameLength];
|
||||
|
||||
public string ReadKeyName()
|
||||
{
|
||||
fixed(QueryKeyNameCommand * thisPtr = &this)
|
||||
{
|
||||
return StringHelpers.ReadStringFromBuffer(new IntPtr(thisPtr->nameBuffer), kMaxNameLength);
|
||||
}
|
||||
}
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static QueryKeyNameCommand Create(Key key)
|
||||
{
|
||||
return new QueryKeyNameCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
scanOrKeyCode = (int)key
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e49477f346c4f3a8c9e5fcdcde317ed
|
||||
timeCreated: 1517018273
|
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Command to query the name of the current keyboard layout from a device.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = InputDeviceCommand.kBaseCommandSize + kMaxNameLength)]
|
||||
public unsafe struct QueryKeyboardLayoutCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('K', 'B', 'L', 'T'); } }
|
||||
|
||||
internal const int kMaxNameLength = 256;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public fixed byte nameBuffer[kMaxNameLength];
|
||||
|
||||
/// <summary>
|
||||
/// Read the current keyboard layout name from <see cref="nameBuffer"/>.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string ReadLayoutName()
|
||||
{
|
||||
fixed(QueryKeyboardLayoutCommand * thisPtr = &this)
|
||||
return StringHelpers.ReadStringFromBuffer(new IntPtr(thisPtr->nameBuffer), kMaxNameLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the given string to <see cref="nameBuffer"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Keyboard layout name.</param>
|
||||
public void WriteLayoutName(string name)
|
||||
{
|
||||
fixed(QueryKeyboardLayoutCommand * thisPtr = &this)
|
||||
StringHelpers.WriteStringToBuffer(name, new IntPtr(thisPtr->nameBuffer), kMaxNameLength);
|
||||
}
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static QueryKeyboardLayoutCommand Create()
|
||||
{
|
||||
return new QueryKeyboardLayoutCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, InputDeviceCommand.kBaseCommandSize + kMaxNameLength)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 620180a2562c422893989c28645cef24
|
||||
timeCreated: 1517017122
|
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Query the ID and the name of the user paired to the device the command is sent to.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This command is only supported on platforms where devices can be paired to user accounts
|
||||
/// at the platform level. Currently this is the case for Xbox and PS4. On Switch, <see
|
||||
/// cref="InitiateUserAccountPairingCommand"/> is supported but the platform does not store
|
||||
/// associations established between devices and users that way.
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public unsafe struct QueryPairedUserAccountCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('P', 'A', 'C', 'C');
|
||||
|
||||
internal const int kMaxNameLength = 256;
|
||||
internal const int kMaxIdLength = 256;
|
||||
|
||||
////REVIEW: is this too heavy to allocate on the stack?
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + 8 + kMaxNameLength * 2 + kMaxIdLength * 2;
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames", Justification = "`Result` matches other command result names")]
|
||||
[Flags]
|
||||
public enum Result : long
|
||||
{
|
||||
// Leave bit #0 unused so as to not lead to possible confusion with GenericSuccess.
|
||||
|
||||
/// <summary>
|
||||
/// The device is currently paired to a user account.
|
||||
/// </summary>
|
||||
DevicePairedToUserAccount = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// The system is currently displaying a prompt for the user to select an account to
|
||||
/// use the device with.
|
||||
/// </summary>
|
||||
UserAccountSelectionInProgress = 1 << 2,
|
||||
|
||||
/// <summary>
|
||||
/// User account selection completed.
|
||||
/// </summary>
|
||||
UserAccountSelectionComplete = 1 << 3,
|
||||
|
||||
/// <summary>
|
||||
/// The system had been displaying a prompt
|
||||
/// </summary>
|
||||
UserAccountSelectionCanceled = 1 << 4,
|
||||
}
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
/// <summary>
|
||||
/// Handle of the user account at the platform level.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that this is wide enough to store a pointer and does not necessarily need to be a plain integer.
|
||||
/// How the backend determines handles for user accounts is up to the backend.
|
||||
///
|
||||
/// Be aware that a handle is not guaranteed to be valid beyond the current application run. For stable,
|
||||
/// persistent user account handles,use <see cref="id"/>.
|
||||
/// </remarks>
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public ulong handle;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize + 8)]
|
||||
internal fixed byte nameBuffer[kMaxNameLength * 2];
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize + 8 + kMaxNameLength * 2)]
|
||||
internal fixed byte idBuffer[kMaxNameLength * 2];
|
||||
|
||||
/// <summary>
|
||||
/// Persistent ID of the user account the platform level.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This ID is guaranteed to not change between application runs, device restarts, and the user
|
||||
/// changing user names on the account.
|
||||
///
|
||||
/// Use this ID to associate persistent settings with.
|
||||
/// </remarks>
|
||||
public string id
|
||||
{
|
||||
get
|
||||
{
|
||||
fixed(byte* idBufferPtr = idBuffer)
|
||||
return StringHelpers.ReadStringFromBuffer(new IntPtr(idBufferPtr), kMaxIdLength);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException(nameof(value));
|
||||
var length = value.Length;
|
||||
if (length > kMaxIdLength)
|
||||
throw new ArgumentException($"ID '{value}' exceeds maximum supported length of {kMaxIdLength} characters", nameof(value));
|
||||
|
||||
fixed(byte* idBufferPtr = idBuffer)
|
||||
{
|
||||
StringHelpers.WriteStringToBuffer(value, new IntPtr(idBufferPtr), kMaxIdLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the user account at the platform level.
|
||||
/// </summary>
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
fixed(byte* nameBufferPtr = nameBuffer)
|
||||
return StringHelpers.ReadStringFromBuffer(new IntPtr(nameBufferPtr), kMaxNameLength);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
var length = value.Length;
|
||||
if (length > kMaxNameLength)
|
||||
throw new ArgumentException($"Name '{value}' exceeds maximum supported length of {kMaxNameLength} characters", nameof(value));
|
||||
|
||||
fixed(byte* nameBufferPtr = nameBuffer)
|
||||
{
|
||||
StringHelpers.WriteStringToBuffer(value, new IntPtr(nameBufferPtr), kMaxNameLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static QueryPairedUserAccountCommand Create()
|
||||
{
|
||||
return new QueryPairedUserAccountCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c6284fecb53e48ee832bc14c64be6fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,32 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
internal struct QuerySamplingFrequencyCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('S', 'M', 'P', 'L'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float);
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public float frequency;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static QuerySamplingFrequencyCommand Create()
|
||||
{
|
||||
return new QuerySamplingFrequencyCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1659bf437d849824999b2b9ae9e1518b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
////TODO: remove this one; superseded by QueryPairedUserAccountCommand
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
internal unsafe struct QueryUserIdCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('U', 'S', 'E', 'R'); } }
|
||||
|
||||
public const int kMaxIdLength = 256;
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + kMaxIdLength * 2;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public fixed byte idBuffer[kMaxIdLength * 2];
|
||||
|
||||
public string ReadId()
|
||||
{
|
||||
fixed(QueryUserIdCommand * thisPtr = &this)
|
||||
{
|
||||
return StringHelpers.ReadStringFromBuffer(new IntPtr(thisPtr->idBuffer), kMaxIdLength);
|
||||
}
|
||||
}
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static QueryUserIdCommand Create()
|
||||
{
|
||||
return new QueryUserIdCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c784a1510a154625903484b84c8ddaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// A command to tell the runtime to reset the device to it's default state.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This triggers an event being sent from the device that represents an empty, or untouched device.
|
||||
/// </remarks>
|
||||
/// <seealso cref="RequestSyncCommand"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = InputDeviceCommand.kBaseCommandSize)]
|
||||
public struct RequestResetCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('R', 'S', 'E', 'T');
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static RequestResetCommand Create()
|
||||
{
|
||||
return new RequestResetCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90a43988da5cf85498b40180b9040a38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// A command to tell the runtime to sync the device to it's last known state.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This triggers an event from the underlying device that represents the whole, current state.
|
||||
/// </remarks>
|
||||
/// <seealso cref="RequestResetCommand"/>
|
||||
[StructLayout(LayoutKind.Explicit, Size = InputDeviceCommand.kBaseCommandSize)]
|
||||
public struct RequestSyncCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type => new FourCC('S', 'Y', 'N', 'C');
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
public FourCC typeStatic => Type;
|
||||
|
||||
public static RequestSyncCommand Create()
|
||||
{
|
||||
return new RequestSyncCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0c637405fa4842cc92e389df8729bc8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the position for IME dialogs. This is in pixels, from the upper left corner going down and to the right.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public unsafe struct SetIMECursorPositionCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('I', 'M', 'E', 'P'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + (sizeof(float) * 2);
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
public Vector2 position
|
||||
{
|
||||
get { return m_Position; }
|
||||
}
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
Vector2 m_Position;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static SetIMECursorPositionCommand Create(Vector2 cursorPosition)
|
||||
{
|
||||
return new SetIMECursorPositionCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
m_Position = cursorPosition
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6873ac51fc9d6dc4dbb6d9dc77a5eb49
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,39 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
////REVIEW: switch this to interval-in-seconds instead of Hz?
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// For a device that is sampled periodically, set the frequency at which the device
|
||||
/// is sampled.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
public struct SetSamplingFrequencyCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('S', 'S', 'P', 'L'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float);
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public float frequency;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static SetSamplingFrequencyCommand Create(float frequency)
|
||||
{
|
||||
return new SetSamplingFrequencyCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
frequency = frequency
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3894aabfd6ab70245859fa873e1a6552
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
internal struct WarpMousePositionCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('W', 'P', 'M', 'S'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float) * 2;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public Vector2 warpPositionInPlayerDisplaySpace;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static WarpMousePositionCommand Create(Vector2 position)
|
||||
{
|
||||
return new WarpMousePositionCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
warpPositionInPlayerDisplaySpace = position
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f018dacefe574045a76769f5f355f3b1
|
||||
timeCreated: 1517107079
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 644895dd25f14937a1d11481e2338925
|
||||
timeCreated: 1506745703
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e286fc65ad3d4645b213e71b11e963e4
|
||||
timeCreated: 1516644432
|
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using UnityEngine.InputSystem.LowLevel;
|
||||
|
||||
////REVIEW: should we keep an explicit playback status? ATM calling ResumeHaptics() will re-issue last set motor speed regardless of pause state
|
||||
|
||||
namespace UnityEngine.InputSystem.Haptics
|
||||
{
|
||||
/// <summary>
|
||||
/// Common implementation of dual motor rumbling.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This struct is meant for use in devices that implement <see cref="IDualMotorRumble"/>.
|
||||
/// </remarks>
|
||||
internal struct DualMotorRumble
|
||||
{
|
||||
/// <summary>
|
||||
/// Normalized [0..1] speed of the low-frequency (usually left) motor.
|
||||
/// </summary>
|
||||
/// <value>Speed of left motor.</value>
|
||||
public float lowFrequencyMotorSpeed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Normalized [0..1] speed of the high-frequency (usually right) motor.
|
||||
/// </summary>
|
||||
/// <value>Speed of right motor.</value>
|
||||
public float highFrequencyMotorSpeed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether either of the motors is currently set to non-zero speeds.
|
||||
/// </summary>
|
||||
/// <value>True if the motors are currently turned on.</value>
|
||||
/// <remarks>
|
||||
/// Does not take pausing into account, i.e. <see cref="lowFrequencyMotorSpeed"/> and/or
|
||||
/// <see cref="highFrequencyMotorSpeed"/> may be non-zero but haptics on the device
|
||||
/// may actually be paused with <see cref="PauseHaptics"/>.
|
||||
/// </remarks>
|
||||
public bool isRumbling =>
|
||||
!Mathf.Approximately(lowFrequencyMotorSpeed, 0f)
|
||||
|| !Mathf.Approximately(highFrequencyMotorSpeed, 0f);
|
||||
|
||||
/// <summary>
|
||||
/// Reset motor speeds to zero but retain current values for <see cref="lowFrequencyMotorSpeed"/>
|
||||
/// and <see cref="highFrequencyMotorSpeed"/>.
|
||||
/// </summary>
|
||||
/// <param name="device">Device to send command to.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="device"/> is null.</exception>
|
||||
public void PauseHaptics(InputDevice device)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("device");
|
||||
|
||||
if (!isRumbling)
|
||||
return;
|
||||
|
||||
var command = DualMotorRumbleCommand.Create(0f, 0f);
|
||||
device.ExecuteCommand(ref command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resume haptics by setting motor speeds to the current values of <see cref="lowFrequencyMotorSpeed"/>
|
||||
/// and <see cref="highFrequencyMotorSpeed"/>.
|
||||
/// </summary>
|
||||
/// <param name="device">Device to send command to.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="device"/> is null.</exception>
|
||||
public void ResumeHaptics(InputDevice device)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("device");
|
||||
|
||||
if (!isRumbling)
|
||||
return;
|
||||
|
||||
SetMotorSpeeds(device, lowFrequencyMotorSpeed, highFrequencyMotorSpeed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset haptics by setting both <see cref="lowFrequencyMotorSpeed"/> and <see cref="highFrequencyMotorSpeed"/>
|
||||
/// to zero.
|
||||
/// </summary>
|
||||
/// <param name="device">Device to send command to.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="device"/> is null.</exception>
|
||||
public void ResetHaptics(InputDevice device)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("device");
|
||||
|
||||
if (!isRumbling)
|
||||
return;
|
||||
|
||||
SetMotorSpeeds(device, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the speed of the low-frequency (usually left) and high-frequency (usually right) motor
|
||||
/// on <paramref name="device"/>. Updates <see cref="lowFrequencyMotorSpeed"/> and
|
||||
/// <see cref="highFrequencyMotorSpeed"/>.
|
||||
/// </summary>
|
||||
/// <param name="device">Device to send command to.</param>
|
||||
/// <param name="lowFrequency">Speed of the low-frequency (left) motor. Normalized [0..1] value
|
||||
/// with 1 indicating maximum speed and 0 indicating the motor is turned off. Will automatically
|
||||
/// be clamped into range.</param>
|
||||
/// <param name="highFrequency">Speed of the high-frequency (right) motor. Normalized [0..1] value
|
||||
/// with 1 indicating maximum speed and 0 indicating the motor is turned off. Will automatically
|
||||
/// be clamped into range.</param>
|
||||
/// <remarks>
|
||||
/// Sends <see cref="DualMotorRumbleCommand"/> to <paramref name="device"/>.
|
||||
/// </remarks>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="device"/> is null.</exception>
|
||||
public void SetMotorSpeeds(InputDevice device, float lowFrequency, float highFrequency)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("device");
|
||||
|
||||
lowFrequencyMotorSpeed = Mathf.Clamp(lowFrequency, 0.0f, 1.0f);
|
||||
highFrequencyMotorSpeed = Mathf.Clamp(highFrequency, 0.0f, 1.0f);
|
||||
|
||||
var command = DualMotorRumbleCommand.Create(lowFrequencyMotorSpeed, highFrequencyMotorSpeed);
|
||||
device.ExecuteCommand(ref command);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4a1c749d40b4bf985d6b32d7db339bb
|
||||
timeCreated: 1517012194
|
@@ -0,0 +1,37 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
namespace UnityEngine.InputSystem.LowLevel
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = kSize)]
|
||||
internal struct DualMotorRumbleCommand : IInputDeviceCommandInfo
|
||||
{
|
||||
public static FourCC Type { get { return new FourCC('R', 'M', 'B', 'L'); } }
|
||||
|
||||
internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float) * 2;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public InputDeviceCommand baseCommand;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize)]
|
||||
public float lowFrequencyMotorSpeed;
|
||||
|
||||
[FieldOffset(InputDeviceCommand.kBaseCommandSize + 4)]
|
||||
public float highFrequencyMotorSpeed;
|
||||
|
||||
public FourCC typeStatic
|
||||
{
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static DualMotorRumbleCommand Create(float lowFrequency, float highFrequency)
|
||||
{
|
||||
return new DualMotorRumbleCommand
|
||||
{
|
||||
baseCommand = new InputDeviceCommand(Type, kSize),
|
||||
lowFrequencyMotorSpeed = lowFrequency,
|
||||
highFrequencyMotorSpeed = highFrequency
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee46ea662a1d4d2397d0b3a45baf67ef
|
||||
timeCreated: 1517015642
|
@@ -0,0 +1,30 @@
|
||||
namespace UnityEngine.InputSystem.Haptics
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple haptics interface that allows to control two motors individually.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Dual-motor control is most common on gamepads (see <see cref="Gamepad"/>) such as
|
||||
/// Xbox and PlayStation controllers.
|
||||
/// </remarks>
|
||||
public interface IDualMotorRumble : IHaptics
|
||||
{
|
||||
/// <summary>
|
||||
/// Set the motor speeds of the low-frequency (usually on the left) and high-frequency
|
||||
/// (usually on the right) motors.
|
||||
/// </summary>
|
||||
/// <param name="lowFrequency">Speed of the low-frequency (left) motor. Normalized [0..1] value
|
||||
/// with 1 indicating maximum speed and 0 indicating the motor is turned off. Will automatically
|
||||
/// be clamped into range.</param>
|
||||
/// <param name="highFrequency">Speed of the high-frequency (right) motor. Normalized [0..1] value
|
||||
/// with 1 indicating maximum speed and 0 indicating the motor is turned off. Will automatically
|
||||
/// be clamped into range.</param>
|
||||
/// <remarks>
|
||||
/// Note that hardware will put limits on the level of control you have over the motors.
|
||||
/// Rumbling the motors at maximum speed for an extended period of time may cause them to turn
|
||||
/// off for some time to prevent overheating. Also, how quickly the motors react and how often
|
||||
/// the speed can be updated will depend on the hardware and drivers.
|
||||
/// </remarks>
|
||||
void SetMotorSpeeds(float lowFrequency, float highFrequency);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6982a6ffcdbf47a6aa68fd4418622395
|
||||
timeCreated: 1516644451
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user