Skip to content
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

Improved key state tracking #16

Closed
wants to merge 2 commits into from
Closed

Improved key state tracking #16

wants to merge 2 commits into from

Conversation

algernon
Copy link
Contributor

This adds the prevLeftKeyStates and prevRightKeyStates arrays, which are used to store the previous state of the matrix. These are then used to determine when a key is released, as opposed to when it is just not pressed. Without these, if we had two or more layer keys, only the last one would work, because the rest would keep getting handled as releases (since we can't make a difference between release and noop, unless we know the previous state).

We could just track layer keys, but there could be any number of them, so it is easier to just save the full matrix state. It's a memcpy of 70 bytes, fairly light.

(As an added bonus, the first commit adds the Mod & Space keys below the bottom row, as they appear on the default layout.)

These are the small keys below the bottom row.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
We need to store the previous state of the keys, to figure out when a specific
key is released, as opposed to simply not being pressed. This is required for
layer keys such as `Mod` and `Fn` to work properly when there are more than one
of them on the keymap.

Without being able to tell when a key is released, we would not be able to turn
a layer off only when no layer key is held. Not easily, anyway: we'd have to
track the state of all layer keys... but then it is easier to just track them
all.

Thankfully, the memcpy at the end is fast, as it only needs to copy 70 bytes.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
@mondalaci
Copy link
Member

Thank you for the PR! Please see my comment in #15.

@algernon
Copy link
Contributor Author

Closing this PR, there's another coming that fixes #17, and includes this one too.

@algernon algernon closed this Dec 12, 2016
@algernon algernon deleted the f/better-state-tracking branch December 12, 2016 19:15
@algernon algernon mentioned this pull request Dec 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants