Introduces the RESERVED bit, a bit reserved for plugins. If it is set, the core
handlers will not handle the event.
Also rearranges the SYNTHETIC bits, to make slightly more sense. In practice,
this means that LED_TOGGLE was promoted to a flag bit, under IS_INTERNAL.
The handler that deals with synthetic events was updated to look at the flag
bits in an order that does not cause confusion, and preparations were also made
to turn it into an independent handler on its own (but that step has not been
taken yet).
This is just groundwork to clean things up, and make the event flow easier to
follow.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
The mousekey handler was way too eager, and captured events that were not meant
to be handled by it, like the `a` key. This has been fixed by removing the
`KEY_MOUSE_CENTER` bit, and replacing it with `KEY_MOUSE_BUTTON`. That way,
everything fits into the `IS_MOUSE_KEY` flag bit.
While there, also fixed the id of the right mouse button.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
We can't register hooks from constructors, because there is no guaranteed order
in which the objects will be created. So it may well happen that the Keyboardio
object gets created later, and zeroes out everything. Or it gets created first,
and registers the default handler as the first one, making all the others
pointless.
Instead, we create a KeyboardioPlugin class, that has a `begin` method. This is
responsible for setting up the hooks and whatnot. To make things simpler (for
some values of simple), a `Keyboardio.use` method is introduced, which, when
given a NULL-terminated list of plugin object pointers, will call the begin
method of each.
All LED effects and other plugins that used to register a static object now use
an extern, and had their initialization moved to the `begin` method.
The end result is not the nicest thing, but it works. We can try figuring out
something nicer later.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Instead of including `key_defs.h`, include `KeyboardioFirmware.h` in
`Keyboardio-MouseKeys.h`, so that the dependency is clear. This is
needed for the arduino-builder to arrange the linking order properly
when using KeyboardioFirmware, KeyboardioFirmware-MouseKeys and other
libraries combined. It does not affect the combination of just the two,
but if there's a third, that happens to include `KeyboardioFirmware.h`
too, this dependency is required for correct linking.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
When we mark a symbol extern, but do not reference it anywhere else
directly, it will not be compiled in when using dot_a_linkage. For this
reason, make MouseKeys a static variable instead of extern.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
The reason it was removed before no longer applies, and enabling it saves
noticeable amounts of size when using KeyboardioFirmware as a library.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Instead of having a previousState and a currentState, of which at most
two bits are used, use a single byte. This saves us a lot of code space,
and makes a number of things easier, too.
The helpers were redone as macros, since they are just bit checks now.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
The mousekeys are not specific to the Model01, name it after Keyboardio
instead, as suggested by @obra.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>