Add an optional Focus hook

Fixes #4.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 8 years ago
parent 6b2263cfa7
commit 407a30f5fd

@ -108,6 +108,15 @@ The plugin provides the `EEPROMKeymapProgrammer` object, which has the following
>
> Defaults to `kaleidoscope::EEPROMKeymapProgrammer::CODE`.
## Focus commands
The plugin provides a single `Focus` hook: `FOCUS_HOOK_KEYMAP_PROGRAMMER`, which
in turn provides the following command:
### `keymap.toggleProgrammer`
> Toggles the programmer mode on or off.
## Dependencies
* [Kaleidoscope-EEPROM-Keymap][plugin:eeprom-keymap]

@ -101,6 +101,18 @@ Key EEPROMKeymapProgrammer::eventHandlerHook(Key mapped_key, byte row, byte col,
return Key_NoKey;
}
bool EEPROMKeymapProgrammer::focusHook(const char *command) {
if (strcmp_P(command, PSTR("keymap.toggleProgrammer")) != 0)
return false;
if (state_ == INACTIVE)
activate();
else
cancel();
return true;
}
}
kaleidoscope::EEPROMKeymapProgrammer EEPROMKeymapProgrammer;

@ -34,10 +34,14 @@ class EEPROMKeymapProgrammer : public KaleidoscopePlugin {
void begin(void) final;
static void activate(void) { nextState(); }
static void activate(void) {
nextState();
}
static void nextState(void);
static void cancel(void);
static bool focusHook(const char *command);
private:
typedef enum {
INACTIVE,
@ -55,3 +59,6 @@ class EEPROMKeymapProgrammer : public KaleidoscopePlugin {
}
extern kaleidoscope::EEPROMKeymapProgrammer EEPROMKeymapProgrammer;
#define FOCUS_HOOK_KEYMAP_PROGRAMMER FOCUS_HOOK(EEPROMKeymapProgrammer.focusHook, \
"keymap.toggleProgrammer")

Loading…
Cancel
Save