New hook: onNameQuery()

This implements a new `FocusSerial` command: `plugins`. The `plugins` command
will reply back with a list of plugins enabled in the firmware. The list is not
exhaustive, only plugins that opt-in to this mechanism will be listed. It is
opt-in, because for a lot of plugins, having them listed isn't useful in a
practical sense.

The goal with this feature is to allow Chrysalis to detect plugins that would
affect what keys it offers, or which additional settings it displays, and do so
in a consistent way. This is why IdleLEDs has an `onNameQuery` handler too, even
though it can be detected otherwise: for consistency.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/1027/head
Gergely Nagy 4 years ago
parent ac187fb016
commit fc1296395e
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -101,6 +101,7 @@ In practice, this boils down to implementing one or more of the following hook p
- `beforeEachCycle()`: Called once, at the beginning of each cycle of the main loop. This is similar to the old "loop hook" with its `post_clear` argument set to false. Takes no arguments, must return `kaleidoscope::EventHandlerResult::OK`. - `beforeEachCycle()`: Called once, at the beginning of each cycle of the main loop. This is similar to the old "loop hook" with its `post_clear` argument set to false. Takes no arguments, must return `kaleidoscope::EventHandlerResult::OK`.
- `onKeyswitchEvent`: Called for every non-idle key event. This replaces the old "event handler hook". It takes a key reference, a key address, and a key state. The key reference can be updated to change the key being processed, so that any plugin that processes it further, will see the updated key. Can return `kaleidoscope::EventHandlerResult::OK` to let other plugins process the event further, or `kaleidoscope::EventHandlerResult::EVENT_CONSUMED` to stop processing. - `onKeyswitchEvent`: Called for every non-idle key event. This replaces the old "event handler hook". It takes a key reference, a key address, and a key state. The key reference can be updated to change the key being processed, so that any plugin that processes it further, will see the updated key. Can return `kaleidoscope::EventHandlerResult::OK` to let other plugins process the event further, or `kaleidoscope::EventHandlerResult::EVENT_CONSUMED` to stop processing.
- `onFocusEvent`: Used to implement [bi-directional communication](#bidirectional-communication-for-plugins). This is called whenever the firmware receives a command from the host. The only argument is the command name. Can return `kaleidoscope::EventHandlerResult::OK` to let other plugins process the event further, or `kaleidoscope::EventHandlerResult::EVENT_CONSUMED` to stop processing. - `onFocusEvent`: Used to implement [bi-directional communication](#bidirectional-communication-for-plugins). This is called whenever the firmware receives a command from the host. The only argument is the command name. Can return `kaleidoscope::EventHandlerResult::OK` to let other plugins process the event further, or `kaleidoscope::EventHandlerResult::EVENT_CONSUMED` to stop processing.
- `onNameQuery`: Used by the [Focus](#bidirecional-communication-for-plugins) plugin, when replying to a `plugins` command. Should either send the plugin name, or not be implemented at all, if the host knowing about the plugin isn't important.
- `beforeReportingState`: Called without arguments, just before sending the keyboard and mouse reports to the host. Must return `kaleidoscope::EventHandlerResult::OK`. - `beforeReportingState`: Called without arguments, just before sending the keyboard and mouse reports to the host. Must return `kaleidoscope::EventHandlerResult::OK`.
- `afterEachCycle`: Called without arguments at the very end of each cycle. This is the replacement for the "loop hook" with its `post_clear` argument set. - `afterEachCycle`: Called without arguments at the very end of each cycle. This is the replacement for the "loop hook" with its `post_clear` argument set.
@ -160,6 +161,10 @@ class FocusExampleCommand : public Plugin {
public: public:
FocusExampleCommand() {} FocusExampleCommand() {}
EventHandlerResult onNameQuery() {
return ::Focus.sendName(F("FocusExampleCommand"));
}
EventHandlerResult onFocusEvent(const char *command) { EventHandlerResult onFocusEvent(const char *command) {
if (strcmp_P(command, PSTR("example")) != 0) if (strcmp_P(command, PSTR("example")) != 0)
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Colormap -- Per-layer colormap effect * Kaleidoscope-Colormap -- Per-layer colormap effect
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016, 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under it under * This program is free software: you can redistribute it and/or modify it under it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -36,6 +36,10 @@ void ColormapEffect::max_layers(uint8_t max_) {
map_base_ = ::LEDPaletteTheme.reserveThemes(max_layers_); map_base_ = ::LEDPaletteTheme.reserveThemes(max_layers_);
} }
EventHandlerResult ColormapEffect::onNameQuery() {
return ::Focus.sendName(F("ColormapEffect"));
}
void ColormapEffect::TransientLEDMode::onActivate(void) { void ColormapEffect::TransientLEDMode::onActivate(void) {
if (!Runtime.has_leds) if (!Runtime.has_leds)
return; return;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Colormap -- Per-layer colormap effect * Kaleidoscope-Colormap -- Per-layer colormap effect
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016, 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under it under * This program is free software: you can redistribute it and/or modify it under it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -31,6 +31,7 @@ class ColormapEffect : public Plugin,
void max_layers(uint8_t max_); void max_layers(uint8_t max_);
EventHandlerResult onLayerChange(); EventHandlerResult onLayerChange();
EventHandlerResult onNameQuery();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
// This class' instance has dynamic lifetime // This class' instance has dynamic lifetime

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Cycle -- Key sequence cycling dead key for Kaleidoscope. * Kaleidoscope-Cycle -- Key sequence cycling dead key for Kaleidoscope.
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016, 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -17,6 +17,7 @@
#include "kaleidoscope/Runtime.h" #include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-Cycle.h> #include <Kaleidoscope-Cycle.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -52,6 +53,10 @@ void Cycle::replace(uint8_t cycle_size, const Key cycle_steps[]) {
// --- hooks --- // --- hooks ---
EventHandlerResult Cycle::onNameQuery() {
return ::Focus.sendName(F("Cycle"));
}
EventHandlerResult Cycle::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) { EventHandlerResult Cycle::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) {
if (key_state & INJECTED) if (key_state & INJECTED)
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Cycle -- Key sequence cycling dead key for Kaleidoscope. * Kaleidoscope-Cycle -- Key sequence cycling dead key for Kaleidoscope.
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016, 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -36,6 +36,7 @@ class Cycle : public kaleidoscope::Plugin {
static void replace(Key key); static void replace(Key key);
static void replace(uint8_t cycle_size, const Key cycle_steps[]); static void replace(uint8_t cycle_size, const Key cycle_steps[]);
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
private: private:

@ -1,5 +1,5 @@
/* DynamicMacros - Dynamic macro support for Kaleidoscope. /* DynamicMacros - Dynamic macro support for Kaleidoscope.
* Copyright (C) 2019 Keyboard.io, Inc. * Copyright (C) 2019, 2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -208,6 +208,10 @@ EventHandlerResult DynamicMacros::onKeyswitchEvent(Key &mappedKey, KeyAddr key_a
return EventHandlerResult::EVENT_CONSUMED; return EventHandlerResult::EVENT_CONSUMED;
} }
EventHandlerResult DynamicMacros::onNameQuery() {
return ::Focus.sendName(F("DynamicMacros"));
}
EventHandlerResult DynamicMacros::onFocusEvent(const char *command) { EventHandlerResult DynamicMacros::onFocusEvent(const char *command) {
if (::Focus.handleHelp(command, PSTR("macros.map\nmacros.trigger"))) if (::Focus.handleHelp(command, PSTR("macros.map\nmacros.trigger")))
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,5 +1,5 @@
/* DynamicMacros - Dynamic macro support for Kaleidoscope. /* DynamicMacros - Dynamic macro support for Kaleidoscope.
* Copyright (C) 2019 Keyboard.io, Inc. * Copyright (C) 2019, 2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -32,6 +32,7 @@ class DynamicMacros : public kaleidoscope::Plugin {
DynamicMacros(void) {} DynamicMacros(void) {}
EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState);
EventHandlerResult onNameQuery();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
static void reserve_storage(uint16_t size); static void reserve_storage(uint16_t size);

@ -1,5 +1,5 @@
/* DynamicTapDance -- Dynamic TapDance support for Kaleidoscope /* DynamicTapDance -- Dynamic TapDance support for Kaleidoscope
* Copyright (C) 2019 Keyboard.io, Inc * Copyright (C) 2019, 2021 Keyboard.io, Inc
* Copyright (C) 2019 Dygma Lab S.L. * Copyright (C) 2019 Dygma Lab S.L.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -86,6 +86,10 @@ bool DynamicTapDance::dance(uint8_t tap_dance_index, KeyAddr key_addr,
return true; return true;
} }
EventHandlerResult DynamicTapDance::onNameQuery() {
return ::Focus.sendName(F("DynamicTapDance"));
}
EventHandlerResult DynamicTapDance::onFocusEvent(const char *command) { EventHandlerResult DynamicTapDance::onFocusEvent(const char *command) {
if (::Focus.handleHelp(command, PSTR("tapdance.map"))) if (::Focus.handleHelp(command, PSTR("tapdance.map")))
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,5 +1,5 @@
/* DynamicTapDance -- Dynamic TapDance support for Kaleidoscope /* DynamicTapDance -- Dynamic TapDance support for Kaleidoscope
* Copyright (C) 2019 Keyboard.io, Inc * Copyright (C) 2019, 2021 Keyboard.io, Inc
* Copyright (C) 2019 Dygma Lab S.L. * Copyright (C) 2019 Dygma Lab S.L.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -27,6 +27,7 @@ class DynamicTapDance: public kaleidoscope::Plugin {
public: public:
DynamicTapDance() {} DynamicTapDance() {}
EventHandlerResult onNameQuery();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
static void setup(uint8_t dynamic_offset, uint16_t size); static void setup(uint8_t dynamic_offset, uint16_t size);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-EEPROM-Keymap -- EEPROM-based keymap support. * Kaleidoscope-EEPROM-Keymap -- EEPROM-based keymap support.
* Copyright (C) 2017, 2018, 2019 Keyboard.io, Inc * Copyright (C) 2017, 2018, 2019, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -32,6 +32,10 @@ EventHandlerResult EEPROMKeymap::onSetup() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
EventHandlerResult EEPROMKeymap::onNameQuery() {
return ::Focus.sendName(F("EEPROMKeymap"));
}
void EEPROMKeymap::setup(uint8_t max) { void EEPROMKeymap::setup(uint8_t max) {
layer_count = max; layer_count = max;
if (::EEPROMSettings.ignoreHardcodedLayers()) { if (::EEPROMSettings.ignoreHardcodedLayers()) {

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-EEPROM-Keymap -- EEPROM-based keymap support. * Kaleidoscope-EEPROM-Keymap -- EEPROM-based keymap support.
* Copyright (C) 2017, 2018, 2019 Keyboard.io, Inc * Copyright (C) 2017, 2018, 2019, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -32,6 +32,7 @@ class EEPROMKeymap : public kaleidoscope::Plugin {
EEPROMKeymap(void) {} EEPROMKeymap(void) {}
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onNameQuery();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
static void setup(uint8_t max); static void setup(uint8_t max);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-FingerPainter -- On-the-fly keyboard painting. * Kaleidoscope-FingerPainter -- On-the-fly keyboard painting.
* Copyright (C) 2017, 2018 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -29,6 +29,10 @@ namespace plugin {
uint16_t FingerPainter::color_base_; uint16_t FingerPainter::color_base_;
bool FingerPainter::edit_mode_; bool FingerPainter::edit_mode_;
EventHandlerResult FingerPainter::onNameQuery() {
return ::Focus.sendName(F("FingerPainter"));
}
EventHandlerResult FingerPainter::onSetup() { EventHandlerResult FingerPainter::onSetup() {
color_base_ = ::LEDPaletteTheme.reserveThemes(1); color_base_ = ::LEDPaletteTheme.reserveThemes(1);
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-FingerPainter -- On-the-fly keyboard painting. * Kaleidoscope-FingerPainter -- On-the-fly keyboard painting.
* Copyright (C) 2017, 2018 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -35,6 +35,7 @@ class FingerPainter : public LEDMode {
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onNameQuery();
protected: protected:
void update(void) final; void update(void) final;

@ -22,6 +22,10 @@ class FocusTestCommand : public Plugin {
public: public:
FocusTestCommand() {} FocusTestCommand() {}
EventHandlerResult onNameQuery() {
return ::Focus.sendName(F("FocusTestCommand"));
}
EventHandlerResult onFocusEvent(const char *command) { EventHandlerResult onFocusEvent(const char *command) {
if (strcmp_P(command, PSTR("test")) != 0) if (strcmp_P(command, PSTR("test")) != 0)
return EventHandlerResult::OK; return EventHandlerResult::OK;
@ -52,6 +56,13 @@ Sends a list of variables over the wire. The difference between `.send()` and `.
Both of them take a variable number of arguments, of almost any type: all built-in types can be sent, `cRGB`, `Key` and `bool` too in addition. For colors, `.send()` will write them as an `R G B` sequence; `Key` objects will be sent as the raw 16-bit keycode; and `bool` will be sent as either the string `true`, or `false`. Both of them take a variable number of arguments, of almost any type: all built-in types can be sent, `cRGB`, `Key` and `bool` too in addition. For colors, `.send()` will write them as an `R G B` sequence; `Key` objects will be sent as the raw 16-bit keycode; and `bool` will be sent as either the string `true`, or `false`.
### `.sendName(F("..."))`
To be used with the `onNameQuery()` hook, this sends the plugin name given,
followed by a newline, and returns `EventHandlerResult::OK`, so that
`onNameQuery()` hooks can be implemented in a single line with the help of this
function.
### `.read(variable)` ### `.read(variable)`
Depending on the type of the variable passed by reference, reads a 8 or 16-bit unsigned integer, a `Key`, or a `cRGB` color from the wire, into the variable passed as the argument. Depending on the type of the variable passed by reference, reads a 8 or 16-bit unsigned integer, a `Key`, or a `cRGB` color from the wire, into the variable passed as the argument.

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-FocusSerial -- Bidirectional communication plugin * Kaleidoscope-FocusSerial -- Bidirectional communication plugin
* Copyright (C) 2017, 2018 Keyboard.io, Inc * Copyright (C) 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -70,7 +70,14 @@ bool FocusSerial::handleHelp(const char *command,
} }
EventHandlerResult FocusSerial::onFocusEvent(const char *command) { EventHandlerResult FocusSerial::onFocusEvent(const char *command) {
handleHelp(command, PSTR("help")); if (handleHelp(command, PSTR("help\nplugins")))
return EventHandlerResult::OK;
if (strcmp_P(command, PSTR("plugins")) == 0) {
kaleidoscope::Hooks::onNameQuery();
return EventHandlerResult::EVENT_CONSUMED;
}
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-FocusSerial -- Bidirectional communication plugin * Kaleidoscope-FocusSerial -- Bidirectional communication plugin
* Copyright (C) 2017, 2018 Keyboard.io, Inc * Copyright (C) 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -28,6 +28,12 @@ class FocusSerial : public kaleidoscope::Plugin {
bool handleHelp(const char *command, bool handleHelp(const char *command,
const char *help_message); const char *help_message);
EventHandlerResult sendName(const __FlashStringHelper *name) {
Runtime.serialPort().print(name);
Runtime.serialPort().print(NEWLINE);
return EventHandlerResult::OK;
}
void send() {} void send() {}
void send(const cRGB color) { void send(const cRGB color) {
send(color.r, color.g, color.b); send(color.r, color.g, color.b);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Idle-LEDs -- Turn off the LEDs when the keyboard's idle * Kaleidoscope-Idle-LEDs -- Turn off the LEDs when the keyboard's idle
* Copyright (C) 2018, 2019, 2020 Keyboard.io, Inc * Copyright (C) 2018, 2019, 2020, 2021 Keyboard.io, Inc
* Copyright (C) 2019 Dygma, Inc * Copyright (C) 2019 Dygma, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -63,6 +63,10 @@ EventHandlerResult IdleLEDs::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr,
uint16_t PersistentIdleLEDs::settings_base_; uint16_t PersistentIdleLEDs::settings_base_;
EventHandlerResult PersistentIdleLEDs::onNameQuery() {
return ::Focus.sendName(F("PersistentIdleLEDs"));
}
EventHandlerResult PersistentIdleLEDs::onSetup() { EventHandlerResult PersistentIdleLEDs::onSetup() {
settings_base_ = ::EEPROMSettings.requestSlice(sizeof(uint16_t)); settings_base_ = ::EEPROMSettings.requestSlice(sizeof(uint16_t));

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Idle-LEDs -- Turn off the LEDs when the keyboard's idle * Kaleidoscope-Idle-LEDs -- Turn off the LEDs when the keyboard's idle
* Copyright (C) 2018, 2019 Keyboard.io, Inc * Copyright (C) 2018, 2019, 2021 Keyboard.io, Inc
* Copyright (C) 2019 Dygma, Inc * Copyright (C) 2019 Dygma, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -43,6 +43,7 @@ class IdleLEDs: public kaleidoscope::Plugin {
class PersistentIdleLEDs : public IdleLEDs { class PersistentIdleLEDs : public IdleLEDs {
public: public:
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onNameQuery();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
static void setIdleTimeoutSeconds(uint32_t new_limit); static void setIdleTimeoutSeconds(uint32_t new_limit);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-LayerFocus -- Focus commands to work with layers * Kaleidoscope-LayerFocus -- Focus commands to work with layers
* Copyright (C) 2020 Keyboard.io, Inc * Copyright (C) 2020, 2021 Keyboard.io, Inc
* Copyright (C) 2020 DygmaLab, SE. * Copyright (C) 2020 DygmaLab, SE.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -24,6 +24,10 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
EventHandlerResult LayerFocus::onNameQuery() {
return ::Focus.sendName(F("LayerFocus"));
}
EventHandlerResult LayerFocus::onFocusEvent(const char *command) { EventHandlerResult LayerFocus::onFocusEvent(const char *command) {
if (::Focus.handleHelp(command, PSTR("layer.activate\nlayer.deactivate\nlayer.isActive" if (::Focus.handleHelp(command, PSTR("layer.activate\nlayer.deactivate\nlayer.isActive"
"\nlayer.moveTo\nlayer.state"))) "\nlayer.moveTo\nlayer.state")))

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-LayerFocus -- Focus commands to work with layers * Kaleidoscope-LayerFocus -- Focus commands to work with layers
* Copyright (C) 2020 Keyboard.io, Inc * Copyright (C) 2020, 2021 Keyboard.io, Inc
* Copyright (C) 2020 DygmaLab, SE. * Copyright (C) 2020 DygmaLab, SE.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -27,6 +27,7 @@ class LayerFocus: public kaleidoscope::Plugin {
public: public:
LayerFocus() {} LayerFocus() {}
EventHandlerResult onNameQuery();
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
}; };

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Leader -- VIM-style leader keys * Kaleidoscope-Leader -- VIM-style leader keys
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016, 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-Leader.h> #include <Kaleidoscope-Leader.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -85,6 +86,10 @@ void Leader::inject(Key key, uint8_t key_state) {
} }
// --- hooks --- // --- hooks ---
EventHandlerResult Leader::onNameQuery() {
return ::Focus.sendName(F("Leader"));
}
EventHandlerResult Leader::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) { EventHandlerResult Leader::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) {
if (keyState & INJECTED) if (keyState & INJECTED)
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Leader -- VIM-style leader keys * Kaleidoscope-Leader -- VIM-style leader keys
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016, 2017, 2018, 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -46,6 +46,7 @@ class Leader : public kaleidoscope::Plugin {
void inject(Key key, uint8_t key_state); void inject(Key key, uint8_t key_state);
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState);
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();

@ -1,5 +1,5 @@
/* Kaleidoscope-Macros - Macro keys for Kaleidoscope. /* Kaleidoscope-Macros - Macro keys for Kaleidoscope.
* Copyright (C) 2017-2019 Keyboard.io, Inc. * Copyright (C) 2017-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -15,6 +15,7 @@
*/ */
#include "Kaleidoscope-Macros.h" #include "Kaleidoscope-Macros.h"
#include "Kaleidoscope-FocusSerial.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -249,6 +250,10 @@ bool Macros_::isMacroKey(Key key) {
return false; return false;
} }
EventHandlerResult Macros_::onNameQuery() {
return ::Focus.sendName(F("Macros"));
}
EventHandlerResult Macros_::onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState) { EventHandlerResult Macros_::onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState) {
if (! isMacroKey(mappedKey)) if (! isMacroKey(mappedKey))
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,5 +1,5 @@
/* Kaleidoscope-Macros - Macro keys for Kaleidoscope. /* Kaleidoscope-Macros - Macro keys for Kaleidoscope.
* Copyright (C) 2017-2018 Keyboard.io, Inc. * Copyright (C) 2017-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -55,6 +55,7 @@ class Macros_ : public kaleidoscope::Plugin {
++active_macro_count; ++active_macro_count;
} }
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState);
EventHandlerResult beforeReportingState(); EventHandlerResult beforeReportingState();
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MagicCombo -- Magic combo framework * Kaleidoscope-MagicCombo -- Magic combo framework
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-MagicCombo.h> #include <Kaleidoscope-MagicCombo.h>
#include <Kaleidoscope-FocusSerial.h>
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
@ -23,6 +24,10 @@ namespace plugin {
uint16_t MagicCombo::min_interval = 500; uint16_t MagicCombo::min_interval = 500;
uint16_t MagicCombo::start_time_ = 0; uint16_t MagicCombo::start_time_ = 0;
EventHandlerResult MagicCombo::onNameQuery() {
return ::Focus.sendName(F("MagicCombo"));
}
EventHandlerResult MagicCombo::beforeReportingState() { EventHandlerResult MagicCombo::beforeReportingState() {
for (byte i = 0; i < magiccombo::combos_length; i++) { for (byte i = 0; i < magiccombo::combos_length; i++) {
bool match = true; bool match = true;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-MagicCombo -- Magic combo framework * Kaleidoscope-MagicCombo -- Magic combo framework
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -48,6 +48,7 @@ class MagicCombo : public kaleidoscope::Plugin {
static uint16_t min_interval; static uint16_t min_interval;
EventHandlerResult onNameQuery();
EventHandlerResult beforeReportingState(); EventHandlerResult beforeReportingState();
private: private:

@ -1,5 +1,5 @@
/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. /* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope.
* Copyright (C) 2017-2018 Keyboard.io, Inc. * Copyright (C) 2017-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -18,6 +18,7 @@
#include "kaleidoscope/Runtime.h" #include "kaleidoscope/Runtime.h"
#include "Kaleidoscope-MouseKeys.h" #include "Kaleidoscope-MouseKeys.h"
#include "Kaleidoscope-FocusSerial.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
namespace kaleidoscope { namespace kaleidoscope {
@ -62,6 +63,10 @@ void MouseKeys_::scrollWheel(uint8_t keyCode) {
kaleidoscope::Runtime.hid().mouse().move(0, 0, 0, wheelSpeed); kaleidoscope::Runtime.hid().mouse().move(0, 0, 0, wheelSpeed);
} }
EventHandlerResult MouseKeys_::onNameQuery() {
return ::Focus.sendName(F("MouseKeys"));
}
EventHandlerResult MouseKeys_::afterEachCycle() { EventHandlerResult MouseKeys_::afterEachCycle() {
kaleidoscope::Runtime.hid().mouse().sendReport(); kaleidoscope::Runtime.hid().mouse().sendReport();
kaleidoscope::Runtime.hid().mouse().releaseAllButtons(); kaleidoscope::Runtime.hid().mouse().releaseAllButtons();

@ -1,5 +1,5 @@
/* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope. /* Kaleidoscope-MouseKeys - Mouse keys for Kaleidoscope.
* Copyright (C) 2017-2018 Keyboard.io, Inc. * Copyright (C) 2017-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -38,6 +38,7 @@ class MouseKeys_ : public kaleidoscope::Plugin {
static void setSpeedLimit(uint8_t speed_limit); static void setSpeedLimit(uint8_t speed_limit);
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onNameQuery();
EventHandlerResult beforeReportingState(); EventHandlerResult beforeReportingState();
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, uint8_t keyState);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-OneShot -- One-shot modifiers and layers * Kaleidoscope-OneShot -- One-shot modifiers and layers
* Copyright (C) 2016-2019 Keyboard.io, Inc. * Copyright (C) 2016-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-OneShot.h> #include <Kaleidoscope-OneShot.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -77,6 +78,10 @@ void OneShot::cancelOneShot(uint8_t idx) {
injectNormalKey(idx, WAS_PRESSED); injectNormalKey(idx, WAS_PRESSED);
} }
EventHandlerResult OneShot::onNameQuery() {
return ::Focus.sendName(F("OneShot"));
}
EventHandlerResult OneShot::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) { EventHandlerResult OneShot::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) {
uint8_t idx = mapped_key.getRaw() - ranges::OS_FIRST; uint8_t idx = mapped_key.getRaw() - ranges::OS_FIRST;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-OneShot -- One-shot modifiers and layers * Kaleidoscope-OneShot -- One-shot modifiers and layers
* Copyright (C) 2016-2019 Keyboard.io, Inc. * Copyright (C) 2016-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -72,6 +72,7 @@ class OneShot : public kaleidoscope::Plugin {
static bool isModifierActive(Key key); static bool isModifierActive(Key key);
EventHandlerResult onNameQuery();
EventHandlerResult beforeReportingState(); EventHandlerResult beforeReportingState();
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState);

@ -20,6 +20,7 @@
#include "kaleidoscope/Runtime.h" #include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-Ranges.h> #include <Kaleidoscope-Ranges.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/progmem_helpers.h" #include "kaleidoscope/progmem_helpers.h"
#include "kaleidoscope/layers.h" #include "kaleidoscope/layers.h"
@ -27,6 +28,10 @@
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
EventHandlerResult Qukeys::onNameQuery() {
return ::Focus.sendName(F("Qukeys"));
}
// This is the event handler. It ignores certain events, but mostly just adds // This is the event handler. It ignores certain events, but mostly just adds
// them to the Qukeys event queue. // them to the Qukeys event queue.
EventHandlerResult Qukeys::onKeyswitchEvent(Key& key, KeyAddr k, uint8_t key_state) { EventHandlerResult Qukeys::onKeyswitchEvent(Key& key, KeyAddr k, uint8_t key_state) {

@ -127,6 +127,7 @@ class Qukeys : public kaleidoscope::Plugin {
static constexpr int8_t layer_wildcard{-1}; static constexpr int8_t layer_wildcard{-1};
// Kaleidoscope hook functions. // Kaleidoscope hook functions.
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, EventHandlerResult onKeyswitchEvent(Key &mapped_key,
KeyAddr key_addr, KeyAddr key_addr,
uint8_t key_state); uint8_t key_state);

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Redial -- Redial support for Kaleidoscope * Kaleidoscope-Redial -- Redial support for Kaleidoscope
* Copyright (C) 2018, 2019 Keyboard.io, Inc. * Copyright (C) 2018-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-Redial.h> #include <Kaleidoscope-Redial.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
namespace kaleidoscope { namespace kaleidoscope {
@ -25,6 +26,10 @@ Key Redial::key_to_redial_;
Key Redial::last_key_; Key Redial::last_key_;
bool Redial::redial_held_ = false; bool Redial::redial_held_ = false;
EventHandlerResult Redial::onNameQuery() {
return ::Focus.sendName(F("Redial"));
}
EventHandlerResult Redial::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) { EventHandlerResult Redial::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) {
if (mapped_key == Key_Redial) { if (mapped_key == Key_Redial) {
if (keyToggledOff(key_state)) if (keyToggledOff(key_state))

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Redial -- Redial support for Kaleidoscope * Kaleidoscope-Redial -- Redial support for Kaleidoscope
* Copyright (C) 2018, 2019 Keyboard.io, Inc. * Copyright (C) 2018-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -31,6 +31,7 @@ class Redial : public kaleidoscope::Plugin {
static bool shouldRemember(Key mappedKey); static bool shouldRemember(Key mappedKey);
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
private: private:

@ -1,6 +1,7 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended * Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc, Ben Gemperline * Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc, Ben Gemperline
* Copyright (C) 2019-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +17,7 @@
*/ */
#include <Kaleidoscope-SpaceCadet.h> #include <Kaleidoscope-SpaceCadet.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -71,6 +73,10 @@ bool SpaceCadet::active() {
return !disabled; return !disabled;
} }
EventHandlerResult SpaceCadet::onNameQuery() {
return ::Focus.sendName(F("SpaceCadet"));
}
EventHandlerResult SpaceCadet::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) { EventHandlerResult SpaceCadet::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) {
//Handle our synthetic keys for enabling and disabling functionality //Handle our synthetic keys for enabling and disabling functionality
if (mapped_key.getRaw() >= kaleidoscope::ranges::SC_FIRST && if (mapped_key.getRaw() >= kaleidoscope::ranges::SC_FIRST &&

@ -1,7 +1,7 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended * Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc, Ben Gemperline * Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc, Ben Gemperline
* Copyright (C) 2019 Keyboard.io, Inc * Copyright (C) 2019-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -66,6 +66,7 @@ class SpaceCadet : public kaleidoscope::Plugin {
static uint16_t time_out; // The global timeout in milliseconds static uint16_t time_out; // The global timeout in milliseconds
static SpaceCadet::KeyBinding * map; // The map of key bindings static SpaceCadet::KeyBinding * map; // The map of key bindings
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
private: private:

@ -1,6 +1,6 @@
/* Kaleidoscope-Steno -- Steno protocols for Kaleidoscope /* Kaleidoscope-Steno -- Steno protocols for Kaleidoscope
* Copyright (C) 2017 Joseph Wasson * Copyright (C) 2017 Joseph Wasson
* Copyright (C) 2017, 2018 Keyboard.io, Inc. * Copyright (C) 2017-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-Steno.h> #include <Kaleidoscope-Steno.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
namespace kaleidoscope { namespace kaleidoscope {
@ -25,6 +26,10 @@ namespace steno {
uint8_t GeminiPR::keys_held_; uint8_t GeminiPR::keys_held_;
uint8_t GeminiPR::state_[6]; uint8_t GeminiPR::state_[6];
EventHandlerResult GeminiPR::onNameQuery() {
return ::Focus.sendName(F("GeminiPR"));
}
EventHandlerResult GeminiPR::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) { EventHandlerResult GeminiPR::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) {
if (mapped_key < geminipr::START || if (mapped_key < geminipr::START ||
mapped_key > geminipr::END) mapped_key > geminipr::END)

@ -1,6 +1,6 @@
/* Kaleidoscope-Steno -- Steno protocols for Kaleidoscope /* Kaleidoscope-Steno -- Steno protocols for Kaleidoscope
* Copyright (C) 2017 Joseph Wasson * Copyright (C) 2017 Joseph Wasson
* Copyright (C) 2017, 2018 Keyboard.io, Inc. * Copyright (C) 2017-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -29,6 +29,7 @@ class GeminiPR : public kaleidoscope::Plugin {
public: public:
GeminiPR(void) {} GeminiPR(void) {}
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState);
private: private:
static uint8_t keys_held_; static uint8_t keys_held_;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Syster -- Symbolic input system * Kaleidoscope-Syster -- Symbolic input system
* Copyright (C) 2017, 2018, 2019 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-Syster.h> #include <Kaleidoscope-Syster.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h" #include "kaleidoscope/key_events.h"
@ -44,6 +45,10 @@ bool Syster::is_active(void) {
} }
// --- hooks --- // --- hooks ---
EventHandlerResult Syster::onNameQuery() {
return ::Focus.sendName(F("Syster"));
}
EventHandlerResult Syster::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) { EventHandlerResult Syster::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) {
if (!is_active_) { if (!is_active_) {
if (!isSyster(mapped_key)) if (!isSyster(mapped_key))

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Syster -- Symbolic input system * Kaleidoscope-Syster -- Symbolic input system
* Copyright (C) 2017, 2018, 2019 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -41,6 +41,7 @@ class Syster : public kaleidoscope::Plugin {
bool is_active(void); bool is_active(void);
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState);
private: private:

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-TapDance -- Tap-dance keys * Kaleidoscope-TapDance -- Tap-dance keys
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc * Copyright (C) 2016-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -16,6 +16,7 @@
*/ */
#include <Kaleidoscope-TapDance.h> #include <Kaleidoscope-TapDance.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
namespace kaleidoscope { namespace kaleidoscope {
@ -105,6 +106,10 @@ void TapDance::actionKeys(uint8_t tap_count, ActionType tap_dance_action, uint8_
// --- hooks --- // --- hooks ---
EventHandlerResult TapDance::onNameQuery() {
return ::Focus.sendName(F("TapDance"));
}
EventHandlerResult TapDance::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) { EventHandlerResult TapDance::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState) {
if (keyState & INJECTED) if (keyState & INJECTED)
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-TapDance -- Tap-dance keys * Kaleidoscope-TapDance -- Tap-dance keys
* Copyright (C) 2016, 2017, 2018, 2019 Keyboard.io, Inc * Copyright (C) 2016-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -46,6 +46,7 @@ class TapDance : public kaleidoscope::Plugin {
void actionKeys(uint8_t tap_count, ActionType tap_dance_action, uint8_t max_keys, const Key tap_keys[]); void actionKeys(uint8_t tap_count, ActionType tap_dance_action, uint8_t max_keys, const Key tap_keys[]);
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t keyState);
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();

@ -17,6 +17,7 @@
#include <Kaleidoscope-Turbo.h> #include <Kaleidoscope-Turbo.h>
#include <Kaleidoscope-LEDControl.h> #include <Kaleidoscope-LEDControl.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/layers.h" #include "kaleidoscope/layers.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
@ -85,6 +86,10 @@ EventHandlerResult Turbo::onSetup() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
EventHandlerResult Turbo::onNameQuery() {
return ::Focus.sendName(F("Turbo"));
}
EventHandlerResult Turbo::onLayerChange() { EventHandlerResult Turbo::onLayerChange() {
Turbo::findKeyPositions(); Turbo::findKeyPositions();
return EventHandlerResult::OK; return EventHandlerResult::OK;

@ -45,6 +45,7 @@ class Turbo : public kaleidoscope::Plugin {
void activeColor(cRGB newVal); void activeColor(cRGB newVal);
EventHandlerResult onSetup(); EventHandlerResult onSetup();
EventHandlerResult onNameQuery();
EventHandlerResult onLayerChange(); EventHandlerResult onLayerChange();
EventHandlerResult onKeyswitchEvent(Key &key, KeyAddr key_addr, uint8_t key_state); EventHandlerResult onKeyswitchEvent(Key &key, KeyAddr key_addr, uint8_t key_state);
EventHandlerResult afterEachCycle(); EventHandlerResult afterEachCycle();

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-TypingBreaks -- Enforced typing breaks * Kaleidoscope-TypingBreaks -- Enforced typing breaks
* Copyright (C) 2017, 2018 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -102,6 +102,10 @@ EventHandlerResult TypingBreaks::onKeyswitchEvent(Key &mapped_key, KeyAddr key_a
return EventHandlerResult::OK; return EventHandlerResult::OK;
} }
EventHandlerResult TypingBreaks::onNameQuery() {
return ::Focus.sendName(F("TypingBreaks"));
}
EventHandlerResult TypingBreaks::onSetup() { EventHandlerResult TypingBreaks::onSetup() {
settings_base_ = ::EEPROMSettings.requestSlice(sizeof(settings)); settings_base_ = ::EEPROMSettings.requestSlice(sizeof(settings));

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-TypingBreaks -- Enforced typing breaks * Kaleidoscope-TypingBreaks -- Enforced typing breaks
* Copyright (C) 2017, 2018, 2019 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -36,6 +36,7 @@ class TypingBreaks : public kaleidoscope::Plugin {
static settings_t settings; static settings_t settings;
EventHandlerResult onNameQuery();
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
EventHandlerResult onFocusEvent(const char *command); EventHandlerResult onFocusEvent(const char *command);
EventHandlerResult onSetup(); EventHandlerResult onSetup();

@ -1,5 +1,5 @@
/* Kaleidoscope - Firmware for computer input devices /* Kaleidoscope - Firmware for computer input devices
* Copyright (C) 2013-2018 Keyboard.io, Inc. * Copyright (C) 2013-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -113,6 +113,16 @@ class SignatureCheckDummy {};
#define _FOR_EACH_EVENT_HANDLER(OPERATION, ...) __NL__ \ #define _FOR_EACH_EVENT_HANDLER(OPERATION, ...) __NL__ \
__NL__ \ __NL__ \
/* Called by Focus, when handling the `plugins` command. */ __NL__ \
/* Should send the plugin name if that makes sense, */ __NL__ \
/* but can be no-op. */ __NL__ \
OPERATION(onNameQuery, __NL__ \
1, __NL__ \
_CURRENT_IMPLEMENTATION, __NL__ \
_NOT_ABORTABLE, __NL__ \
(), (), (), __NL__ \
(), (), ##__VA_ARGS__) __NL__ \
__NL__ \
OPERATION(onSetup, __NL__ \ OPERATION(onSetup, __NL__ \
1, __NL__ \ 1, __NL__ \
_CURRENT_IMPLEMENTATION, __NL__ \ _CURRENT_IMPLEMENTATION, __NL__ \
@ -233,6 +243,10 @@ class SignatureCheckDummy {};
OP(onSetup, 1) __NL__ \ OP(onSetup, 1) __NL__ \
END(onSetup, 1) __NL__ \ END(onSetup, 1) __NL__ \
__NL__ \ __NL__ \
START(onNameQuery, 1) __NL__ \
OP(onNameQuery, 1) __NL__ \
END(onNameQuery, 1) __NL__ \
__NL__ \
START(beforeEachCycle, 1) __NL__ \ START(beforeEachCycle, 1) __NL__ \
OP(beforeEachCycle, 1) __NL__ \ OP(beforeEachCycle, 1) __NL__ \
END(beforeEachCycle, 1) __NL__ \ END(beforeEachCycle, 1) __NL__ \

@ -1,5 +1,5 @@
/* Kaleidoscope - Firmware for computer input devices /* Kaleidoscope - Firmware for computer input devices
* Copyright (C) 2013-2018 Keyboard.io, Inc. * Copyright (C) 2013-2021 Keyboard.io, Inc.
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software * the terms of the GNU General Public License as published by the Free Software
@ -35,6 +35,7 @@ namespace kaleidoscope {
namespace plugin { namespace plugin {
// Forward declaration to enable friend declarations. // Forward declaration to enable friend declarations.
class LEDControl; class LEDControl;
class FocusSerial;
} }
// Forward declaration to enable friend declarations. // Forward declaration to enable friend declarations.
@ -61,6 +62,7 @@ class Hooks {
// Runtime_ calls Hooks::onSetup, Hooks::beforeReportingState // Runtime_ calls Hooks::onSetup, Hooks::beforeReportingState
// and Hooks::afterEachCycle. // and Hooks::afterEachCycle.
friend class Runtime_; friend class Runtime_;
friend class ::kaleidoscope::plugin::FocusSerial;
friend class ::kaleidoscope::Layer_; friend class ::kaleidoscope::Layer_;
friend class ::kaleidoscope::plugin::LEDControl; friend class ::kaleidoscope::plugin::LEDControl;
friend void ::kaleidoscope::sketch_exploration::pluginsExploreSketch(); friend void ::kaleidoscope::sketch_exploration::pluginsExploreSketch();

Loading…
Cancel
Save