| using System; |
| using UnityEngine.InputSystem.Controls; |
| using UnityEngine.InputSystem.Layouts; |
| using UnityEngine.InputSystem.LowLevel; |
| using UnityEngine.InputSystem.Utilities; |
|
|
| |
| |
|
|
| |
|
|
| namespace UnityEngine.InputSystem.LowLevel |
| { |
| internal struct AccelerometerState : IInputStateTypeInfo |
| { |
| public static FourCC kFormat => new FourCC('A', 'C', 'C', 'L'); |
|
|
| [InputControl(displayName = "Acceleration", processors = "CompensateDirection", noisy = true)] |
| public Vector3 acceleration; |
|
|
| public FourCC format => kFormat; |
| } |
|
|
| internal struct GyroscopeState : IInputStateTypeInfo |
| { |
| public static FourCC kFormat => new FourCC('G', 'Y', 'R', 'O'); |
|
|
| [InputControl(displayName = "Angular Velocity", processors = "CompensateDirection", noisy = true)] |
| public Vector3 angularVelocity; |
|
|
| public FourCC format => kFormat; |
| } |
|
|
| internal struct GravityState : IInputStateTypeInfo |
| { |
| public static FourCC kFormat => new FourCC('G', 'R', 'V', ' '); |
|
|
| [InputControl(displayName = "Gravity", processors = "CompensateDirection", noisy = true)] |
| public Vector3 gravity; |
|
|
| public FourCC format => kFormat; |
| } |
|
|
| internal struct AttitudeState : IInputStateTypeInfo |
| { |
| public static FourCC kFormat => new FourCC('A', 'T', 'T', 'D'); |
|
|
| [InputControl(displayName = "Attitude", processors = "CompensateRotation", noisy = true)] |
| public Quaternion attitude; |
|
|
| public FourCC format => kFormat; |
| } |
|
|
| internal struct LinearAccelerationState : IInputStateTypeInfo |
| { |
| public static FourCC kFormat => new FourCC('L', 'A', 'A', 'C'); |
|
|
| [InputControl(displayName = "Acceleration", processors = "CompensateDirection", noisy = true)] |
| public Vector3 acceleration; |
|
|
| public FourCC format => kFormat; |
| } |
| } |
|
|
| namespace UnityEngine.InputSystem |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| [InputControlLayout(isGenericTypeOfDevice = true)] |
| public class Sensor : InputDevice |
| { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public float samplingFrequency |
| { |
| get |
| { |
| var command = QuerySamplingFrequencyCommand.Create(); |
| if (ExecuteCommand(ref command) >= 0) |
| return command.frequency; |
| throw new NotSupportedException($"Device '{this}' does not support querying sampling frequency"); |
| } |
| set |
| { |
| |
| var command = SetSamplingFrequencyCommand.Create(value); |
| ExecuteCommand(ref command); |
| } |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| [InputControlLayout(stateType = typeof(AccelerometerState))] |
| public class Accelerometer : Sensor |
| { |
| public Vector3Control acceleration { get; private set; } |
|
|
| |
| |
| |
| |
| public static Accelerometer current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| acceleration = GetChildControl<Vector3Control>("acceleration"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| [InputControlLayout(stateType = typeof(GyroscopeState))] |
| public class Gyroscope : Sensor |
| { |
| public Vector3Control angularVelocity { get; private set; } |
|
|
| |
| |
| |
| |
| public static Gyroscope current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| angularVelocity = GetChildControl<Vector3Control>("angularVelocity"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| [InputControlLayout(stateType = typeof(GravityState), displayName = "Gravity")] |
| public class GravitySensor : Sensor |
| { |
| public Vector3Control gravity { get; private set; } |
|
|
| |
| |
| |
| |
| public static GravitySensor current { get; private set; } |
|
|
| |
| protected override void FinishSetup() |
| { |
| gravity = GetChildControl<Vector3Control>("gravity"); |
| base.FinishSetup(); |
| } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| [InputControlLayout(stateType = typeof(AttitudeState), displayName = "Attitude")] |
| public class AttitudeSensor : Sensor |
| { |
| public QuaternionControl attitude { get; private set; } |
|
|
| |
| |
| |
| |
| public static AttitudeSensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| attitude = GetChildControl<QuaternionControl>("attitude"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| [InputControlLayout(stateType = typeof(LinearAccelerationState), displayName = "Linear Acceleration")] |
| public class LinearAccelerationSensor : Sensor |
| { |
| public Vector3Control acceleration { get; private set; } |
|
|
| |
| |
| |
| |
| public static LinearAccelerationSensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| acceleration = GetChildControl<Vector3Control>("acceleration"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| [InputControlLayout(displayName = "Magnetic Field")] |
| public class MagneticFieldSensor : Sensor |
| { |
| |
| |
| |
| |
| |
| |
| |
| [InputControl(displayName = "Magnetic Field", noisy = true)] |
| public Vector3Control magneticField { get; private set; } |
|
|
| |
| |
| |
| |
| public static MagneticFieldSensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| magneticField = GetChildControl<Vector3Control>("magneticField"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| [InputControlLayout(displayName = "Light")] |
| public class LightSensor : Sensor |
| { |
| |
| |
| |
| [InputControl(displayName = "Light Level", noisy = true)] |
| public AxisControl lightLevel { get; private set; } |
|
|
| |
| |
| |
| |
| public static LightSensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| lightLevel = GetChildControl<AxisControl>("lightLevel"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| [InputControlLayout(displayName = "Pressure")] |
| public class PressureSensor : Sensor |
| { |
| |
| |
| |
| [InputControl(displayName = "Atmospheric Pressure", noisy = true)] |
| public AxisControl atmosphericPressure { get; private set; } |
|
|
| |
| |
| |
| |
| public static PressureSensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| atmosphericPressure = GetChildControl<AxisControl>("atmosphericPressure"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| [InputControlLayout(displayName = "Proximity")] |
| public class ProximitySensor : Sensor |
| { |
| |
| |
| |
| [InputControl(displayName = "Distance", noisy = true)] |
| public AxisControl distance { get; private set; } |
|
|
| |
| |
| |
| |
| public static ProximitySensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| distance = GetChildControl<AxisControl>("distance"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| [InputControlLayout(displayName = "Humidity")] |
| public class HumiditySensor : Sensor |
| { |
| |
| |
| |
| [InputControl(displayName = "Relative Humidity", noisy = true)] |
| public AxisControl relativeHumidity { get; private set; } |
|
|
| |
| |
| |
| |
| public static HumiditySensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| relativeHumidity = GetChildControl<AxisControl>("relativeHumidity"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| [InputControlLayout(displayName = "Ambient Temperature")] |
| public class AmbientTemperatureSensor : Sensor |
| { |
| |
| |
| |
| [InputControl(displayName = "Ambient Temperature", noisy = true)] |
| public AxisControl ambientTemperature { get; private set; } |
|
|
| |
| |
| |
| |
| public static AmbientTemperatureSensor current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| ambientTemperature = GetChildControl<AxisControl>("ambientTemperature"); |
| base.FinishSetup(); |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| [InputControlLayout(displayName = "Step Counter")] |
| public class StepCounter : Sensor |
| { |
| |
| |
| |
| [InputControl(displayName = "Step Counter", noisy = true)] |
| public IntegerControl stepCounter { get; private set; } |
|
|
| |
| |
| |
| |
| public static StepCounter current { get; private set; } |
|
|
| |
| public override void MakeCurrent() |
| { |
| base.MakeCurrent(); |
| current = this; |
| } |
|
|
| |
| protected override void OnRemoved() |
| { |
| base.OnRemoved(); |
| if (current == this) |
| current = null; |
| } |
|
|
| |
| protected override void FinishSetup() |
| { |
| stepCounter = GetChildControl<IntegerControl>("stepCounter"); |
| base.FinishSetup(); |
| } |
| } |
| } |
|
|