This mirrors `moveMouse()`, and the intent is to use it when releasing a mouse
key outside of the main event loop (such as during a macro).
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
When using `Kaleidoscope.use()` and the V1 API is disabled, we want to display
an error. The current method of doing that is not reliable, it sometimes works,
sometimes will error out even when not using `Kaleidoscope.use()`. To fix this,
delay the initialisation of `.use()`, so it only evaluates when used, and thus,
only fails with a descriptive error in that case.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
In preparation for the sunset of the V1 API, when using the V2 API only, give a
nice error message on `Kaleidoscope.use()`, instead of simply not defining it.
This makes the upgrade path a little easier.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Instead of iterating through all the bits, use `__builtin_popcountl()`, provided
by gcc, which should be considerably more efficient.
Fixes#27.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
For a while now, Kaleidoscope does nothing if keys are idle. This example relied
on events being fired in the idle case too. So instead of relying on that, move
the holding logic to `loop()`.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
`Consumer_SNapshot` really should have been `Consumer_Snapshot`, so lets fix it.
However, the typo'd name is left in place as an alias, in order to not break any
existing user code, however unlikely the use of this key is.
Sadly, we can't easily add a deprecation warning, because key_defs.h, which
defines `Key`, depends on `key_defs_consumerctl.h`, so we'd end up with a
circular dependency if we tried to add a deprecation.
Fixes#339.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
As per UPGRADE.md, remove `Kaleidoscope.setup(KEYMAP_SIZE)`,
`event_handler_hook_use`, `loop_hook_use`, `USE_PLUGINS`, `MOMENTARY_OFFSET`,
`key_was_pressed`, `key_is_pressed`, `key_toggled_on`, and `key_toggled_off`.
These were deprecated between July and October 2017, and have been marked for
deletion for over a month.
Also updated UPGRADE.md, moving the section about these to a new, "deprecated
and removed" section.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Instead of `getKeyswitchStateAtPosition`, which is long, unintuitive and feels
wrong too, introduce `isKeyswitchPressed`, shorter, better, more
reasonable (because it returns a bool - we support only two states anyway!).
Additionally, add `pressedKeyswitchCount()`, which returns the number of key
switches pressed.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
This is sufficiently low-level that it is OK to use `KeyboardHardware` for it.
It's not a HID thing, either.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Move `KEY_INDEX` here, and turn it into a `constexpr` function, `keyIndex`, and
convert the `RxCy` macros to constexpr values instead.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
To allow the hardware plugin to use a more efficient way of representing the
index (if need be), and to be able to turn it into a constexpr, move it to the
hardware plugin.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
To be used by the hardware implementations, `KEY_INDEX` tells us the index of a
key, from which we can figure out the row and column as needed. The index starts
at one, so that plugins that work with a list of key indexes can use zero as a
sentinel. This is important, because when we initialize arrays with fewer
elements than the declared array size, the remaining elements will be zero. We
can use this to avoid having to explicitly add a sentinel in user-facing code.
Additionally, we add `getKeyswitchStateAtPosition` to the HID facade. See its
documentation in `Kaleidoscope-Hardware`.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Implement `getKeyswitchStateAtPosition`, a hardware-agnostic way to peek into
the keyswitch state. Also transition the `RxCy` macros to `KEY_INDEX`, to make
it easier for hardware with more keys than 64 to implement them, and to make
their values unique across a keyboard, not just across a keyboard half.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Instead of only having an ifdef in the body of deprecated methods, and leaving
it up to the compiler to optimize out the empty & unused, explicitly wrap the
declaration of them within an ifdef too. This will make it easier to remove
everything V1 at a later point, and we're not at the mercy of the compiler,
either.
Fixes#327.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
We do not want user code having to deal with KeyboardHardware, so wrap
.detachFromHost and .attachToHost ourselves.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
These functions can be used to detach from the host, then re-attach, possibly
with different properties, without having to reboot the device.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Instead of using a lambda (which is not constexpr in C++11), use a temporary,
anonymous struct instance to wrap the `static_assert`, which is constexpr in
C++11.
Fixeskeyboardio/Model01-Firmware#53. Thanks to @noseglasses for finding the
cause, and explaining the fix!
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Many plugins use timers, and most of them will call `millis()`, which isn't
wrong, but isn't the most efficient either. While `millis()` isn't terribly
expensive, it's not cheap either. For most cases, we do not need an exact timer,
and one updated once per cycle is enough - which is what `.millisAtCycleStart()`
is. Having a timer that is consistent throughout the whole cycle may also be
beneficial.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Use ./_build/ for the build path by default, and do not delete it at the end of
compilation, only when doing a clean.
Fixes#315.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>
Instead of hardcoding the max program size, pick it out of boards.txt, like we
pick the device VID and PID.
Signed-off-by: Gergely Nagy <algernon@keyboard.io>