Instead of a single custom function, have an array of functions that get
called in order, until one of them returns true. Defaults to the normal
event handler.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Instead of always calling handle_user_key_event(), call a function
pointed to by the customHandler variable. This makes it possible to
override what function gets called, at run time, at very little cost.
The reason for this change is to be able to change the user function
into a testing one, if a magic combo is pressed, while still allowing
the end-user to fully customize handle_user_key_event, and allow them to
have access to the testing one too, without them doing anything special.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This allows external libraries to look up the keycode for a given
position, without having to reimplement the keymap themselves. This
becomes important when you hook into the event processing.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This adds a new `handle_user_key_event` function, that will get called
before anything else, and can override what happens. If it returns true,
the event will not be processed further by the firmware. By default,
this function returns false, and is a no-op.
It is defined with a `weak` attribute, to let the linker know that any
other function with the same name should override his one. This makes it
possible to have another version of this function in a firmware Sketch,
and override the behaviour, to extend the event handling.
This is the foundation that allows it to use external libraries, and tap
into the firmware's event handler, to add new stuff. (We can already
hook into the main loop by changing the top `loop` function in the
Sketch)
This addresses #21 for the most part.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>