This PR builds upon #90, further enhancing exit comprehension by giving the user the option to choose between auto stopping when no binds are present (the old windows/linux behaviour) and stopping only upon explicit call to stop_handling_input_events (previously a linux only feature). The stop_handling_input_events function is now available to both platforms.
Warning !!! Only compiled and tested on windows.
Migration Guide
handle_input_events now expects an auto_stop boolean (where true is the old exit behaviour and false requires an explicit call to stop_handling_input_events to exit)
Motivation
I should mention the main motivation for this.
The obvious motivation is to make stop_handling_input_events available across platforms.
But secondly, I'm working on an app which may at some point have zero binds present. I don't want the input handler to exit every time the user removes binds. Therefore, I added the option to set auto_stop behaviour.
Now that I think on it, perhaps I should split this PR into two... Thoughts?
Changes
Moved stop_handling_input_events to public.rs
Added should_continue(auto_stop) function to common.rs to ensure loop behaviour is identical
Loop behaviour when auto_stop is true is: HANDLE_EVENTS && have_any_binds_present
Loop behaviour when auto_stop is false is just: HANDLE_EVENTS
handle_input_events now takes a boolean auto_stop parameter, which is internally passed to should_continue to drive the input loop
Moved HANDLE_EVENTS atomic to common.rs
HANDLE_EVENTS now defaults to false and each handle_input_events function now sets it to true just before the loop starts - this is because the previous arrangement would cause the handle_input_events function to immediately exit if it follows a call to stop_handling_input_events, which would be surprising behaviour to most users
This PR builds upon #90, further enhancing exit comprehension by giving the user the option to choose between auto stopping when no binds are present (the old windows/linux behaviour) and stopping only upon explicit call to
stop_handling_input_events
(previously a linux only feature). Thestop_handling_input_events
function is now available to both platforms.Warning !!! Only compiled and tested on windows.
Migration Guide
handle_input_events
now expects anauto_stop
boolean (wheretrue
is the old exit behaviour andfalse
requires an explicit call tostop_handling_input_events
to exit)Motivation
I should mention the main motivation for this.
The obvious motivation is to make
stop_handling_input_events
available across platforms.But secondly, I'm working on an app which may at some point have zero binds present. I don't want the input handler to exit every time the user removes binds. Therefore, I added the option to set
auto_stop
behaviour.Now that I think on it, perhaps I should split this PR into two... Thoughts?
Changes
stop_handling_input_events
topublic.rs
should_continue(auto_stop)
function tocommon.rs
to ensure loop behaviour is identicalauto_stop
istrue
is:HANDLE_EVENTS && have_any_binds_present
auto_stop
isfalse
is just:HANDLE_EVENTS
handle_input_events
now takes a booleanauto_stop
parameter, which is internally passed toshould_continue
to drive the input loopHANDLE_EVENTS
atomic tocommon.rs
HANDLE_EVENTS
now defaults tofalse
and eachhandle_input_events
function now sets it to true just before the loop starts - this is because the previous arrangement would cause thehandle_input_events
function to immediately exit if it follows a call tostop_handling_input_events
, which would be surprising behaviour to most users