This lets us remove some awkward code from `handleKeyswitchEvent()`, because as
long as the default value (which triggers a keymap lookup) was the same as
`Key_Masked`, it wasn't sufficient for an `onKeyswitchEvent()` handler to change
`event.key` to `Key_Masked`, because that would be interpreted by
`handleKeyEvent()` as a signal to do a keymap lookup.
This also makes it more consistent with other parts of the code. The values
`Key_Undefined`, `Key_Inactive`, and `Key_Transparent` are all the same, and
with this change they are each interpreted the same way by code that encounters
them. In a keymap lookup, if an active layer has a `Key_Transparent` value, we
continue searching for a different value on another layer. In the live keys
array, if we find a `Key_Inactive` entry, we look for a value from the keymap.
And with this change, when processing a key event, if it has a `Key_Undefined`
value, we look for a value from `active_keys` (and then from the keymap layers,
if nothing is found there).
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
To allow us to use any other HID than KeyboardioHID, the base device _must_ use
something else (practically, the Base HID), otherwise we'll get a compile error
when building on a platform that KeyboardioHID does not support, even if we do
not use KeyboardioHID. We get that error, because the base class references it
anyway.
As such, lets use the base HID as default, and adjust all users of KeyboardioHID
to explicitly set that: Virtual, Dygma Raise, and ATmega32U4Keyboard. Everything
else derives from the last one, so they're covered with just the change to
ATmega32U4Keyboard.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
If `HID_BOOT_PROTOCOL` is undefined, define it ourselves (the value is set by
the USB standard, so we can do that). This allows compiling the base class
without KeyboardioHID, letting our HID base driver be completely independent of
it.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
This function is completely unused, and should not have been exposed to begin
with. Neither in the base class, nor in specific implementations.
The `getReport()` method ties us to a specific report datatype, both in name,
and in shape. That's not something we want, we'd rather have the base class be
HID-library agnostic, which it can't be with `getReport()` present.
Luckily, the function is completely unused, and as such, is safe to remove
without deprecation.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Instead of doing the stop in the base class, delegate it to the specific
implementation. Do this to avoid depending on the exact shape and layout of the
mouse report within the base class.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
We do not need to redefine `new` on STM32, as it is included in the standard
library, and defining it ourselves would lead to linking errors.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Other parts of Kaleidoscope require the NKRO and Boot keyboard classes to have
an `isKeyPressed()` method, which our base classes did not provide - until now.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
The `layer_state_` bitfield is no longer necessary now that we have
activation-order layers. Removing it reduces clutter and saves a modicum of
PROGMEM & RAM.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
This event handler is useful for plugins that need to react to events, but
should wait until after those events are fully processed before doing so. This
is useful for OneShot, which needs to keep keys active until after events that
trigger their release. The `afterEachCycle()` hook is unfortunately
insufficient for this purpose, because the same event could trigger multiple
plugins (e.g. TapDance & OneShot) to resolve events, and the OneShot should
apply only to the first ensuing report.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
This fixes a problem with a plugin that returns `ABORT` from its
`onKeyswitchEvent()` handler, for a masked key addr. I'm convinced that a
better solution is to switch from using `Key_NoKey` (a.k.a. `Key_Masked`) to
using `Key_Transparent` as the default for new events, and thus, the value that
signals that a lookup should be done, but this at least fixes the bug for now,
with a much less intrusive change.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
`Runtime.hasTimeExpired()` had a minor flaw. Because it was comparing two values
using `>` instead of `>=`, it meant that a timeout set at 20ms wouldn't actually
time out until 21ms elapsed.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
This allows plugins to override the current LED mode just before the LED sync is
done (i.e. after the mode sets the LED colors, but before those changes are
pushed to the hardware.)
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
This class should help plugins that implement `onKeyswitchEvent()` to ensure
that they won't process the same event more than once.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
There's no need to trigger a keyboard HID report after processing a layer
change, so stop processing before calling `prepareKeyboardReport()` if
`event.key` is a layer change `Key`.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
The new version of the layer change `Key` handler is more consistent with the
other `KeyEvent` handling functions, and properly checks for a second layer
shift key being held when releasing the first one.
Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>