diff --git a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs index 128aca347c..2abac9ad80 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs @@ -3731,19 +3731,22 @@ private unsafe void ProcessStateEvent(InputDevice device, InputUpdateType update // that are generated in the backend and would require considerable work to ensure monotonically // increasing timestamps across all such streams. var deviceIsStateCallbackReceiver = device.hasStateCallbacks; +#if UNITY_ANDROID + // Android keyboards can send events out of order: Holding down a key will send multiple + // presses after a short time, like on most platforms. Unfortunately, on Android, the + // last of these "presses" can be timestamped to be after the event of the key release. + // If that happens, we'd skip the keyUp here, and the device state will have the key + // "stuck" pressed. So, special case here to not skip keyboard events on Android. ISXB-475 + // N.B. Android seems to have similar issues with touch input (OnStateEvent, Touchscreen.cs) + // Android also seems to have similar issue with mouse input, see UUM-136430. + if (currentEventTimeInternal < device.m_LastUpdateTimeInternal - 1e-3 && /* 1 ms accepted error */ +#else if (currentEventTimeInternal < device.m_LastUpdateTimeInternal && +#endif !(deviceIsStateCallbackReceiver && device.stateBlock.format != eventPtr.stateFormat)) { #if UNITY_EDITOR m_Diagnostics?.OnEventTimestampOutdated(new InputEventPtr(currentEventReadPtr), device); -#elif UNITY_ANDROID - // Android keyboards can send events out of order: Holding down a key will send multiple - // presses after a short time, like on most platforms. Unfortunately, on Android, the - // last of these "presses" can be timestamped to be after the event of the key release. - // If that happens, we'd skip the keyUp here, and the device state will have the key - // "stuck" pressed. So, special case here to not skip keyboard events on Android. ISXB-475 - // N.B. Android seems to have similar issues with touch input (OnStateEvent, Touchscreen.cs) - if (!(device is Keyboard)) #endif return; }