/// <summary> /// Get input devices. /// </summary> public static DeviceInputType GetInputDevices() { DeviceInputType inputDevices = DeviceInputType.Unknown; if (IsKeyboardAllowed()) { inputDevices = inputDevices | DeviceInputType.Keyboard; } if (IsGamePadAllowed()) { inputDevices = inputDevices | DeviceInputType.Gamepad; } if (IsMouseAllowed()) { inputDevices = inputDevices | DeviceInputType.Mouse; } if (IsTouchAllowed()) { inputDevices = inputDevices | DeviceInputType.Touch; } if (IsPenAllowed()) { inputDevices = inputDevices | DeviceInputType.Pen; } return(inputDevices); }
/// <summary> /// The constructor for a new MixedRealityInputActionMapping definition /// </summary> /// <param name="description">The description of the interaction mapping.</param> /// <param name="inputAction">The logical MixedRealityInputAction that this input performs</param> public MixedRealityInputActionMapping(string description, AxisType axisType, DeviceInputType inputType, MixedRealityInputAction inputAction) { this.description = description; this.axisType = axisType; this.inputType = inputType; this.inputAction = inputAction; }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="id">Identity for mapping</param> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param> /// <param name="inputType">The physical input device / control</param> /// <param name="keyCode">Optional KeyCode value to get input from Unity's old input system</param> public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, KeyCode keyCode) { this.id = id; this.description = description; this.axisType = axisType; this.inputType = inputType; inputAction = MixedRealityInputAction.None; this.keyCode = keyCode; axisCodeX = string.Empty; axisCodeY = string.Empty; rawData = null; boolData = false; floatData = 0f; vector2Data = Vector2.zero; positionData = Vector3.zero; rotationData = Quaternion.identity; poseData = MixedRealityPose.ZeroIdentity; changed = false; }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="id">Identity for mapping</param> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param> /// <param name="inputType">The physical input device / control</param> /// <param name="inputAction">The logical MixedRealityInputAction that this input performs</param> /// <param name="keyCode">Optional KeyCode value to get input from Unity's old input system</param> /// <param name="axisCodeX">Optional horizontal or single axis value to get axis data from Unity's old input system.</param> /// <param name="axisCodeY">Optional vertical axis value to get axis data from Unity's old input system.</param> /// <param name="invertXAxis">Optional horizontal axis invert option.</param> /// <param name="invertYAxis">Optional vertical axis invert option.</param> public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, MixedRealityInputAction inputAction, KeyCode keyCode = KeyCode.None, string axisCodeX = "", string axisCodeY = "", bool invertXAxis = false, bool invertYAxis = false) { this.id = id; this.description = description; this.axisType = axisType; this.inputType = inputType; this.inputAction = inputAction; this.keyCode = keyCode; this.axisCodeX = axisCodeX; this.axisCodeY = axisCodeY; this.invertXAxis = invertXAxis; this.invertYAxis = invertYAxis; rawData = null; boolData = false; floatData = 0f; vector2Data = Vector2.zero; positionData = Vector3.zero; rotationData = Quaternion.identity; poseData = MixedRealityPose.ZeroIdentity; changed = false; }
/// <summary> /// Gets the <seealso cref="MixedRealityInteractionMapping"/> matching the <seealso cref="DeviceInputType"/> for /// the specified controller. /// </summary> /// <param name="controller">The <seealso cref="IMixedRealityController"/> instance</param> /// <param name="inputType">The type of device input</param> /// <param name="mapping">The <seealso cref="MixedRealityInteractionMapping"/> being returned</param> /// <returns> /// True if the interaction mapping is being returned, false otherwise. /// </returns> private static bool TryGetInteractionMapping(IMixedRealityController controller, DeviceInputType inputType, out MixedRealityInteractionMapping mapping) { mapping = null; MixedRealityInteractionMapping[] mappings = controller.Interactions; for (int i = 0; i < mappings.Length; i++) { if (mappings[i].InputType == inputType) { mapping = mappings[i]; return(true); } } return(false); }
/// <summary> /// Overload extension to enable getting of an InteractionDefinition of a specific type /// </summary> /// <param name="input">The InteractionDefinition array reference</param> /// <param name="key">The specific DeviceInputType value to query</param> public static MixedRealityInteractionMapping GetInteractionByType(this MixedRealityInteractionMapping[] input, DeviceInputType key) { for (int i = 0; i < input?.Length; i++) { if (input[i].InputType == key) { return(input[i]); } } return(default);
/// <summary> /// The constructor for a new MixedRealityInputActionMapping definition /// </summary> /// <param name="description">The description of the interaction mapping.</param> /// <param name="inputAction">The logical MixedRealityInputAction that this input performs</param> public MixedRealityInputActionMapping(string description, AxisType axisType, DeviceInputType inputType) : this(description, axisType, inputType, MixedRealityInputAction.None) { }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param> /// <param name="inputType">The physical input device / control type.</param> /// <param name="keyCode">Optional KeyCode value to get input from Unity's old input system</param> /// <param name="inputProcessors"></param> public MixedRealityInteractionMapping(string description, AxisType axisType, DeviceInputType inputType, KeyCode keyCode, List <InputProcessor> inputProcessors = null) : this(description, axisType, inputType, inputProcessors) { this.keyCode = keyCode; }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param> /// <param name="inputType">The physical input device / control type.</param> /// <param name="axisCodeX">Optional horizontal or single axis value to get axis data from Unity's old input system.</param> /// <param name="axisCodeY">Optional vertical axis value to get axis data from Unity's old input system.</param> /// <param name="inputProcessors"></param> public MixedRealityInteractionMapping(string description, AxisType axisType, DeviceInputType inputType, string axisCodeX, string axisCodeY = "", List <InputProcessor> inputProcessors = null) : this(description, axisType, inputType, inputProcessors) { this.axisCodeX = axisCodeX; this.axisCodeY = axisCodeY; }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping.</param> /// <param name="inputName">Optional inputName value to get input for a coded input identity from a provider.</param> /// <param name="inputType">The physical input device / control type.</param> /// <param name="inputProcessors"></param> public MixedRealityInteractionMapping(string description, AxisType axisType, string inputName, DeviceInputType inputType, List <InputProcessor> inputProcessors = null) : this(description, axisType, inputType, inputProcessors) { this.inputName = inputName; }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="id">Identity for mapping</param> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param> /// <param name="inputType">The physical input device / control</param> /// <param name="keyCode">Optional KeyCode value to get input from Unity's old input system</param> public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, KeyCode keyCode) : this(id, description, axisType, inputType, MixedRealityInputAction.None, keyCode) { }
/// <summary> /// The constructor for a new Interaction Mapping definition /// </summary> /// <param name="id">Identity for mapping</param> /// <param name="description">The description of the interaction mapping.</param> /// <param name="axisType">The axis that the mapping operates on, also denotes the data type for the mapping</param> /// <param name="inputType">The physical input device / control</param> /// <param name="axisCodeX">Optional horizontal or single axis value to get axis data from Unity's old input system.</param> /// <param name="axisCodeY">Optional vertical axis value to get axis data from Unity's old input system.</param> /// <param name="invertXAxis">Optional horizontal axis invert option.</param> /// <param name="invertYAxis">Optional vertical axis invert option.</param> public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, string axisCodeX = "", string axisCodeY = "", bool invertXAxis = false, bool invertYAxis = false) : this(id, description, axisType, inputType, MixedRealityInputAction.None, KeyCode.None, axisCodeX, axisCodeY, invertXAxis, invertYAxis) { }
/// <summary> /// Overload extension to enable getting of an InteractionDefinition of a specific type /// </summary> /// <param name="input">The InteractionDefinition array reference</param> /// <param name="key">The specific DeviceInputType value to query</param> public static bool SupportsInputType(this MixedRealityInteractionMapping[] input, DeviceInputType key) { for (int i = 0; i < input.Length; i++) { if (input[i].InputType == key) { return(true); } } return(false); }