First of all, to disallow switching to LEDNumlock, we need to do the check in
the `.init()` method, not in `.setup()`. Second, tracking the previous LED mode
can be done a lot simpler - and a lot reliably.
With these changes, the NumLock LED effect works as it is expected to.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
When toggling a layer, the same keycode should toggle the layer off, too.
Without this, toggling layers won't work at all, because the target layer will
never be turned off.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Turn the `event_handler_hook_add` and `loop_hook_add` aliases into real
functions, that emit a deprecation warning during compilation. This makes it a
little bit easier to see what needs to be updated still.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
In most cases, one only wants a single copy of a hook. On the other hand,
plugins that depend on other plugins, may want to make it easier for the
end-user to use the plugin, and call the setup function of the dependent plugins
too. In case the end-user calls the same setup function, we'd end up with hooks
registered multiple times.
To avoid this, protection against double-registration has been introduced. The
new `event_handler_hook_use` and `loop_hook_use` functions will only allow one
copy of the hook. The `event_handler_hook_append` and `loop_hook_append`
functions will, on the other hand, just append the hooks, and not care about
protection.
The `event_handler_hook_add` and `loop_hook_add` functions are gone, but for the
time being, they are aliases to the `_use` functions, until all plugins have
been updated, and the aliases can be removed.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
The example does not use LEDs, drop the key, lest we'd need to pull in the
Keyboardio-LEDControl plugin, too.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Moves the LED control code, along with the built-in effects into the
Keyboardio-LEDControl plugin.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This is a slightly tweaked version of LEDControl from core
KeyboardioFirmware, along with the built-in LED effects.
The one major change is that LED sync is now called just before the update,
instead of at the end of the main loop. This, however, should not be a
noticeable change.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
When a key interrupts the one-shot, mask the position out until a key release.
This is needed, because even a short tap usually results in a short hold, which
in turn - without the mask - handles the key.
Instead, we now mask the position out until it is released, so no such problems
arise. Fixes#4.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
I forgot to update the `LCTRL`, `LALT`, etc macros, and they still assumed the
previous order. This little patch fixes that.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
We want to treat the one-shot keys as active even when they were interrupted -
as long as their state is not cleared. This is because when using isActive from
another plugin, or macro, that is usually in response to a key press that
already sets up `shouldCancel` - yet, the modifier is technically active still!
So `isActive` does not check the to-be-cancelled flag anymore. This makes the
Escape-OneShot plugin much more reliable as a consequence.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Useful when writing an event handler that needs to check if a modifier is
active, but may run before OneShot has a chance to re-register the given
modifier.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>