-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix for macro and Unicode sequence reliability #127
Conversation
Removing the sync line fixes problems with macros and Unicode keystroke sequences that fail partway through.
The linting check failed but it appears to be something about how the linting is configured. You need an API key for a safety check? Doesn't seem to be anything I can do about that on my end. |
It's saying we need to update |
Might leave this open a while (for testing)... it's weird to think we'd need no ACKS... and with this removed the only acks we are getting are going to be original ones that are passed thru (immediately) from the real keyboard (since they are unmappable events)... the proper solution here might be to rewrite the input/modify layer such that it can understands entire key sequences - not just individual events... IE we have:
So we'd need to understand and rewrite them all.. after this patch we're just remapping I wonder what would happen if we just removed ALL the acks. |
Yes, I am also surprised that this doesn't appear to have any negative consequences that I've yet noticed. Everything seems fine.
This probably isn't what you meant, but I took a wild guess and tried adding this to the start of
The results seem... unequivocally bad. Like the system thinks I'm constantly holding or typing some keys. Had to bail and take it out right away. I'll continue to use this patch of removing the sync line, and update this if I ever run into anything odd. So far, nothing. Probably is a good idea to let this one sit here and cook for quite some time. 👍🏽 |
Exactly what I meant, and kind of what I expected... so strange though. |
For reference, apparently Not that any of that means anything to me yet. This is the entire
|
Same thing, well technically EV_SYN is the whole category... but SYN_REPORT is the only event I'm aware of being used in actual practice.
This is likely why we were still calling it, if we never called it (and also didn't randomly pass it thru) then any events queued would never be "fired" (and as you've seen that's a no go). So perhaps the secret sauce is in exactly when SYN is exerted?
I'd love to know more about this... |
But everything seems to keep working as it normally does, so when/why would No idea. |
I assume it's queuing until the "untransformed" syns come thru directly from the real keyboard... which flushes the queue. Why that works so much better than flushing it explicitly after each keypress is what remains a mystery. |
Ah. Interesting. That triggered a thought. I once again blocked all EV_SYN events. But, before restarting the keymapper I made sure to re-enable the sync call in both If I understand things correctly, this means the only syn events are coming from the keymapper now, and none from the real keyboard. After messing around for a few minutes, everything seems to be working fine. No dialog focus issues. No immediately apparent problems with macro reliability. The "0, 0, 0" events are no longer in the log, but there is an object emitted by the sync function.
So this is one apparently viable way to do things. If it's better or worse seems to be kind of a toss-up at the moment, without more information. But if there were ever a possibility that queued |
Yeah, that is the more "correct" approach IMHO, but really you'd also need some sort of state machine to account for KB + mouse devices (or running a separate mouse thru)... because you have events that are not If we failed to do that you could only move the mouse if you hit a key on the keyboard soon after, or some ridiculousness like that... so really I think in a perfect world:
Right now we're doing both which, means sometimes we double up, which evidently some systems don't like. |
Mmmm... not having any trouble with my touchpad movement or clicking. Or click-selecting things. Even if I don't mess with the keyboard at all for a while as I do touchpad stuff. Not saying you're wrong, but I haven't experienced any issue so far.
Ah, so this would be a problem with a combined device (or, I assume, any other pointing device that happens to be "grabbed" during startup)? Yeah... I could see that being an issue. So for me it's not a problem because only my keyboard device is being grabbed. Can syn events from a keyboard be easily distinguished from syn events from a pointing device? Looking at the event codes documentation it doesn't seem like there is a clear delineation between them. 👿 It's never easy.
Yeah, so we're back to the best way seemingly being to just let the real keyboard send the syn events, allow them through, and not to bother with any artificial ones, which... seems to work fine at least 99.9% of the time. And fixes some problems. |
Events originate from a specific device. But in combo devices there isn't that delineation.
No because we sometimes generate events that aren't in line with the keyboard... like if you hit CMD now, but we hit CMD a second later...(with hibernate) so we need the SYN now, not 1 second ago... |
I'm not sure what this is referring to. Like if there is a sleep delay in an output macro? The "real" syn events are often out of order, and almost always come out prior to the transformed EV_KEY events. Yet this doesn't seem to be causing any problems. Can you give me an example of how I can deliberately cause a problematic delay between the real key press and the virtual output? I want to understand this better. Wait, I feel like this should be a problem with long macros, since there is only one "real" combo of keys pressed and then a ton of virtual keystrokes to create the macro output. Yet I have no seen any kind of problem when testing macros like this:
If the code has the artificial sync line blocked, shouldn't there be some sort of problem outputting all this? |
I mean suspend. Where you hit a key but we don't exert it until we know what you're doing - waiting to see if it might be part of a macro that doesn't actually include that key - so we don't "False" press it.
Yes, very strange.
Exactly - and also surprising. |
Yeah, that's the one that usually comes out after the "0, 0, 0" event in the log, instead of before. Suspended keys. Meanwhile the release event syn is typically at the very end of the sequence of events, so maybe that's why it all keeps working. I'm also wondering if the timestamp parts of the event are identical for the EV_KEY and the syn event that comes through before it, so it just ends up not really being an issue. Like out-of-order network packets getting pieced back together in the correct sequence. Or if, again, the syn event from the "release" is what pulls it all out of the fire and makes it appear to work. But press and release are really separate things, which is why the syns are normally needed... trailing off in confusion... 🤷🏽♂️ It's almost like the virtual keyboard keystrokes are somehow creating a syn event for each keystroke anyway, despite the lack of an explicit call. Yet blocking all the real syns without allowing any virtual syn calls definitely causes a huge problem. Macros definitely come out fine without needing another real keystroke to "flush the queue". So... 🤷🏽♂️ 🤷🏽♂️ |
Bad news. Shift-clicking and Cmd-clicking seem to be unreliable with the sync line disabled. Unless the modifier is held for a certain period of time, most likely corresponding to the repeat delay. This is with the suspend time set to zero, so it seems that the modifier key press is not immediately recognized if there is no artificial I wasn't certain what was going on at first, since this isn't the greatest keyboard. I thought maybe I was just not pressing the modifier key solidly enough, because the failure happens intermittently. But the issue goes away when re-activating the sync line. So it seems this is the effect of a missing So this "fix" definitely has a down side. Don't know where to go from here. The dialog focus issue can still be minimized by leaving the suspend time set to zero, or extremely short (0.01s). With the potential issues that implies. |
I'm going to close this PR since, as documented above, it turns out that removing the sync line is an ill-advised solution that makes Mod+clicking unreliable. PR #134 is a much less invasive approach for fixing macro, hotkey and Unicode sequence glitches. Optional and user-guided injection of custom keystroke delays. |
Removing the sync line from the
send_key_action
function fixes problems with macros and Unicode keystroke sequences that fail partway through.This change appears to resolve a long-standing problem with macro keystroke sequences and Unicode keystroke sequences failing partway through in various circumstances.
No negative side effects are known or have yet been observed.