Based on #306, with slightly improved text. Thanks to Ross Donaldson
(@Gastove) for the original pull request!
Closes#306.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Since keyboardio/Kaleidoscope-Hardware-Model01#23 we do not call
`handleKeyswitchEvent` for keys that are idle. Document this in the comments.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
When a keyswitch has been off in the previous cycle and is still off now, do not
call `handleKeyswitchEvent` on it. As an extension, when the whole column is
idle, skip the whole thing.
In practice, handling fully idle keys is not useful. There are many plugins
which explicitly look for this case and return early, because it isn't an
interesting event. As such, not calling the event handler in this case makes
sense, as we save not only a few needless checks in plugins, but our performance
improves greatly too.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
In `actOnMatrixScan`, there is no need to use temporary variables, we can just
pass the data directly to `actOnHalfRow`, and doing so makes the code easier to
follow.
In `actOnHalfRow`, we can further optimize things if instead of reading the Nth
bit, we always read the first, and shift the byte at the end.
All of these optimizations were done by @obra, I just wrote the commit message.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
When there are no state changes, and no keys pressed on a row, instead of
iterating through a byte bit-by-bit, just fire idle events without checking the
bits. In all other cases, do the bit-walking like we did before.
The reason this is useful is because bit-walking is costly, and slow. If we can
avoid that, we win quite a lot of performance. Since rows being idle is the most
common case on a keyboard, this is a huge net win. Even in the worst case, where
no rows are idle, this is just one byte comparison and a branch slower than our
previous implementation.
As part of this optimization, `actOnHalfRow` was lifted out into its own
function, to reduce code duplication.
Many thanks to @gedankenexperimenter for the original idea!
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
There are a number of false-positives, where ShellCheck warns about behaviour we
do want, or are otherwise intentional.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
If the user has missed the step about setting up their account
with the right group membership, they would get a cryptic failure
from stty, so catch this and explain the problem.
This should never happen, but could if something goes badly wrong
in the device detection code, e.g. someone changing it in a way
which caused extra output on STDOUT.
7bd2e9fbb7/udev/99-hdmi2usb-mm-blacklist.rules (L4)
says:
It should be enough to set ID_MM_DEVICE_IGNORE:="1" but it seems many
versions of modem manager have a bug which makes them ignore that value.
Setting ID_MM_CANDIDATE:="0" has the same effect but is an "internal
implementation detail" of modem manager.
so set both to be safe. Also use := rather than =, in order to prevent
any later rules from overriding the settings.
Further testing suggests that macOS unconditionally replaces the final character with a
`1` (I tested with `kbio02` as the device short name, which became the "Serial Number"
`CDkbio02`, and it got changed to `CDkbio01` in the filename). This change will try
looking for any file that matches the serial number with the final character replaced with
"1" (not just if that charater is "E"). I also added some comments that might help update
the script in the future if the OS changes behaviour.
Several people have reported difficulty flashing firmware on macOS High Sierra because the
device port filename doesn't match the serial number from system_profiler. In particular,
system_profiler would return a string ending in `E` whereas the device filename would have
a `1`. This change adds a check for that filename explictily.
I also corrected the location_id fallback (the substring should have been just 3
characters long, not 4), and it works properly on my system if I make the device shortname
7 characters long, and the filename reverts to using the location id instead.
Last, I added one more check, simply listing the filenames, and searching for a match for
the string `kbio01`, which should be present (although in one case, it wasn't).
It's easier for most people to interpret numbers in decimal than hexadecimal; adding this
option to avr-nm prints out the sizes in the size_map in a more intuitive format.
These macros were copied and pasted, I'm guessing from the USB HID Usage Tables document,
where this keycode is identified with a parenthetical, unlike all of the others around it:
`AC Download (Save Target As)`. When automatically converted into a preprocessor macro, it
gets a trailing underscore and an argument, which is not what we want.
This change won't actually fix anything that's currently broken, but it might matter
someday.