Oh gotcha, that makes sense.
I run into that problem sometimes, and use a manual input blackout. Not sure how applicable that is for your case, but the general logic is like:
update(int state) {
if (blackout) {
if (!state) blackout = false;
} else {
...poll state etc etc...
}
}
Then when there’s a modal change, I set blackout nonzero and it will stop processing new input until the input state goes clear again.