-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing release events when keys are released in order of pressing #965
Conversation
fe99bec
to
201ee44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are still some bugs in the notify()
method. There are 3 different states and 6 different state transitions:
P
PassiveA
ActiveS
Suppressed
P
->P
with key downP
->P
with key upP
->A
key downA
->P
key upP
->S
key downS
->P
key up
I think the first 4 transitions are good, but not the transitions 5 and 6.
On transition 5 self.forward_release()
will be executed (line 129). Basically releasing the input even though the mapping does not execute. A test for this would be two mappings:
a+b+c->1
and a+c->2
on mapping 1 set release_combination_keys=False
and then input a+b+c
the first mapping will be active, the second one suppressed but the key a
is still released.
On transition 6 the line return not self.should_release_event(event)
(line 125) is executed. Now there are two possibilities: the released key is the exact same key that triggered transition 5 -> Return False
the released key is a different one -> Return True
I think the second possibility can cause a stuck key like so (assuming transition 5 is fixed):
mappings: a+b+d->1
and c+d->2
press a+b+c+d
-> mapping 1 is in sate A
and 2 in state S
release c
-> mapping 2 does transition 6 but the release of c
is not forwarded because line 125 returns True (i think)
9a69df4
to
eeb0951
Compare
Thanks. I'm pretty impressed that you figured that out by looking at the code. I reproduced transition 5 in I couldn't reproduce transition 6. Did I test that correctly in |
I had to draw a state diagram in order to wrap my head around this and see all the possible state transitions. Going to look at transition 6 again, as I could not check this without the fix for transition 5. |
Sounds like something that I should do as well sometimes. I'm curious, could you please share the state diagram? |
I think I was wrong with the transition 6. The only key that is not in |
Ok, thank you. Shall we merge? |
Should we keep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep
test_no_stuck_key
?
I think it is fine to keep
Ok, thank you. Shall we merge?
You can change the things I commented or not, I am not sure what is more readable
inputremapper/injection/mapping_handlers/combination_handler.py
Outdated
Show resolved
Hide resolved
inputremapper/injection/mapping_handlers/combination_handler.py
Outdated
Show resolved
Hide resolved
I think we can remove the calls to |
99f2140
to
0fb8379
Compare
With the recent changes and discoveries, I managed to split it into 4 separate methods
Is this more maintainable? I guess so |
e8a6519
to
3437103
Compare
3437103
to
f0ed62e
Compare
if changed: | ||
if is_pressed: | ||
return self._handle_freshly_activated(suppress, event, source) | ||
else: | ||
return self._handle_freshly_deactivated(event, source) | ||
else: | ||
if is_pressed: | ||
return self._handle_no_change_press(event) | ||
else: | ||
return self._handle_no_change_release(event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, but I think this is a bit misleading. If I read this correctly _handle_no_change_release
will be called when the state changes from suppressed to passive. I guess a simple comment should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit lost, could you please propose a change with the comment?
Thank you so much @jonasBoss, after merging I realized I probably should have added you as a co-author of that commit. Great review. |
I'll make a new 2.0.2 release in a few weeks |
1.
a + b -> c
the release event for a was never injected
2.
"release_input" "on" released events, for which no key-down event was written before