diff options
-rw-r--r-- | Makefile | 25 | ||||
-rw-r--r-- | README | 3 | ||||
m--------- | lib/hardware/arduino/avr | 0 | ||||
m--------- | lib/hardware/keyboardio | 0 | ||||
-rw-r--r-- | src/Macros.cpp | 22 | ||||
-rw-r--r-- | src/Macros.h | 2 | ||||
-rw-r--r-- | src/MagicCombo.cpp | 25 | ||||
-rw-r--r-- | src/MagicCombo.h | 27 | ||||
-rw-r--r-- | src/TapDance.cpp | 2 | ||||
-rw-r--r-- | src/TapDance.h | 2 | ||||
-rw-r--r-- | src/colormap.map | 4 | ||||
-rw-r--r-- | src/keymap.h | 22 | ||||
-rw-r--r-- | src/model01.ino | 4 | ||||
-rwxr-xr-x | tools/apply-colormap | 10 |
14 files changed, 117 insertions, 31 deletions
@@ -16,12 +16,31 @@ LOCAL_CPP_SRCS = $(wildcard $(SOURCEDIR)/*.cpp) LOCAL_INO_SRCS = $(wildcard $(SOURCEDIR)/*.ino) USER_LIB_PATH = $(ALTERNATE_CORE_PATH)/libraries -ARDUINO_LIBS = EEPROM Kaleidoscope Kaleidoscope-HIDAdaptor-KeyboardioHID KeyboardioHID KeyboardioScanner - -# extra definitions from boards.txt +KALEIDOSCOPE_PLUGINS = Kaleidoscope-Colormap \ + Kaleidoscope-EEPROM-Settings \ + Kaleidoscope-Escape-OneShot \ + Kaleidoscope-FocusSerial \ + Kaleidoscope-Hardware-Model01 \ + Kaleidoscope-Hardware-Keyboardio-Model01 \ + Kaleidoscope-IdleLEDs \ + Kaleidoscope-LED-ActiveModColor \ + Kaleidoscope-LED-Palette-Theme \ + Kaleidoscope-Macros \ + Kaleidoscope-MagicCombo \ + Kaleidoscope-MouseKeys \ + Kaleidoscope-OneShot \ + Kaleidoscope-OneShotMetaKeys \ + Kaleidoscope-Ranges \ + Kaleidoscope-TapDance +ARDUINO_LIBS = EEPROM Kaleidoscope KeyboardioHID \ + $(addprefix Kaleidoscope/plugins/,$(KALEIDOSCOPE_PLUGINS)) + +# extra definitions from lib/hardware/keyboardio/avr/boards.txt CXXFLAGS = -DARDUINO_AVR_MODEL01 \ -DUSB_MANUFACTURER="\"keyboardio\"" -DUSB_PRODUCT="\"Model 01\"" \ -DKALEIDOSCOPE_HARDWARE_H="\"Kaleidoscope-Hardware-Model01.h\"" +# cf. lib/hardware/keyboardio/avr/platform.txt +CXXFLAGS_STD = -std=c++14 -fno-threadsafe-statics ifeq ($(ENABLE_SERIAL),yes) CXXFLAGS += -DENABLE_SERIAL @@ -1,7 +1,7 @@ Introduction ============ -A firmware Sketch for the Keyboardio Model 01. Based algerno's: +A firmware Sketch for the Keyboardio Model 01. Based on algerno's: https://git.madhouse-project.org/algernon/Model01-Sketch#base-layer @@ -31,7 +31,6 @@ Initialize (or update) submodules: ~$ git -C lib/hardware/keyboardio submodule update --init --recursive \ "avr/bootloaders/*" \ "avr/libraries/Kaleidoscope" \ - "avr/libraries/Kaleidoscope-HIDAdaptor-KeyboardioHID" \ "avr/libraries/Keyboardio*" ~$ make diff --git a/lib/hardware/arduino/avr b/lib/hardware/arduino/avr -Subproject 2663be17272e19f00c55f3f2d8f1ebfac47158d +Subproject b3243815e2ed8c72f9ac3669e69632a590b1d04 diff --git a/lib/hardware/keyboardio b/lib/hardware/keyboardio -Subproject 60d06fdd42cf131ead99dd4bc63aee59d366a52 +Subproject a9165613d1aab35d8be365b54976460165d790f diff --git a/src/Macros.cpp b/src/Macros.cpp index 2fd4229..529bfca 100644 --- a/src/Macros.cpp +++ b/src/Macros.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. **********************************************************************/ +#include <Kaleidoscope.h> #include <Kaleidoscope-OneShot.h> #include "Macros.h" @@ -24,18 +25,21 @@ * like i3: without this macro it doesn't see the difference between * $mod+R0C2 (switch to workspace #2) and $mod+shift+R0C2 (move focused * container to workspace #2), as R0C2 triggers LSHIFT(Key_2). + * + * XXX doesn't work with repeats... + * https://github.com/keyboardio/Kaleidoscope/issues/647 */ #define TopRow(k1, k2) \ - if (kaleidoscope::hid::isModifierKeyActive(Key_LeftControl) || \ - ::OneShot.isModifierActive(Key_LeftControl) || \ - kaleidoscope::hid::isModifierKeyActive(Key_RightAlt) || \ - ::OneShot.isModifierActive(Key_RightAlt)) \ - return MACRODOWN(Tr(k2)); \ - else \ - return MACRODOWN(Tr(k1)); \ + if (keyToggledOn(event.state)) { \ + if (Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_LeftControl) || \ + Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_RightAlt)) \ + return MACRO(Dr(k2)); \ + else \ + return MACRO(Dr(k1)); \ + }; -const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { - switch (macroIndex) { +const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { + switch (macro_id) { case AT: TopRow(LSHIFT(Key_2), Key_2); case STAR: TopRow(LSHIFT(Key_8), Key_3); case DOLLAR: TopRow(LSHIFT(Key_4), Key_4); diff --git a/src/Macros.h b/src/Macros.h index 829308c..5e4395c 100644 --- a/src/Macros.h +++ b/src/Macros.h @@ -34,4 +34,4 @@ enum { , RIGHT_BRACKET }; -extern const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState); +extern const macro_t *macroAction(uint8_t macro_id, KeyEvent &event); diff --git a/src/MagicCombo.cpp b/src/MagicCombo.cpp new file mode 100644 index 0000000..f24e221 --- /dev/null +++ b/src/MagicCombo.cpp @@ -0,0 +1,25 @@ +/*********************************************************************** + * A firmware Sketch for the Keyboardio Model 01 + * Copyright © 2019 Guilhem Moulin <guilhem@fripost.org> + * + * 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 Foundation, either version 3 of the License, or (at + * your option) any later version. + + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **********************************************************************/ + +#include <Kaleidoscope-Macros.h> +#include <Kaleidoscope-MouseKeys.h> +#include "MagicCombo.h" + +void comboMiddleClick(uint8_t combo_index) { + Macros.play(MACRO(T(mouseBtnM))); +} diff --git a/src/MagicCombo.h b/src/MagicCombo.h new file mode 100644 index 0000000..1546790 --- /dev/null +++ b/src/MagicCombo.h @@ -0,0 +1,27 @@ +/*********************************************************************** + * A firmware Sketch for the Keyboardio Model 01 + * Copyright © 2019 Guilhem Moulin <guilhem@fripost.org> + * + * 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 Foundation, either version 3 of the License, or (at + * your option) any later version. + + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **********************************************************************/ + +#pragma once + +#include <Kaleidoscope-MagicCombo.h> + +enum { + MIDDLE_CLICK +}; + +extern void comboMiddleClick(uint8_t combo_index); diff --git a/src/TapDance.cpp b/src/TapDance.cpp index e5f870d..7af5393 100644 --- a/src/TapDance.cpp +++ b/src/TapDance.cpp @@ -20,7 +20,7 @@ #include "TapDance.h" bool cancelOneShot = false; -void tapDanceAction(uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, +void tapDanceAction(uint8_t tapDanceIndex, KeyAddr keyAddr, uint8_t tapCount, kaleidoscope::plugin::TapDance::ActionType tapDanceAction) { /* Cancel any pending on-shot effects when a tap-dance key is released */ if (tapDanceAction == kaleidoscope::plugin::TapDance::Release) diff --git a/src/TapDance.h b/src/TapDance.h index ff90f5e..7129259 100644 --- a/src/TapDance.h +++ b/src/TapDance.h @@ -27,5 +27,5 @@ enum { }; extern bool cancelOneShot; -extern void tapDanceAction(uint8_t tapDanceIndex, byte row, byte col, uint8_t tapCount, +extern void tapDanceAction(uint8_t tapDanceIndex, KeyAddr keyAddr, uint8_t tapCount, kaleidoscope::plugin::TapDance::ActionType tapDanceAction); diff --git a/src/colormap.map b/src/colormap.map index 2ba99d4..7387a80 100644 --- a/src/colormap.map +++ b/src/colormap.map @@ -7,12 +7,12 @@ 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 -8 0 0 0 0 0 3 0 +0 0 0 0 0 0 3 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 6 0 0 0 0 0 0 +8 6 0 0 0 0 0 0 # Nav diff --git a/src/keymap.h b/src/keymap.h index a15f725..41f3a20 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -29,6 +29,7 @@ enum { , LAYER_MAX = NUM }; +#define Key_LockScreen Consumer_AL_TerminalLockSlashScreensaver #define Key_PlayPause Consumer_PlaySlashPause #define Key_Plus LSHIFT(Key_Equals) #define Key_Underscore LSHIFT(Key_Minus) @@ -40,7 +41,7 @@ KEYMAPS( ___, M(LEFT_BRACKET), M(AT), M(STAR), M(DOLLAR), M(CARET), ___ , Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, TD(LPB) , Key_Tab, Key_A, Key_O, Key_E, Key_U, Key_I - , Key_LeftGui, Key_Slash, Key_Q, Key_J, Key_K, Key_X, TD(COLON) + , ___, Key_Slash, Key_Q, Key_J, Key_K, Key_X, TD(COLON) , OSM(LeftControl), Key_Backspace, OSM(LeftShift), Key_Escape , OSL(NAV) @@ -50,16 +51,16 @@ KEYMAPS( , Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus , Key_Equals, Key_B, Key_M, Key_W, Key_V, Key_Z, ___ - , ___, Key_Enter, Key_Spacebar, OSM(RightAlt) + , Key_LeftGui, Key_Enter, Key_Spacebar, OSM(RightAlt) , OSL(NUM) ) , [NAV] = KEYMAP_STACKED( - ___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_PrintScreen - , XXX, Key_mouseScrollR, Key_mouseWarpNW, Key_mouseUp, Key_mouseWarpNE, Key_mouseScrollDn, Key_mouseWarpEnd - , XXX, Key_mouseScrollL, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseScrollUp - , ___, XXX, Key_mouseWarpSW, XXX, Key_mouseWarpSE, XXX, Key_mouseBtnL + Key_LockScreen, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_PrintScreen + , XXX, Key_mouseScrollR, Key_mouseWarpNW, Key_mouseUp, Key_mouseWarpNE, Key_mouseScrollDn, Key_mouseWarpEnd + , XXX, Key_mouseScrollL, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseScrollUp + , ___, XXX, Key_mouseWarpSW, XXX, Key_mouseWarpSE, XXX, Key_mouseBtnL , ___, Key_Delete, ___, ___ , ___ @@ -92,3 +93,12 @@ KEYMAPS( , ___ ) ) + +/* Magic Combos */ +USE_MAGIC_COMBOS( + [MIDDLE_CLICK] = { + .action = comboMiddleClick + /* Nav + LeftClick + RightClick */ + , .keys = {R3C6, R2C6, R2C9} + } +) diff --git a/src/model01.ino b/src/model01.ino index 61f0871..ba6f088 100644 --- a/src/model01.ino +++ b/src/model01.ino @@ -31,6 +31,7 @@ #include <Kaleidoscope-OneShot.h> #include "Macros.h" +#include "MagicCombo.h" #include "TapDance.h" #include "keymap.h" @@ -46,6 +47,7 @@ KALEIDOSCOPE_INIT_PLUGINS( , EscapeOneShot , ActiveModColorEffect , Macros + , MagicCombo #ifdef ENABLE_SERIAL , Focus #endif @@ -61,7 +63,7 @@ void setup() { MouseKeys.speed = 15; MouseKeys.accelDelay = 35; - IdleLEDs.idle_time_limit = 60; + IdleLEDs.setIdleTimeoutSeconds(60); } void loop() { diff --git a/tools/apply-colormap b/tools/apply-colormap index dd35844..d59ddd2 100755 --- a/tools/apply-colormap +++ b/tools/apply-colormap @@ -73,13 +73,12 @@ colormap() { } palette() { - printf "palette" - sed "/^\\s*#/d; s/\\s*#.*//" <"$PALETTE" \ - | sed -nr "1h;1!H; \${x; s/^\\s*/ /; s/\s+/ /g; p}" + { echo "palette"; sed "/^\\s*#/d; s/\\s*#.*//" <"$PALETTE"; } \ + | sed -r ':a; $!N; s/\n/ /; ta; s/\s+/ /g' } serial_send() { - local fd + local fd x old_IFS="$IFS" exec {fd}<"$DEVICE_PATH" "$@" >"$DEVICE_PATH" while IFS= read -r -u "$fd" x; do @@ -87,7 +86,8 @@ serial_send() { [ "$x" != "." ] || break printf "%s\\n" "$x" done - {fd}<&- + IFS="$old_IFS" + exec {fd}<&- } serial_send palette |