@@ -2221,7 +2221,7 @@ internal void InstallRuntime(IInputRuntime runtime)
22212221#endif
22222222 m_Runtime . pollingFrequency = pollingFrequency ;
22232223
2224- focusState = Application . isFocused
2224+ focusState = Application . isFocused
22252225 ? focusState | FocusFlags . ApplicationFocus
22262226 : focusState & ~ FocusFlags . ApplicationFocus ;
22272227
@@ -3432,10 +3432,10 @@ private unsafe void ProcessEventBuffer(InputUpdateType updateType, ref InputEven
34323432 ++ m_Metrics . totalEventCount ;
34333433 m_Metrics . totalEventBytes += ( int ) currentEventReadPtr ->sizeInBytes ;
34343434
3435- ProcessEvent ( device , updateType , currentEventReadPtr , ref totalEventBytesProcessed ) ;
3435+ ProcessEvent ( device , updateType , currentEventReadPtr , ref totalEventBytesProcessed , currentEventTimeInternal ) ;
34363436
34373437 m_InputEventStream . Advance ( leaveEventInBuffer : false ) ;
3438-
3438+
34393439 // Discard events in case the maximum event bytes per update has been exceeded
34403440 if ( AreMaximumEventBytesPerUpdateExceeded ( totalEventBytesProcessed ) )
34413441 break ;
@@ -3491,7 +3491,7 @@ private unsafe bool SkipEventDueToEditorBehaviour(InputUpdateType updateType, Fo
34913491 {
34923492 var focusEventType = new FourCC ( FocusConstants . kEventType ) ;
34933493 var possibleFocusEvent = m_InputEventStream . Peek ( ) ;
3494-
3494+
34953495 if ( possibleFocusEvent != null )
34963496 {
34973497 if ( possibleFocusEvent ->type == focusEventType && ! gameShouldGetInputRegardlessOfFocus )
@@ -3550,6 +3550,7 @@ private unsafe bool SkipEventDueToEditorBehaviour(InputUpdateType updateType, Fo
35503550 }
35513551 return false ;
35523552 }
3553+
35533554#endif
35543555
35553556 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -3662,7 +3663,7 @@ private unsafe bool MergeWithNextEvent(InputDevice device, InputEvent* currentEv
36623663 }
36633664
36643665 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
3665- private unsafe void ProcessEvent ( InputDevice device , InputUpdateType updateType , InputEvent * currentEventReadPtr , ref uint totalEventBytesProcessed )
3666+ private unsafe void ProcessEvent ( InputDevice device , InputUpdateType updateType , InputEvent * currentEventReadPtr , ref uint totalEventBytesProcessed , double currentEventTimeInternal )
36663667 {
36673668 var currentEventType = currentEventReadPtr ->type ;
36683669
@@ -3671,7 +3672,7 @@ private unsafe void ProcessEvent(InputDevice device, InputUpdateType updateType,
36713672 {
36723673 case StateEvent . Type :
36733674 case DeltaStateEvent . Type :
3674- ProcessStateEvent ( device , updateType , currentEventReadPtr , ref totalEventBytesProcessed ) ;
3675+ ProcessStateEvent ( device , updateType , currentEventReadPtr , ref totalEventBytesProcessed , currentEventTimeInternal ) ;
36753676 break ;
36763677
36773678 case TextEvent . Type :
@@ -3702,24 +3703,23 @@ private unsafe void ProcessEvent(InputDevice device, InputUpdateType updateType,
37023703 }
37033704
37043705 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
3705- private unsafe void ProcessStateEvent ( InputDevice device , InputUpdateType updateType , InputEvent * currentEventReadPtr , ref uint totalEventBytesProcessed )
3706+ private unsafe void ProcessStateEvent ( InputDevice device , InputUpdateType updateType , InputEvent * currentEventReadPtr , ref uint totalEventBytesProcessed , double currentEventTimeInternal )
37063707 {
37073708 var eventPtr = new InputEventPtr ( currentEventReadPtr ) ;
37083709
3709- // Ignore the event if the last state update we received for the device was
3710- // newer than this state event is. We don't allow devices to go back in time.
3711- //
3712- // NOTE: We make an exception here for devices that implement IInputStateCallbackReceiver (such
3713- // as Touchscreen). For devices that dynamically incorporate state it can be hard ensuring
3714- // a global ordering of events as there may be multiple substreams (e.g. each individual touch)
3715- // that are generated in the backend and would require considerable work to ensure monotonically
3716- // increasing timestamps across all such streams.
3717- var deviceIsStateCallbackReceiver = device . hasStateCallbacks ;
3718- if ( currentEventTimeInternal < device . m_LastUpdateTimeInternal &&
3719- ! ( deviceIsStateCallbackReceiver && device . stateBlock . format != eventPtr . stateFormat ) )
3720- {
3721- #if UNITY_EDITOR
3710+ // Ignore the event if the last state update we received for the device was
3711+ // newer than this state event is. We don't allow devices to go back in time.
3712+ //
3713+ // NOTE: We make an exception here for devices that implement IInputStateCallbackReceiver (such
3714+ // as Touchscreen). For devices that dynamically incorporate state it can be hard ensuring
3715+ // a global ordering of events as there may be multiple substreams (e.g. each individual touch)
3716+ // that are generated in the backend and would require considerable work to ensure monotonically
3717+ // increasing timestamps across all such streams.
3718+ var deviceIsStateCallbackReceiver = device . hasStateCallbacks ;
3719+ if ( currentEventTimeInternal < device . m_LastUpdateTimeInternal &&
3720+ ! ( deviceIsStateCallbackReceiver && device . stateBlock . format != eventPtr . stateFormat ) )
37223721 {
3722+ #if UNITY_EDITOR
37233723 m_Diagnostics ? . OnEventTimestampOutdated ( new InputEventPtr ( currentEventReadPtr ) , device ) ;
37243724#elif UNITY_ANDROID
37253725 // Android keyboards can send events out of order: Holding down a key will send multiple
0 commit comments