@@ -109,10 +109,8 @@ DWORD InitiateSendInput(RemapEntry* pRemapEntry, RemapEntryState* pRemapEntrySta
109109 }
110110 if (pOutputConfig->outputFlag .bCancelActiveOutputs )
111111 {
112- // HACK alert - would destroy this thread, so disassociate and exit immediately after
113- pRemapEntryState->bShutdown = true ;
114- pRemapEntryState->threadHandle = NULL ;
115- ShutdownInputThreads ();
112+ // NOTE: even this thread might be affected
113+ ShutdownInputThreads (false );
116114 break ;
117115 }
118116 else if (pOutputConfig->outputFlag .bMouseOut )
@@ -152,17 +150,34 @@ DWORD InitiateSendInput(RemapEntry* pRemapEntry, RemapEntryState* pRemapEntrySta
152150 firstPassComplete = true ;
153151 if (pRemapEntryState->bRepeating )
154152 {
155- Sleep (repeatDelayMillis);
156- LogDebugMessage (" SendInputThread Repeating..." );
153+ int iterations = repeatDelayMillis / MIN_REPEAT_DELAY_MS;
154+ for (int repeatDelayCount = 0 ; repeatDelayCount < iterations; repeatDelayCount++)
155+ {
156+ Sleep (100 );
157+ if (pRemapEntryState->bShutdown )
158+ {
159+ LogDebugMessage (" Exiting repeat loop due to shutdown." );
160+ break ;
161+ }
162+ }
163+ if (!pRemapEntryState->bShutdown )
164+ {
165+ LogDebugMessage (" SendInputThread Repeating..." );
166+ }
157167 }
158168 } while (pRemapEntryState->bRepeating );
159169
160- // flip the overall toggle state
170+ // flip the overall toggle state (even when a thread is canceled this should flip back, arguably to false...)
161171 pRemapEntryState->bToggled = !pRemapEntryState->bToggled ;
162- pRemapEntryState->bShutdown = false ;
163172
164- LogDebugMessage (" SendInputThread Completed" );
165- // Disconnect this thread from the state
173+ // reset things on the remap entry
174+ pRemapEntryState->bShutdown = false ;
175+ pRemapEntryState->bRepeating = false ;
166176 pRemapEntryState->threadHandle = NULL ;
177+ #ifdef _DEBUG
178+ char * pInputConfigDescription = GetInputConfigDescription (pRemapEntry->inputConfig );
179+ LogDebugMessage (" SendInputThread Completed: %s" , pInputConfigDescription);
180+ free (pInputConfigDescription);
181+ #endif
167182 return 0 ;
168183}
0 commit comments