File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -365,6 +365,7 @@ def prepare(m):
365365
366366 logger .info ("Emulated controller launched, have fun!" )
367367 prev = 0
368+ woke_up = 0
368369 while not should_exit .is_set () and not updated .is_set ():
369370 start = time .perf_counter ()
370371 # Add timeout to call consumers a minimum amount of times per second
@@ -378,18 +379,19 @@ def prepare(m):
378379 if id (d ) in to_run :
379380 evs .extend (d .produce (r ))
380381
382+ # Detect wakeup through pause
381383 if start - prev > 1 :
382- # After wakeup, the controller waits a bit until it
383- # realizes it woke up and switches to desktop mode.
384- # Therefore we need to wait otherwise we race it and
385- # end up stuck in desktop mode.
386- if prev :
387- time .sleep (3 )
384+ woke_up = start
385+ prev = start
386+
387+ # After wakeup, the controller waits a bit until it
388+ # realizes it woke up and switches to desktop mode.
389+ # Therefore we need to wait otherwise we race it and
390+ # end up stuck in desktop mode.
391+ if woke_up is not None and start - woke_up > 3 :
388392 logger .info ("Setting controller to dinput mode." )
389393 d_vend .set_dinput_mode ()
390- prev = time .perf_counter ()
391- else :
392- prev = start
394+ woke_up = None
393395
394396 evs = multiplexer .process (evs )
395397 if evs :
You can’t perform that action at this time.
0 commit comments