Use Kaleidoscope-Ranges for the enable/disable keys

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/389/head
Gergely Nagy 7 years ago
parent ec35d638d8
commit 842f6ed98a

@ -153,6 +153,10 @@ properties:
> behavior. This is only triggered on initial downpress, and does not > behavior. This is only triggered on initial downpress, and does not
> trigger again if held down or when the key is released. > trigger again if held down or when the key is released.
## Dependencies
* [Kaleidoscope-Ranges](https://github.com/keyboardio/Kaleidoscope-Ranges)
## Further reading ## Further reading
Starting from the [example][plugin:example] is the recommended way of getting Starting from the [example][plugin:example] is the recommended way of getting

@ -77,7 +77,8 @@ void SpaceCadet::begin() {
Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, 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.flags == (SYNTHETIC | IS_INTERNAL | SPACECADET_TOGGLE)) { if (mapped_key.raw >= kaleidoscope::ranges::SC_FIRST &&
mapped_key.raw <= kaleidoscope::ranges::SC_LAST) {
//Only fire the activate / deactivate on the initial press (not held or release) //Only fire the activate / deactivate on the initial press (not held or release)
if (keyToggledOn(key_state)) { if (keyToggledOn(key_state)) {
if (mapped_key == Key_SpaceCadetEnable) { if (mapped_key == Key_SpaceCadetEnable) {

@ -1,6 +1,6 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended * Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended
* Copyright (C) 2016, 2017 Gergely Nagy, Ben Gemperline * Copyright (C) 2016, 2017, 2018 Gergely Nagy, Ben Gemperline
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,16 +19,14 @@
#pragma once #pragma once
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
#include <Kaleidoscope-Ranges.h>
#ifndef SPACECADET_MAP_END #ifndef SPACECADET_MAP_END
#define SPACECADET_MAP_END (kaleidoscope::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 } #define SPACECADET_MAP_END (kaleidoscope::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 }
#endif #endif
#ifndef SPACECADET_TOGGLE #define Key_SpaceCadetEnable (Key) { .raw = kaleidoscope::ranges::SC_FIRST }
#define SPACECADET_TOGGLE B00000011 // Synthetic, internal #define Key_SpaceCadetDisable (Key) { .raw = kaleidoscope::ranges::SC_LAST }
#define Key_SpaceCadetEnable (Key) { 0, KEY_FLAGS | SYNTHETIC | IS_INTERNAL | SPACECADET_TOGGLE }
#define Key_SpaceCadetDisable (Key) { 1, KEY_FLAGS | SYNTHETIC | IS_INTERNAL | SPACECADET_TOGGLE }
#endif
namespace kaleidoscope { namespace kaleidoscope {
//Declaration for the method (implementing KaleidoscopePlugin) //Declaration for the method (implementing KaleidoscopePlugin)

Loading…
Cancel
Save