FIX: Inverted Y on sticks and broken axis dpad on Android.
This commit is contained in:
Родитель
1dd5c24bfd
Коммит
fcf6bf9813
|
@ -256,19 +256,18 @@ namespace UnityEngine.Experimental.Input
|
|||
ArrayHelpers.Merge(usages.m_Array,
|
||||
other.usages.m_Array));
|
||||
|
||||
// We don't merge parameters. If a control sets parameters, it'll overwrite
|
||||
// parameters inherited from the base.
|
||||
if (parameters.Count == 0)
|
||||
result.parameters = other.parameters;
|
||||
else if (other.parameters.Count == 0)
|
||||
result.parameters = parameters;
|
||||
else
|
||||
throw new NotImplementedException("merging parameters");////REVIEW: probably best to not merge them actually
|
||||
result.parameters = parameters;
|
||||
|
||||
// Same for processors.
|
||||
if (processors.Count == 0)
|
||||
result.processors = other.processors;
|
||||
else if (other.parameters.Count == 0)
|
||||
result.processors = processors;
|
||||
else
|
||||
throw new NotImplementedException("merging processors");
|
||||
result.processors = processors;
|
||||
|
||||
if (!string.IsNullOrEmpty(displayName))
|
||||
result.displayName = displayName;
|
||||
|
|
|
@ -35,10 +35,11 @@ namespace UnityEngine.Experimental.Input.Plugins.Android.LowLevel
|
|||
[InputControl(name = "leftTrigger", offset = (uint)AndroidAxis.Ltrigger * sizeof(float) + kAxisOffset, variant = kVariantGamepad)]
|
||||
[InputControl(name = "rightTrigger", offset = (uint)AndroidAxis.Rtrigger * sizeof(float) + kAxisOffset, variant = kVariantGamepad)]
|
||||
[InputControl(name = "leftStick", variant = kVariantGamepad)]
|
||||
[InputControl(name = "leftStick/y", variant = kVariantGamepad, parameters = "invert")]
|
||||
////FIXME: state for this control is not contiguous
|
||||
[InputControl(name = "rightStick", offset = (uint)AndroidAxis.Z * sizeof(float) + kAxisOffset, sizeInBits = ((uint)AndroidAxis.Rz - (uint)AndroidAxis.Z) * sizeof(float) * 8, variant = kVariantGamepad)]
|
||||
[InputControl(name = "rightStick/x", variant = kVariantGamepad)]
|
||||
[InputControl(name = "rightStick/y", offset = ((uint)AndroidAxis.Rz - (uint)AndroidAxis.Z) * sizeof(float), variant = kVariantGamepad)]
|
||||
[InputControl(name = "rightStick/y", offset = ((uint)AndroidAxis.Rz - (uint)AndroidAxis.Z) * sizeof(float), variant = kVariantGamepad, parameters = "invert")]
|
||||
public fixed float axis[kMaxAndroidAxes];
|
||||
|
||||
public FourCC GetFormat()
|
||||
|
|
|
@ -30,10 +30,10 @@ namespace UnityEngine.Experimental.Input.Plugins.Android
|
|||
""extend"" : ""AndroidGamepad"",
|
||||
""controls"" : [
|
||||
{ ""name"" : ""dpad"", ""offset"" : 88, ""format"" : ""VEC2"", ""sizeInBits"" : 64 },
|
||||
{ ""name"" : ""dpad/left"", ""offset"" : 0, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampMin=0,clampMax=0.5,normalize,normalizeMin=0,normalizeMax=0.5"" },
|
||||
{ ""name"" : ""dpad/right"", ""offset"" : 0, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampConstant=0.5,clampMin=0.5,clampMax=1,normalize,normalizeMin=0.5,normalizeMax=1"" },
|
||||
{ ""name"" : ""dpad/up"", ""offset"" : 4, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampConstant=0.5,clampMin=0.5,clampMax=1,normalize,normalizeMin=0.5,normalizeMax=1"" },
|
||||
{ ""name"" : ""dpad/down"", ""offset"" : 4, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampMin=0,clampMax=0.5,normalize,normalizeMin=0,normalizeMax=0.5"" }
|
||||
{ ""name"" : ""dpad/right"", ""offset"" : 0, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampConstant=0,clampMin=0,clampMax=1"" },
|
||||
{ ""name"" : ""dpad/left"", ""offset"" : 0, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampConstant=0,clampMin=-1,clampMax=0,invert"" },
|
||||
{ ""name"" : ""dpad/down"", ""offset"" : 4, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampConstant=0,clampMin=0,clampMax=1"" },
|
||||
{ ""name"" : ""dpad/up"", ""offset"" : 4, ""bit"" : 0, ""format"" : ""FLT"", ""parameters"" : ""clampToConstant,clampConstant=0,clampMin=-1,clampMax=0,invert"" }
|
||||
]
|
||||
}
|
||||
");
|
||||
|
|
|
@ -69,9 +69,9 @@ class AndroidTests : InputTestFixture
|
|||
Assert.That(controller.leftTrigger.ReadValue(), Is.EqualTo(0.123).Within(0.000001));
|
||||
Assert.That(controller.rightTrigger.ReadValue(), Is.EqualTo(0.456).Within(0.000001));
|
||||
Assert.That(controller.leftStick.x.ReadValue(), Is.EqualTo(0.789).Within(0.000001));
|
||||
Assert.That(controller.leftStick.y.ReadValue(), Is.EqualTo(0.987).Within(0.000001));
|
||||
Assert.That(controller.leftStick.y.ReadValue(), Is.EqualTo(-0.987).Within(0.000001)); // Y is upside down on Android.
|
||||
Assert.That(controller.rightStick.x.ReadValue(), Is.EqualTo(0.654).Within(0.000001));
|
||||
Assert.That(controller.rightStick.y.ReadValue(), Is.EqualTo(0.321).Within(0.000001));
|
||||
Assert.That(controller.rightStick.y.ReadValue(), Is.EqualTo(-0.321).Within(0.000001)); // Y is upside down on Android.
|
||||
|
||||
AssertButtonPress(controller, new AndroidGameControllerState().WithButton(AndroidKeyCode.ButtonA), controller.buttonSouth);
|
||||
AssertButtonPress(controller, new AndroidGameControllerState().WithButton(AndroidKeyCode.ButtonX), controller.buttonWest);
|
||||
|
@ -107,27 +107,41 @@ class AndroidTests : InputTestFixture
|
|||
}.ToJson()
|
||||
});
|
||||
|
||||
// HatX is -1 (left) to 1 (right)
|
||||
// HatY is -1 (up) to 1 (down)
|
||||
|
||||
InputSystem.QueueStateEvent(gamepad,
|
||||
new AndroidGameControllerState()
|
||||
.WithAxis(AndroidAxis.HatX, 0.789f)
|
||||
.WithAxis(AndroidAxis.HatY, 0.987f));
|
||||
.WithAxis(AndroidAxis.HatX, 1)
|
||||
.WithAxis(AndroidAxis.HatY, 1));
|
||||
InputSystem.Update();
|
||||
|
||||
Assert.That(gamepad.dpad.left.isPressed, Is.False);
|
||||
Assert.That(gamepad.dpad.right.isPressed, Is.True);
|
||||
Assert.That(gamepad.dpad.up.isPressed, Is.False);
|
||||
Assert.That(gamepad.dpad.down.isPressed, Is.True);
|
||||
|
||||
InputSystem.QueueStateEvent(gamepad,
|
||||
new AndroidGameControllerState()
|
||||
.WithAxis(AndroidAxis.HatX, -1)
|
||||
.WithAxis(AndroidAxis.HatY, -1));
|
||||
InputSystem.Update();
|
||||
|
||||
Assert.That(gamepad.dpad.left.isPressed, Is.True);
|
||||
Assert.That(gamepad.dpad.right.isPressed, Is.False);
|
||||
Assert.That(gamepad.dpad.up.isPressed, Is.True);
|
||||
Assert.That(gamepad.dpad.down.isPressed, Is.False);
|
||||
|
||||
InputSystem.QueueStateEvent(gamepad,
|
||||
new AndroidGameControllerState()
|
||||
.WithAxis(AndroidAxis.HatX, 0.123f)
|
||||
.WithAxis(AndroidAxis.HatY, 0.456f));
|
||||
.WithAxis(AndroidAxis.HatX, 0)
|
||||
.WithAxis(AndroidAxis.HatY, 0));
|
||||
InputSystem.Update();
|
||||
|
||||
Assert.That(gamepad.dpad.left.isPressed, Is.True);
|
||||
Assert.That(gamepad.dpad.left.isPressed, Is.False);
|
||||
Assert.That(gamepad.dpad.right.isPressed, Is.False);
|
||||
Assert.That(gamepad.dpad.up.isPressed, Is.False);
|
||||
Assert.That(gamepad.dpad.down.isPressed, Is.True);
|
||||
Assert.That(gamepad.dpad.down.isPressed, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -37,6 +37,7 @@ GraphicsSettings:
|
|||
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_PreloadedShaders: []
|
||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||
type: 0}
|
||||
|
|
|
@ -12,8 +12,8 @@ PlayerSettings:
|
|||
targetDevice: 2
|
||||
useOnDemandResources: 0
|
||||
accelerometerFrequency: 60
|
||||
companyName: DefaultCompany
|
||||
productName: InputSystemX
|
||||
companyName: Unity Technologies
|
||||
productName: InputSystem
|
||||
defaultCursor: {fileID: 0}
|
||||
cursorHotspot: {x: 0, y: 0}
|
||||
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
||||
|
@ -246,6 +246,7 @@ PlayerSettings:
|
|||
androidSplashScreen: {fileID: 0}
|
||||
AndroidKeystoreName:
|
||||
AndroidKeyaliasName:
|
||||
AndroidBuildApkPerCpuArchitecture: 0
|
||||
AndroidTVCompatibility: 1
|
||||
AndroidIsGame: 1
|
||||
AndroidEnableTango: 0
|
||||
|
@ -607,9 +608,11 @@ PlayerSettings:
|
|||
platformArchitecture:
|
||||
iOS: 0
|
||||
scriptingBackend:
|
||||
Android: 0
|
||||
Standalone: 0
|
||||
iOS: 1
|
||||
il2cppCompilerConfiguration: {}
|
||||
il2cppCompilerConfiguration:
|
||||
Android: 0
|
||||
incrementalIl2cppBuild: {}
|
||||
allowUnsafeCode: 0
|
||||
additionalIl2CppArgs:
|
||||
|
@ -662,6 +665,7 @@ PlayerSettings:
|
|||
XboxOneGameOsOverridePath:
|
||||
XboxOnePackagingOverridePath:
|
||||
XboxOneAppManifestOverridePath:
|
||||
XboxOneVersion: 1.0.0.0
|
||||
XboxOnePackageEncryption: 0
|
||||
XboxOnePackageUpdateGranularity: 2
|
||||
XboxOneDescription:
|
||||
|
|
|
@ -1 +1 @@
|
|||
m_EditorVersion: 2018.2.0a8
|
||||
m_EditorVersion: 2018.2.0a9
|
||||
|
|
Загрузка…
Ссылка в новой задаче