diff --git a/README.md b/README.md index 5a8fc2c9..874d88df 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ this sort of functionality on other keys, as well. Fortunately, the Space Cadet plugin is configurable and extensible to support adding symbols to other keys. Along with `(` on your left `Shift` key and `)` on your right `Shift` key, you may wish to add other such programming mainstays as `{` to your left-side `cmd` key, -`}` to your right-side `alt` key, `[` to your left `Control` key, and `]` to your right -`Control` key. You can map the keys in whatever way you may wish to do, so feel free to +`}` to your right-side `alt` key, `[` to your left `Control` key, and `]` to your right +`Control` key. You can map the keys in whatever way you may wish to do, so feel free to experiment with different combinations and discover what works best for you! [space-cadet]: https://en.wikipedia.org/wiki/Space-cadet_keyboard @@ -53,7 +53,7 @@ void setup() { ``` This assumes a US QWERTY layout on the host computer, though the plugin sends -the correct keymap code for each symbol. Because the mapping is entirely +the correct keymap code for each symbol. Because the mapping is entirely configurable, though, you may switch out keys at your leisure. If you wish to enable additional modifier keys (or disable the default behavior @@ -108,7 +108,7 @@ properties: > An object consisting of the key that is pressed, the key that should be sent > in its place, and the timeout (in milliseconds) until the key press is > considered to be a "held" key press. The third parameter, the timeout, is -> optional and may be set per-key or left out entirely (or set to `0`) to use +> optional and may be set per-key or left out entirely (or set to `0`) to use > the default timeout value. ### `.time_out` @@ -125,7 +125,7 @@ properties: > This method enables the SpaceCadet plugin. This is useful for interfacing > with other plugins or macros, especially where SpaceCadet functionality isn't -> always desired. +> always desired. > > The default behavior is `enabled`. @@ -133,12 +133,12 @@ properties: > This method disables the SpaceCadet behavior. This is useful for interfacing > with other plugins or macros, especially where SpaceCadet functionality isn't -> always desired. +> always desired. ### `.active()` > This method returns `true` if SpaceCadet is enabled and `false` if SpaceCadet -> is disabled. This is useful for interfacing with other plugins or macros, +> is disabled. This is useful for interfacing with other plugins or macros, > especially where SpaceCadet functionality isn't always desired. ### `Key_SpaceCadetEnable` @@ -153,6 +153,10 @@ properties: > behavior. This is only triggered on initial downpress, and does not > trigger again if held down or when the key is released. +## Dependencies + +* [Kaleidoscope-Ranges](https://github.com/keyboardio/Kaleidoscope-Ranges) + ## Further reading Starting from the [example][plugin:example] is the recommended way of getting diff --git a/src/Kaleidoscope/SpaceCadet.cpp b/src/Kaleidoscope/SpaceCadet.cpp index 657a2468..1a7f7a88 100644 --- a/src/Kaleidoscope/SpaceCadet.cpp +++ b/src/Kaleidoscope/SpaceCadet.cpp @@ -77,7 +77,8 @@ void SpaceCadet::begin() { Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { //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) if (keyToggledOn(key_state)) { if (mapped_key == Key_SpaceCadetEnable) { diff --git a/src/Kaleidoscope/SpaceCadet.h b/src/Kaleidoscope/SpaceCadet.h index b0a82ca2..bf901afa 100644 --- a/src/Kaleidoscope/SpaceCadet.h +++ b/src/Kaleidoscope/SpaceCadet.h @@ -1,6 +1,6 @@ /* -*- mode: c++ -*- * 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 * it under the terms of the GNU General Public License as published by @@ -19,16 +19,14 @@ #pragma once #include +#include #ifndef SPACECADET_MAP_END #define SPACECADET_MAP_END (kaleidoscope::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 } #endif -#ifndef SPACECADET_TOGGLE -#define SPACECADET_TOGGLE B00000011 // Synthetic, internal -#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 +#define Key_SpaceCadetEnable (Key) { .raw = kaleidoscope::ranges::SC_FIRST } +#define Key_SpaceCadetDisable (Key) { .raw = kaleidoscope::ranges::SC_LAST } namespace kaleidoscope { //Declaration for the method (implementing KaleidoscopePlugin)