1
0

Updated to use the new MagicCombo APIs

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
This commit is contained in:
Gergely Nagy 2018-06-09 13:13:46 +02:00
parent 33bcc999b9
commit 583d5429cd

View File

@ -288,45 +288,23 @@ void hostPowerManagementEventHandler(kaleidoscope::HostPowerManagement::Event ev
* firmware The names aren't particularly important. What is important is that * firmware The names aren't particularly important. What is important is that
* each is unique. * each is unique.
* *
* These are the names of your magic combos. They'll be used in two places. * These are the names of your magic combos. They will be used by the
* * `USE_MAGIC_COMBOS` call below.
* The first is in the magic combo list, that pairs a name (or index, really)
* with keys.
*
* The second is in the 'switch' statement in the 'magicComboActions' function.
* That switch statement actually runs the code associated with the combo, when
* the combo is recognised.
*/ */
enum { COMBO_PROTOCOL_TOGGLE }; enum { COMBO_PROTOCOL_TOGGLE };
// Key combinations we want special actions for, to be used with the MagicCombo static void toggleKeyboardProtocol(uint8_t combo_index) {
// plugin.
static const kaleidoscope::MagicCombo::combo_t magic_combos[] PROGMEM = {
[COMBO_PROTOCOL_TOGGLE] = {
R3C6 | R2C6 | R3C7, // Left Fn + Esc + Shift
0
},
{0, 0} // End-of-list marker.
};
/** magicComboActions dispatches combo events the MagicCombo plugin recognises.
The first argument is the index of the combination, the next two are the
left- and right-hand states, as bit maps. For most cases, the index is
enough to decide how to handle the combination.
The 'switch' statement should have a 'case' for each entry of the combo
enum. Each 'case' statement should call out to a function to handle the
combination in question.
*/
void magicComboActions(uint8_t combo_index, uint32_t left_hand, uint32_t right_hand) {
switch (combo_index) {
case COMBO_PROTOCOL_TOGGLE:
USBQuirks.toggleKeyboardProtocol(); USBQuirks.toggleKeyboardProtocol();
break;
}
} }
/** Magic combo list, a list of key combo and action pairs the firmware should
* recognise.
*/
USE_MAGIC_COMBOS([COMBO_PROTOCOL_TOGGLE] = {.action = toggleKeyboardProtocol,
// Left Fn + Esc + Shift
.keys = { R3C6, R2C6, R3C7 }
});
// First, tell Kaleidoscope which plugins you want to use. // First, tell Kaleidoscope which plugins you want to use.
// The order can be important. For example, LED effects are // The order can be important. For example, LED effects are
// added in the order they're listed here. // added in the order they're listed here.
@ -417,10 +395,6 @@ void setup() {
// see https://github.com/keyboardio/Kaleidoscope-LED-Stalker // see https://github.com/keyboardio/Kaleidoscope-LED-Stalker
StalkerEffect.variant = STALKER(BlazingTrail); StalkerEffect.variant = STALKER(BlazingTrail);
// For the MagicCombo plugin to work, we need to tell it what combos we care
// about.
MagicCombo.magic_combos = magic_combos;
// We want to make sure that the firmware starts with LED effects off // We want to make sure that the firmware starts with LED effects off
// This avoids over-taxing devices that don't have a lot of power to share // This avoids over-taxing devices that don't have a lot of power to share
// with USB devices // with USB devices