Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Missing updates required in Core for Oculus module #237

Merged
merged 3 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions XRTK-Core/Packages/com.xrtk.core/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
[assembly: InternalsVisibleTo("XRTK.Utilities.Gltf.Importers")]
[assembly: InternalsVisibleTo("XRTK.WindowsMixedReality")]
[assembly: InternalsVisibleTo("XRTK.WindowsMixedReality.Player")]
[assembly: InternalsVisibleTo("XRTK.Oculus")]
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public MixedRealityInteractionMapping(uint id, string description, AxisType axis
this.inputType = inputType;
inputAction = MixedRealityInputAction.None;
keyCode = KeyCode.None;
this.inputName = string.Empty;
this.axisCodeX = axisCodeX;
this.axisCodeY = axisCodeY;
this.invertXAxis = invertXAxis;
Expand Down Expand Up @@ -76,6 +77,34 @@ public MixedRealityInteractionMapping(uint id, string description, AxisType axis
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="inputName">Optional inputName value to get input for a coded input identity from a provider</param>
public MixedRealityInteractionMapping(uint id, string description, AxisType axisType, DeviceInputType inputType, string inputName)
{
this.id = id;
this.description = description;
this.axisType = axisType;
this.inputType = inputType;
inputAction = MixedRealityInputAction.None;
this.inputName = inputName;
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>
Expand Down Expand Up @@ -111,6 +140,41 @@ public MixedRealityInteractionMapping(uint id, string description, AxisType axis
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="inputName">Optional inputName value to get input for a coded input identity from a provider</param></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, string inputName, 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.inputName = inputName;
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;
}

public MixedRealityInteractionMapping(MixedRealityInteractionMapping mixedRealityInteractionMapping)
{
id = mixedRealityInteractionMapping.id;
Expand All @@ -119,6 +183,7 @@ public MixedRealityInteractionMapping(MixedRealityInteractionMapping mixedRealit
inputType = mixedRealityInteractionMapping.inputType;
inputAction = mixedRealityInteractionMapping.inputAction;
keyCode = mixedRealityInteractionMapping.keyCode;
inputName = mixedRealityInteractionMapping.inputName;
axisCodeX = mixedRealityInteractionMapping.axisCodeX;
axisCodeY = mixedRealityInteractionMapping.axisCodeY;
invertXAxis = mixedRealityInteractionMapping.invertXAxis;
Expand Down Expand Up @@ -193,6 +258,15 @@ public MixedRealityInputAction MixedRealityInputAction
/// </summary>
public KeyCode KeyCode => keyCode;

[SerializeField]
[Tooltip("Optional KeyCode value to get input from Unity's old input system.")]
private string inputName;

/// <summary>
/// Optional inputName value to get input for a coded input identity from a provider.
/// </summary>
public string InputName => inputName;

[SerializeField]
[Tooltip("Optional horizontal or single axis value to get axis data from Unity's old input system.")]
private string axisCodeX;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using XRTK.Definitions.Devices;
using XRTK.Definitions.Utilities;
using XRTK.Interfaces.InputSystem;
using XRTK.Services;

namespace XRTK.Extensions
{
/// <summary>
/// Extensions for the InteractionMapping class to refactor the generic methods used for raising events in InteractionMappings.
/// </summary>
public static class InteractionMappingsExtensions
{
public static void UpdateInteractionMappingBool(this MixedRealityInteractionMapping interactionMapping, IMixedRealityInputSource inputSource, Handedness controllerHandedness)
{
// If our value changed raise it.
if (interactionMapping.Changed)
{
// Raise input system Event if it enabled
if (interactionMapping.BoolData)
{
MixedRealityToolkit.InputSystem?.RaiseOnInputDown(inputSource, controllerHandedness, interactionMapping.MixedRealityInputAction);
}
else
{
MixedRealityToolkit.InputSystem?.RaiseOnInputUp(inputSource, controllerHandedness, interactionMapping.MixedRealityInputAction);
}
}

if (interactionMapping.Updated)
{
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(inputSource, controllerHandedness, interactionMapping.MixedRealityInputAction);
}
}

public static void UpdateInteractionMappingFloat(this MixedRealityInteractionMapping interactionMapping, IMixedRealityInputSource inputSource, Handedness controllerHandedness)
{
// If our value changed raise it.
if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaiseOnInputPressed(inputSource, controllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
}
}

public static void UpdateInteractionMappingVector2(this MixedRealityInteractionMapping interactionMapping, IMixedRealityInputSource inputSource, Handedness controllerHandedness)
{
// If our value changed raise it.
if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaisePositionInputChanged(inputSource, controllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.Vector2Data);
}
}

public static void UpdateInteractionMappingPose(this MixedRealityInteractionMapping interactionMapping, IMixedRealityInputSource inputSource, Handedness controllerHandedness)
{
// If our value changed raise it.
if (interactionMapping.Updated)
{
// Raise input system Event if it enabled
MixedRealityToolkit.InputSystem?.RaisePoseInputChanged(inputSource, controllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.PoseData);
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion XRTK-Core/Packages/com.xrtk.core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.xrtk.core",
"displayName": "XRTK.Core",
"description": "The core framework of the Mixed Reality Toolkit",
"version": "0.1.12",
"version": "0.1.13",
"unity": "2019.1",
"license": "MIT",
"repository": {
Expand Down