FIX: Several fixes to XR layouts (#95).
This commit is contained in:
Родитель
cc6b238fa0
Коммит
748c1b3ef0
|
@ -1079,7 +1079,7 @@ namespace UnityEngine.Experimental.Input
|
|||
Plugins.Switch.SwitchSupport.Initialize();
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_EDITOR || UNITY_IOS
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_ANDROID || UNITY_IOS || UNITY_UWP
|
||||
Plugins.XR.XRSupport.Initialize();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -45,11 +45,15 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
public AxisControl indexNearTouch { get; private set; }
|
||||
public AxisControl thumbNearTouch { get; private set; }
|
||||
|
||||
[InputControl(aliases = new[] { "A", "X" })]
|
||||
public ButtonControl primaryButton { get; private set; }
|
||||
[InputControl(aliases = new[] { "B", "Y" })]
|
||||
public ButtonControl secondaryButton { get; private set; }
|
||||
public ButtonControl start { get; private set; }
|
||||
public ButtonControl thumbstickClick { get; private set; }
|
||||
[InputControl(aliases = new[] { "ATouch", "XTouch" })]
|
||||
public ButtonControl primaryTouch { get; private set; }
|
||||
[InputControl(aliases = new[] { "BTouch", "YTouch" })]
|
||||
public ButtonControl secondaryTouch { get; private set; }
|
||||
public ButtonControl indexTouch { get; private set; }
|
||||
public ButtonControl thumbstickTouch { get; private set; }
|
||||
|
|
|
@ -40,13 +40,14 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
public AxisControl combinedTrigger { get; private set; }
|
||||
public Vector2Control joystick { get; private set; }
|
||||
public AxisControl trigger { get; private set; }
|
||||
public AxisControl grip { get; private set; }
|
||||
public Vector2Control touchpad { get; private set; }
|
||||
public ButtonControl gripPressed { get; private set; }
|
||||
public ButtonControl grip { get; private set; }
|
||||
public ButtonControl menu { get; private set; }
|
||||
public ButtonControl joystickClick { get; private set; }
|
||||
public ButtonControl triggerPressed { get; private set; }
|
||||
public ButtonControl triggerPressed { get; private set; }
|
||||
[InputControl(aliases = new[] { "touchpadClick" })]
|
||||
public ButtonControl touchpadClicked { get; private set; }
|
||||
[InputControl(aliases = new[] { "touchpadTouch" })]
|
||||
public ButtonControl touchPadTouched { get; private set; }
|
||||
public IntegerControl trackingState { get; private set; }
|
||||
public ButtonControl isTracked { get; private set; }
|
||||
|
@ -60,9 +61,8 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
combinedTrigger = builder.GetControl<AxisControl>("combinedTrigger");
|
||||
joystick = builder.GetControl<Vector2Control>("joystick");
|
||||
trigger = builder.GetControl<AxisControl>("trigger");
|
||||
grip = builder.GetControl<AxisControl>("grip");
|
||||
touchpad = builder.GetControl<Vector2Control>("touchpad");
|
||||
gripPressed = builder.GetControl<ButtonControl>("gripPressed");
|
||||
grip = builder.GetControl<ButtonControl>("grip");
|
||||
menu = builder.GetControl<ButtonControl>("menu");
|
||||
joystickClick = builder.GetControl<ButtonControl>("joystickClick");
|
||||
triggerPressed = builder.GetControl<ButtonControl>("triggerPressed");
|
||||
|
|
|
@ -83,13 +83,11 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
InputSystem.RegisterControlLayout<WMRHMD>(
|
||||
matches: new InputDeviceMatcher()
|
||||
.WithInterface(XRUtilities.kXRInterface)
|
||||
.WithManufacturer("Microsoft")
|
||||
.WithProduct("Windows Mixed Reality HMD"));
|
||||
InputSystem.RegisterControlLayout<WMRSpatialController>(
|
||||
matches: new InputDeviceMatcher()
|
||||
.WithInterface(XRUtilities.kXRInterface)
|
||||
.WithManufacturer("Microsoft")
|
||||
.WithProduct("Spatial Controller"));
|
||||
.WithProduct("^(Spatial Controller)"));
|
||||
|
||||
InputSystem.RegisterControlLayout<OculusHMD>(
|
||||
matches: new InputDeviceMatcher()
|
||||
|
|
|
@ -103,6 +103,10 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
layoutName = string.Format("{0}::{1}::{2}", SanitizeName(XRUtilities.kXRInterface), SanitizeName(description.manufacturer), SanitizeName(description.product));
|
||||
}
|
||||
|
||||
// If we are already using a generated layout, we just want to use what's there currently, instead of creating a brand new layout.
|
||||
if (layoutName == matchedLayout)
|
||||
return layoutName;
|
||||
|
||||
var layout = new XRLayoutBuilder { descriptor = deviceDescriptor, parentLayout = matchedLayout };
|
||||
InputSystem.RegisterControlLayoutBuilder(() => layout.Build(), layoutName, matchedLayout,
|
||||
InputDeviceMatcher.FromDeviceDescription(description));
|
||||
|
@ -110,6 +114,27 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
return layoutName;
|
||||
}
|
||||
|
||||
string ConvertPotentialAliasToName(InputControlLayout layout, string nameOrAlias)
|
||||
{
|
||||
InternedString internedNameOrAlias = new InternedString(nameOrAlias);
|
||||
ReadOnlyArray<InputControlLayout.ControlItem> controls = layout.controls;
|
||||
for(int i = 0; i < controls.Count; i++)
|
||||
{
|
||||
InputControlLayout.ControlItem controlItem = controls[i];
|
||||
|
||||
if (controlItem.name == internedNameOrAlias)
|
||||
return nameOrAlias;
|
||||
|
||||
ReadOnlyArray<InternedString> aliases = controlItem.aliases;
|
||||
for(int j = 0; j < aliases.Count; j++)
|
||||
{
|
||||
if (aliases[j] == nameOrAlias)
|
||||
return controlItem.name.ToString();
|
||||
}
|
||||
}
|
||||
return nameOrAlias;
|
||||
}
|
||||
|
||||
public InputControlLayout Build()
|
||||
{
|
||||
var builder = new InputControlLayout.Builder
|
||||
|
@ -119,6 +144,8 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
updateBeforeRender = true
|
||||
};
|
||||
|
||||
var inherittedLayout = InputSystem.TryLoadLayout(parentLayout);
|
||||
|
||||
var currentUsages = new List<string>();
|
||||
|
||||
uint currentOffset = 0;
|
||||
|
@ -133,9 +160,13 @@ namespace UnityEngine.Experimental.Input.Plugins.XR
|
|||
if (!string.IsNullOrEmpty(usageHint.content))
|
||||
currentUsages.Add(usageHint.content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string featureName = feature.name;
|
||||
featureName = SanitizeName(featureName);
|
||||
if (inherittedLayout != null)
|
||||
featureName = ConvertPotentialAliasToName(inherittedLayout, featureName);
|
||||
|
||||
string featureName = SanitizeName(feature.name);
|
||||
uint nextOffset = GetSizeOfFeature(feature);
|
||||
switch (feature.featureType)
|
||||
{
|
||||
|
|
|
@ -1 +1 @@
|
|||
m_EditorVersion: 2018.2.0a9
|
||||
m_EditorVersion: 2018.2.0b3
|
||||
|
|
Загрузка…
Ссылка в новой задаче