Skip to content

Conversation

@jechter
Copy link
Contributor

@jechter jechter commented Sep 19, 2019

When a control does not have an explicit defaultState argument to the InputControl attribute, the default state is considered to be 0. But for axis controls which are normalized to return values from -1..1, and which are represented by an unsigned integer on the device, 0 is not the correct default value for the input state. This meant that the axis would be considered to be at it's default value when at -1. This is common for gamepad access, and would result in canceled callbacks being sent when moving the axis towards -1.

Now, in combination with my previous fix here: https://github.com/Unity-Technologies/InputSystem/pull/828/files#diff-a82dc3439d6b317a87e69ff2cdc0bc0a , which would always return 0 values for canceled interactions, this would mean that moving a gamepad stick all the way to the left would generate a value of 0, which completely broke the Input System.

This PR automatically generates default values for axes when no default is explicitly set and when normalizeZero is used, which fixes the problem. This is the best fix I could think of - I also considered adding default values everywhere (but that would have been much work, and easy to get wrong or miss a place), or to ignore any controls without explicit default values for CheckStateIsAtDefault, but that would skip optimizations and possibly change behavior).

@jechter jechter merged commit ab70ecc into develop Sep 20, 2019
@jechter jechter mentioned this pull request Sep 25, 2019
@Rene-Damm Rene-Damm deleted the fix-axis-control-default-state branch October 11, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants