summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BUILD_GUIDE.md6
-rw-r--r--keyboard/planck/planck.c32
-rw-r--r--keyboard/planck/planck.h1
-rw-r--r--keyboard/retro_refit/Makefile23
-rw-r--r--keyboard/retro_refit/config.h47
-rw-r--r--quantum/template/Makefile23
-rw-r--r--quantum/template/config.h47
-rw-r--r--quantum/template/template.c20
-rw-r--r--quantum/template/template.h5
-rw-r--r--tmk_core/common/action.c10
-rw-r--r--tmk_core/common/action.h3
-rw-r--r--tmk_core/common/action_macro.c4
-rw-r--r--tmk_core/common/action_util.c9
-rw-r--r--tmk_core/common/action_util.h7
-rw-r--r--tmk_core/common/command.c353
-rw-r--r--tmk_core/common/command.h121
-rw-r--r--tmk_core/common/keyboard.c6
17 files changed, 559 insertions, 158 deletions
diff --git a/BUILD_GUIDE.md b/BUILD_GUIDE.md
index 81c3ec44f..e8b242e4e 100644
--- a/BUILD_GUIDE.md
+++ b/BUILD_GUIDE.md
@@ -25,12 +25,12 @@ You can also try these instructions:
3. Install [DFU-Programmer][dfu-prog].
### Linux
-Install AVR GCC and dfu-progammer with your favorite package manager.
+Install AVR GCC, AVR libc, and dfu-progammer with your favorite package manager.
Debian/Ubuntu example:
sudo apt-get update
- sudo apt-get install gcc-avr dfu-programmer
+ sudo apt-get install gcc-avr avr-libc dfu-programmer
### Vagrant
If you have any problems building the firmware, you can try using a tool called Vagrant. It will set up a virtual computer with a known configuration that's ready-to-go for firmware building. OLKB does NOT host the files for this virtual computer. Details on how to set up Vagrant are in the [VAGRANT_GUIDE file](VAGRANT_GUIDE.md).
@@ -52,4 +52,4 @@ If you have any problems building the firmware, you can try using a tool called
## Troubleshooting
1. Try running `make clean` if the make command fails.
- WIP \ No newline at end of file
+ WIP
diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c
index fe8731ec7..4b39cf1e8 100644
--- a/keyboard/planck/planck.c
+++ b/keyboard/planck/planck.c
@@ -1,28 +1,26 @@
#include "planck.h"
__attribute__ ((weak))
-void matrix_init_user(void) {
-
-}
+void matrix_init_user(void) {}
__attribute__ ((weak))
-void matrix_scan_user(void) {
+void matrix_scan_user(void) {}
-}
+__attribute__ ((weak))
+void process_action_user(keyrecord_t *record) {}
void matrix_init_kb(void) {
- #ifdef BACKLIGHT_ENABLE
- backlight_init_ports();
- #endif
+#ifdef BACKLIGHT_ENABLE
+ backlight_init_ports();
+#endif
- #ifdef RGBLIGHT_ENABLE
- rgblight_init();
- #endif
+#ifdef RGBLIGHT_ENABLE
+ rgblight_init();
+#endif
-
- // Turn status LED on
- DDRE |= (1<<6);
- PORTE |= (1<<6);
+ // Turn status LED on
+ DDRE |= (1<<6);
+ PORTE |= (1<<6);
matrix_init_user();
}
@@ -30,3 +28,7 @@ void matrix_init_kb(void) {
void matrix_scan_kb(void) {
matrix_scan_user();
}
+
+void process_action_kb(keyrecord_t *record) {
+ process_action_user(record);
+}
diff --git a/keyboard/planck/planck.h b/keyboard/planck/planck.h
index e9566b922..edcb5fbff 100644
--- a/keyboard/planck/planck.h
+++ b/keyboard/planck/planck.h
@@ -42,5 +42,6 @@
void matrix_init_user(void);
void matrix_scan_user(void);
+void process_action_user(keyrecord_t *record);
#endif
diff --git a/keyboard/retro_refit/Makefile b/keyboard/retro_refit/Makefile
index ec51227ff..918b43071 100644
--- a/keyboard/retro_refit/Makefile
+++ b/keyboard/retro_refit/Makefile
@@ -113,18 +113,19 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512
# Build Options
# comment out to disable the options.
#
-BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = yes # Console for debug(+400)
-COMMAND_ENABLE = yes # Commands for debug and configuration
+BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = yes # Console for debug(+400)
+COMMAND_ENABLE = yes # Commands for debug and configuration
+KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
-# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
-# MIDI_ENABLE = YES # MIDI controls
-# UNICODE_ENABLE = YES # Unicode
-# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
+# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
+# MIDI_ENABLE = YES # MIDI controls
+# UNICODE_ENABLE = YES # Unicode
+# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
# Optimize size but this may cause error "relocation truncated to fit"
diff --git a/keyboard/retro_refit/config.h b/keyboard/retro_refit/config.h
index ba9a861ed..05fceb92b 100644
--- a/keyboard/retro_refit/config.h
+++ b/keyboard/retro_refit/config.h
@@ -53,11 +53,54 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
-/* key combination for command */
+
+/* Force NKRO Mode - If forced on, must be disabled via magic key (default = LShift+RShift+N) */
+#define FORCE_NKRO
+
+/*
+ * Magic key options
+ * These options allow the magic key functionality to be changed. This is useful
+ * if your keyboard/keypad is missing keys and you want magic key support.
+ */
+
+/* key combination for magic key command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
+/* control how magic key switches layers */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
+
+/* remap magic keys */
+//#define MAGIC_KEY_HELP1 H
+//#define MAGIC_KEY_HELP2 SLASH
+//#define MAGIC_KEY_DEBUG D
+//#define MAGIC_KEY_DEBUG_MATRIX X
+//#define MAGIC_KEY_DEBUG_KBD K
+//#define MAGIC_KEY_DEBUG_MOUSE M
+//#define MAGIC_KEY_VERSION V
+//#define MAGIC_KEY_STATUS S
+//#define MAGIC_KEY_CONSOLE C
+//#define MAGIC_KEY_LAYER0_ALT1 ESC
+//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
+//#define MAGIC_KEY_LAYER0 0
+//#define MAGIC_KEY_LAYER1 1
+//#define MAGIC_KEY_LAYER2 2
+//#define MAGIC_KEY_LAYER3 3
+//#define MAGIC_KEY_LAYER4 4
+//#define MAGIC_KEY_LAYER5 5
+//#define MAGIC_KEY_LAYER6 6
+//#define MAGIC_KEY_LAYER7 7
+//#define MAGIC_KEY_LAYER8 8
+//#define MAGIC_KEY_LAYER9 9
+//#define MAGIC_KEY_BOOTLOADER PAUSE
+#define MAGIC_KEY_LOCK BSLS
+//#define MAGIC_KEY_EEPROM E
+//#define MAGIC_KEY_NKRO N
+//#define MAGIC_KEY_SLEEP_LED Z
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
@@ -76,4 +119,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
-#endif
+#endif \ No newline at end of file
diff --git a/quantum/template/Makefile b/quantum/template/Makefile
index 2efa69138..4fa195468 100644
--- a/quantum/template/Makefile
+++ b/quantum/template/Makefile
@@ -113,18 +113,19 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512
# Build Options
# comment out to disable the options.
#
-BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = yes # Console for debug(+400)
-COMMAND_ENABLE = yes # Commands for debug and configuration
+BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = yes # Console for debug(+400)
+COMMAND_ENABLE = yes # Commands for debug and configuration
+KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
-# NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
-# MIDI_ENABLE = YES # MIDI controls
-# UNICODE_ENABLE = YES # Unicode
-# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
+# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+#NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
+# MIDI_ENABLE = YES # MIDI controls
+# UNICODE_ENABLE = YES # Unicode
+# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID
# Optimize size but this may cause error "relocation truncated to fit"
diff --git a/quantum/template/config.h b/quantum/template/config.h
index 7d6149f43..dae4b6313 100644
--- a/quantum/template/config.h
+++ b/quantum/template/config.h
@@ -55,11 +55,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Locking resynchronize hack */
#define LOCKING_RESYNC_ENABLE
-/* key combination for command */
+/* Force NKRO Mode - If forced on, must be disabled via magic key (default = LShift+RShift+N) */
+//#define FORCE_NKRO
+
+/*
+ * Magic key options
+ * These options allow the magic key functionality to be changed. This is useful
+ * if your keyboard/keypad is missing keys and you want magic key support.
+ */
+
+/* key combination for magic key command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
)
+/* control how magic key switches layers */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
+
+/* override magic key keymap */
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
+//#define MAGIC_KEY_HELP1 H
+//#define MAGIC_KEY_HELP2 SLASH
+//#define MAGIC_KEY_DEBUG D
+//#define MAGIC_KEY_DEBUG_MATRIX X
+//#define MAGIC_KEY_DEBUG_KBD K
+//#define MAGIC_KEY_DEBUG_MOUSE M
+//#define MAGIC_KEY_VERSION V
+//#define MAGIC_KEY_STATUS S
+//#define MAGIC_KEY_CONSOLE C
+//#define MAGIC_KEY_LAYER0_ALT1 ESC
+//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
+//#define MAGIC_KEY_LAYER0 0
+//#define MAGIC_KEY_LAYER1 1
+//#define MAGIC_KEY_LAYER2 2
+//#define MAGIC_KEY_LAYER3 3
+//#define MAGIC_KEY_LAYER4 4
+//#define MAGIC_KEY_LAYER5 5
+//#define MAGIC_KEY_LAYER6 6
+//#define MAGIC_KEY_LAYER7 7
+//#define MAGIC_KEY_LAYER8 8
+//#define MAGIC_KEY_LAYER9 9
+//#define MAGIC_KEY_BOOTLOADER PAUSE
+//#define MAGIC_KEY_LOCK CAPS
+//#define MAGIC_KEY_EEPROM E
+//#define MAGIC_KEY_NKRO N
+//#define MAGIC_KEY_SLEEP_LED Z
+
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/quantum/template/template.c b/quantum/template/template.c
index 58e73cb09..cc52e496f 100644
--- a/quantum/template/template.c
+++ b/quantum/template/template.c
@@ -11,6 +11,11 @@ void matrix_scan_user(void) {
}
__attribute__ ((weak))
+void process_action_user(keyrecord_t *record) {
+ // leave this function blank - it can be defined in a keymap file
+}
+
+__attribute__ ((weak))
void led_set_user(uint8_t usb_led) {
// leave this function blank - it can be defined in a keymap file
}
@@ -18,19 +23,26 @@ void led_set_user(uint8_t usb_led) {
void matrix_init_kb(void) {
// put your keyboard start-up code here
// runs once when the firmware starts up
-
+
matrix_init_user();
}
void matrix_scan_kb(void) {
- // put your looping keyboard code here
- // runs every cycle (a lot)
+ // put your looping keyboard code here
+ // runs every cycle (a lot)
matrix_scan_user();
}
+void process_action_kb(keyrecord_t *record) {
+ // put your per-action keyboard code here
+ // runs for every action, just before processing by the firmware
+
+ process_action_user(record);
+}
+
void led_set_kb(uint8_t usb_led) {
// put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
led_set_user(usb_led);
-} \ No newline at end of file
+}
diff --git a/quantum/template/template.h b/quantum/template/template.h
index ba91abac3..b1c34d3cb 100644
--- a/quantum/template/template.h
+++ b/quantum/template/template.h
@@ -17,10 +17,11 @@
{ \
{ k00, k01, k02 }, \
{ k10, KC_NO, k11 }, \
-}
+}
void matrix_init_user(void);
void matrix_scan_user(void);
+void process_action_user(keyrecord_t *record);
void led_set_user(uint8_t usb_led);
-#endif \ No newline at end of file
+#endif
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 77ea39e94..2ccc0e0b9 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -53,6 +53,9 @@ void action_exec(keyevent_t event)
#endif
}
+__attribute__ ((weak))
+void process_action_kb(keyrecord_t *record) {}
+
void process_action(keyrecord_t *record)
{
keyevent_t event = record->event;
@@ -62,6 +65,8 @@ void process_action(keyrecord_t *record)
if (IS_NOEVENT(event)) { return; }
+ process_action_kb(record);
+
action_t action = layer_switch_get_action(event.key);
dprint("ACTION: "); debug_action(action);
#ifndef NO_ACTION_LAYER
@@ -70,6 +75,10 @@ void process_action(keyrecord_t *record)
#endif
dprintln();
+ if (event.pressed) {
+ // clear the potential weak mods left by previously pressed keys
+ clear_weak_mods();
+ }
switch (action.kind.id) {
/* Key and Mods */
case ACT_LMODS:
@@ -500,6 +509,7 @@ void clear_keyboard(void)
void clear_keyboard_but_mods(void)
{
clear_weak_mods();
+ clear_macro_mods();
clear_keys();
send_keyboard_report();
#ifdef MOUSEKEY_ENABLE
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 8a4736d7b..9f528af4b 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -58,6 +58,9 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
/* user defined special function */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
+/* keyboard-specific key event (pre)processing */
+void process_action_kb(keyrecord_t *record);
+
/* Utilities for actions. */
void process_action(keyrecord_t *record);
void register_code(uint8_t code);
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index ffaf125c0..7726b1190 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -41,7 +41,7 @@ void action_macro_play(const macro_t *macro_p)
MACRO_READ();
dprintf("KEY_DOWN(%02X)\n", macro);
if (IS_MOD(macro)) {
- add_weak_mods(MOD_BIT(macro));
+ add_macro_mods(MOD_BIT(macro));
send_keyboard_report();
} else {
register_code(macro);
@@ -51,7 +51,7 @@ void action_macro_play(const macro_t *macro_p)
MACRO_READ();
dprintf("KEY_UP(%02X)\n", macro);
if (IS_MOD(macro)) {
- del_weak_mods(MOD_BIT(macro));
+ del_macro_mods(MOD_BIT(macro));
send_keyboard_report();
} else {
unregister_code(macro);
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index f81877dd9..a2d6577b2 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -29,6 +29,7 @@ static inline void del_key_bit(uint8_t code);
static uint8_t real_mods = 0;
static uint8_t weak_mods = 0;
+static uint8_t macro_mods = 0;
#ifdef USB_6KRO_ENABLE
#define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS)
@@ -55,6 +56,7 @@ static int16_t oneshot_time = 0;
void send_keyboard_report(void) {
keyboard_report->mods = real_mods;
keyboard_report->mods |= weak_mods;
+ keyboard_report->mods |= macro_mods;
#ifndef NO_ACTION_ONESHOT
if (oneshot_mods) {
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
@@ -118,6 +120,13 @@ void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; }
void set_weak_mods(uint8_t mods) { weak_mods = mods; }
void clear_weak_mods(void) { weak_mods = 0; }
+/* macro modifier */
+uint8_t get_macro_mods(void) { return macro_mods; }
+void add_macro_mods(uint8_t mods) { macro_mods |= mods; }
+void del_macro_mods(uint8_t mods) { macro_mods &= ~mods; }
+void set_macro_mods(uint8_t mods) { macro_mods = mods; }
+void clear_macro_mods(void) { macro_mods = 0; }
+
/* Oneshot modifier */
#ifndef NO_ACTION_ONESHOT
void set_oneshot_mods(uint8_t mods)
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h
index a955638b4..1a95cec10 100644
--- a/tmk_core/common/action_util.h
+++ b/tmk_core/common/action_util.h
@@ -47,6 +47,13 @@ void del_weak_mods(uint8_t mods);
void set_weak_mods(uint8_t mods);
void clear_weak_mods(void);
+/* macro modifier */
+uint8_t get_macro_mods(void);
+void add_macro_mods(uint8_t mods);
+void del_macro_mods(uint8_t mods);
+void set_macro_mods(uint8_t mods);
+void clear_macro_mods(void);
+
/* oneshot modifier */
void set_oneshot_mods(uint8_t mods);
void clear_oneshot_mods(void);
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index d59bb01bb..b4cd3ca56 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -52,6 +52,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static bool command_common(uint8_t code);
static void command_common_help(void);
+static void print_version(void);
+static void print_status(void);
static bool command_console(uint8_t code);
static void command_console_help(void);
#ifdef MOUSEKEY_ENABLE
@@ -112,35 +114,140 @@ bool command_console_extra(uint8_t code)
***********************************************************/
static void command_common_help(void)
{
- print("\n\t- Magic -\n"
- "d: debug\n"
- "x: debug matrix\n"
- "k: debug keyboard\n"
- "m: debug mouse\n"
- "v: version\n"
- "s: status\n"
- "c: console mode\n"
- "0-4: layer0-4(F10-F4)\n"
- "Paus: bootloader\n"
+ print( "\n\t- Magic -\n"
+ STR(MAGIC_KEY_DEBUG ) ": Debug Message Toggle\n"
+ STR(MAGIC_KEY_DEBUG_MATRIX) ": Matrix Debug Mode Toggle - Show keypresses in matrix grid\n"
+ STR(MAGIC_KEY_DEBUG_KBD ) ": Keyboard Debug Toggle - Show keypress report\n"
+ STR(MAGIC_KEY_DEBUG_MOUSE ) ": Debug Mouse Toggle\n"
+ STR(MAGIC_KEY_VERSION ) ": Version\n"
+ STR(MAGIC_KEY_STATUS ) ": Status\n"
+ STR(MAGIC_KEY_CONSOLE ) ": Activate Console Mode\n"
+
+#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
+ STR(MAGIC_KEY_LAYER0 ) ": Switch to Layer 0\n"
+ STR(MAGIC_KEY_LAYER1 ) ": Switch to Layer 1\n"
+ STR(MAGIC_KEY_LAYER2 ) ": Switch to Layer 2\n"
+ STR(MAGIC_KEY_LAYER3 ) ": Switch to Layer 3\n"
+ STR(MAGIC_KEY_LAYER4 ) ": Switch to Layer 4\n"
+ STR(MAGIC_KEY_LAYER5 ) ": Switch to Layer 5\n"
+ STR(MAGIC_KEY_LAYER6 ) ": Switch to Layer 6\n"
+ STR(MAGIC_KEY_LAYER7 ) ": Switch to Layer 7\n"
+ STR(MAGIC_KEY_LAYER8 ) ": Switch to Layer 8\n"
+ STR(MAGIC_KEY_LAYER9 ) ": Switch to Layer 9\n"
+#endif
+
+#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+ "F1-F10: Switch to Layer 0-9 (F10 = L0)\n"
+#endif
+
+#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+ "0-9: Switch to Layer 0-9\n"
+#endif
+
+ STR(MAGIC_KEY_LAYER0_ALT1 ) ": Switch to Layer 0 (alternate key 1)\n"
+ STR(MAGIC_KEY_LAYER0_ALT2 ) ": Switch to Layer 0 (alternate key 2)\n"
+ STR(MAGIC_KEY_BOOTLOADER ) ": Jump to Bootloader (Reset)\n"
#ifdef KEYBOARD_LOCK_ENABLE
- "Caps: Lock\n"
+ STR(MAGIC_KEY_LOCK ) ": Lock\n"
#endif
#ifdef BOOTMAGIC_ENABLE
- "e: eeprom\n"
+ STR(MAGIC_KEY_EEPROM ) ": Print EEPROM Settings\n"
#endif
#ifdef NKRO_ENABLE
- "n: NKRO\n"
+ STR(MAGIC_KEY_NKRO ) ": NKRO Toggle\n"
#endif
#ifdef SLEEP_LED_ENABLE
- "z: sleep LED test\n"
+ STR(MAGIC_KEY_SLEEP_LED ) ": Sleep LED Test\n"
#endif
);
}
+static void print_version(void)
+{
+ // print version & information
+ print("\n\t- Version -\n");
+ print("DESC: " STR(DESCRIPTION) "\n");
+ print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
+ "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
+ "VER: " STR(DEVICE_VER) "\n");
+ print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n");
+
+ /* build options */
+ print("OPTIONS:"
+
+#ifdef PROTOCOL_PJRC
+ " PJRC"
+#endif
+#ifdef PROTOCOL_LUFA
+ " LUFA"
+#endif
+#ifdef PROTOCOL_VUSB
+ " VUSB"
+#endif
+#ifdef BOOTMAGIC_ENABLE
+ " BOOTMAGIC"
+#endif
+#ifdef MOUSEKEY_ENABLE
+ " MOUSEKEY"
+#endif
+#ifdef EXTRAKEY_ENABLE
+ " EXTRAKEY"
+#endif
+#ifdef CONSOLE_ENABLE
+ " CONSOLE"
+#endif
+#ifdef COMMAND_ENABLE
+ " COMMAND"
+#endif
+#ifdef NKRO_ENABLE
+ " NKRO"
+#endif
+#ifdef KEYMAP_SECTION_ENABLE
+ " KEYMAP_SECTION"
+#endif
+
+ " " STR(BOOTLOADER_SIZE) "\n");
+
+ print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
+ " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
+ " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
+
+ return;
+}
+
+static void print_status(void)
+{
+
+ print("\n\t- Status -\n");
+
+ print_val_hex8(host_keyboard_leds());
+ print_val_hex8(keyboard_protocol);
+ print_val_hex8(keyboard_idle);
+#ifdef NKRO_ENABLE
+ print_val_hex8(keyboard_nkro);
+#endif
+ print_val_hex32(timer_count);
+
+#ifdef PROTOCOL_PJRC
+ print_val_hex8(UDCON);
+ print_val_hex8(UDIEN);
+ print_val_hex8(UDINT);
+ print_val_hex8(usb_keyboard_leds);
+ print_val_hex8(usb_keyboard_idle_count);
+#endif
+
+#ifdef PROTOCOL_PJRC
+# if USB_COUNT_SOF
+ print_val_hex8(usbSofCount);
+# endif
+#endif
+ return;
+}
+
#ifdef BOOTMAGIC_ENABLE
static void print_eeconfig(void)
{
@@ -178,24 +285,36 @@ static void print_eeconfig(void)
static bool command_common(uint8_t code)
{
+
+#ifdef KEYBOARD_LOCK_ENABLE
static host_driver_t *host_driver = 0;
+#endif
+
switch (code) {
+
#ifdef SLEEP_LED_ENABLE
- case KC_Z:
- // test breathing sleep LED
- print("Sleep LED test\n");
+
+ // test breathing sleep LED
+ case MAGIC_KC(MAGIC_KEY_SLEEP_LED):
+ print("Sleep LED Test\n");
sleep_led_toggle();
led_set(host_keyboard_leds());
break;
#endif
+
#ifdef BOOTMAGIC_ENABLE
- case KC_E:
+
+ // print stored eeprom config
+ case MAGIC_KC(MAGIC_KEY_EEPROM):
print("eeconfig:\n");
print_eeconfig();
break;
#endif
+
#ifdef KEYBOARD_LOCK_ENABLE
- case KC_CAPSLOCK:
+
+ // lock/unlock keyboard
+ case MAGIC_KC(MAGIC_KEY_LOCK):
if (host_get_driver()) {
host_driver = host_get_driver();
clear_keyboard();
@@ -207,11 +326,15 @@ static bool command_common(uint8_t code)
}
break;
#endif
- case KC_H:
- case KC_SLASH: /* ? */
+
+ // print help
+ case MAGIC_KC(MAGIC_KEY_HELP1):
+ case MAGIC_KC(MAGIC_KEY_HELP2):
command_common_help();
break;
- case KC_C:
+
+ // activate console
+ case MAGIC_KC(MAGIC_KEY_CONSOLE):
debug_matrix = false;
debug_keyboard = false;
debug_mouse = false;
@@ -220,25 +343,33 @@ static bool command_common(uint8_t code)
print("C> ");
command_state = CONSOLE;
break;
- case KC_PAUSE:
- clear_keyboard();
- print("\n\nbootloader... ");
+
+ // jump to bootloader
+ case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
+ clear_keyboard(); // clear to prevent stuck keys
+ print("\n\nJumping to bootloader... ");
_delay_ms(1000);
bootloader_jump(); // not return
break;
- case KC_D:
+
+ // debug toggle
+ case MAGIC_KC(MAGIC_KEY_DEBUG):
+ debug_enable = !debug_enable;
if (debug_enable) {
+ print("\ndebug: on\n");
+ debug_matrix = true;
+ debug_keyboard = true;
+ debug_mouse = true;
+ } else {
print("\ndebug: off\n");
debug_matrix = false;
debug_keyboard = false;
debug_mouse = false;
- debug_enable = false;
- } else {
- print("\ndebug: on\n");
- debug_enable = true;
}
break;
- case KC_X: // debug matrix toggle
+
+ // debug matrix toggle
+ case MAGIC_KC(MAGIC_KEY_DEBUG_MATRIX):
debug_matrix = !debug_matrix;
if (debug_matrix) {
print("\nmatrix: on\n");
@@ -247,7 +378,9 @@ static bool command_common(uint8_t code)
print("\nmatrix: off\n");
}
break;
- case KC_K: // debug keyboard toggle
+
+ // debug keyboard toggle
+ case MAGIC_KC(MAGIC_KEY_DEBUG_KBD):
debug_keyboard = !debug_keyboard;
if (debug_keyboard) {
print("\nkeyboard: on\n");
@@ -256,87 +389,33 @@ static bool command_common(uint8_t code)
print("\nkeyboard: off\n");
}
break;
- case KC_M: // debug mouse toggle
+
+ // debug mouse toggle
+ case MAGIC_KC(MAGIC_KEY_DEBUG_MOUSE):
debug_mouse = !debug_mouse;
if (debug_mouse) {
print("\nmouse: on\n");
debug_enable = true;
} else {
- print("\nmouse: off\n");
+ print("\nmouse: off\n");
}
break;
- case KC_V: // print version & information
- print("\n\t- Version -\n");
- print("DESC: " STR(DESCRIPTION) "\n");
- print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
- "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
- "VER: " STR(DEVICE_VER) "\n");
- print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n");
- /* build options */
- print("OPTIONS:"
-#ifdef PROTOCOL_PJRC
- " PJRC"
-#endif
-#ifdef PROTOCOL_LUFA
- " LUFA"
-#endif
-#ifdef PROTOCOL_VUSB
- " VUSB"
-#endif
-#ifdef BOOTMAGIC_ENABLE
- " BOOTMAGIC"
-#endif
-#ifdef MOUSEKEY_ENABLE
- " MOUSEKEY"
-#endif
-#ifdef EXTRAKEY_ENABLE
- " EXTRAKEY"
-#endif
-#ifdef CONSOLE_ENABLE
- " CONSOLE"
-#endif
-#ifdef COMMAND_ENABLE
- " COMMAND"
-#endif
-#ifdef NKRO_ENABLE
- " NKRO"
-#endif
-#ifdef KEYMAP_SECTION_ENABLE
- " KEYMAP_SECTION"
-#endif
- " " STR(BOOTLOADER_SIZE) "\n");
- print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
- " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
- " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
- break;
- case KC_S:
- print("\n\t- Status -\n");
- print_val_hex8(host_keyboard_leds());
- print_val_hex8(keyboard_protocol);
- print_val_hex8(keyboard_idle);
-#ifdef NKRO_ENABLE
- print_val_hex8(keyboard_nkro);
-#endif
- print_val_hex32(timer_count);
-
-#ifdef PROTOCOL_PJRC
- print_val_hex8(UDCON);
- print_val_hex8(UDIEN);
- print_val_hex8(UDINT);
- print_val_hex8(usb_keyboard_leds);
- print_val_hex8(usb_keyboard_idle_count);
-#endif
+ // print version
+ case MAGIC_KC(MAGIC_KEY_VERSION):
+ print_version();
+ break;
-#ifdef PROTOCOL_PJRC
-# if USB_COUNT_SOF
- print_val_hex8(usbSofCount);
-# endif
-#endif
+ // print status
+ case MAGIC_KC(MAGIC_KEY_STATUS):
+ print_status();
break;
+
#ifdef NKRO_ENABLE
- case KC_N:
- clear_keyboard(); //Prevents stuck keys.
+
+ // NKRO toggle
+ case MAGIC_KC(MAGIC_KEY_NKRO):
+ clear_keyboard(); // clear to prevent stuck keys
keyboard_nkro = !keyboard_nkro;
if (keyboard_nkro)
print("NKRO: on\n");
@@ -344,18 +423,78 @@ static bool command_common(uint8_t code)
print("NKRO: off\n");
break;
#endif
- case KC_ESC:
- case KC_GRV:
- case KC_0:
+
+ // switch layers
+
+ case MAGIC_KC(MAGIC_KEY_LAYER0_ALT1):
+ case MAGIC_KC(MAGIC_KEY_LAYER0_ALT2):
+ switch_default_layer(0);
+ break;
+
+#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
+
+ case MAGIC_KC(MAGIC_KEY_LAYER0):
+ switch_default_layer(0);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER1):
+ switch_default_layer(1);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER2):
+ switch_default_layer(2);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER3):
+ switch_default_layer(3);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER4):
+ switch_default_layer(4);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER5):
+ switch_default_layer(5);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER6):
+ switch_default_layer(6);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER7):
+ switch_default_layer(7);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER8):
+ switch_default_layer(8);
+ break;
+
+ case MAGIC_KC(MAGIC_KEY_LAYER9):
+ switch_default_layer(9);
+ break;
+#endif
+
+
+#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+
+ case KC_F1 ... KC_F9:
+ switch_default_layer((code - KC_F1) + 1);
+ break;
case KC_F10:
switch_default_layer(0);
break;
+#endif
+
+#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+
case KC_1 ... KC_9:
switch_default_layer((code - KC_1) + 1);
break;
- case KC_F1 ... KC_F9:
- switch_default_layer((code - KC_F1) + 1);
+ case KC_0:
+ switch_default_layer(0);
break;
+#endif
+
default:
print("?");
return false;
diff --git a/tmk_core/common/command.h b/tmk_core/common/command.h
index b57a6c1ce..92b18849b 100644
--- a/tmk_core/common/command.h
+++ b/tmk_core/common/command.h
@@ -32,4 +32,125 @@ bool command_proc(uint8_t code);
#define command_proc(code) false
#endif
+
+#ifndef MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
+#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
+#endif
+
+#ifndef MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
+#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
+#endif
+
+#ifndef MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
+#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
+#endif
+
+#ifndef MAGIC_KEY_HELP1
+#define MAGIC_KEY_HELP1 H
+#endif
+
+#ifndef MAGIC_KEY_HELP2
+#define MAGIC_KEY_HELP2 SLASH
+#endif
+
+#ifndef MAGIC_KEY_DEBUG
+#define MAGIC_KEY_DEBUG D
+#endif
+
+#ifndef MAGIC_KEY_DEBUG_MATRIX
+#define MAGIC_KEY_DEBUG_MATRIX X
+#endif
+
+#ifndef MAGIC_KEY_DEBUG_KBD
+#define MAGIC_KEY_DEBUG_KBD K
+#endif
+
+#ifndef MAGIC_KEY_DEBUG_MOUSE
+#define MAGIC_KEY_DEBUG_MOUSE M
+#endif
+
+#ifndef MAGIC_KEY_VERSION
+#define MAGIC_KEY_VERSION V
+#endif
+
+#ifndef MAGIC_KEY_STATUS
+#define MAGIC_KEY_STATUS S
+#endif
+
+#ifndef MAGIC_KEY_CONSOLE
+#define MAGIC_KEY_CONSOLE C
+#endif
+
+#ifndef MAGIC_KEY_LAYER0_ALT1
+#define MAGIC_KEY_LAYER0_ALT1 ESC
+#endif
+
+#ifndef MAGIC_KEY_LAYER0_ALT2
+#define MAGIC_KEY_LAYER0_ALT2 GRAVE
+#endif
+
+#ifndef MAGIC_KEY_LAYER0
+#define MAGIC_KEY_LAYER0 0
+#endif
+
+#ifndef MAGIC_KEY_LAYER1
+#define MAGIC_KEY_LAYER1 1
+#endif
+
+#ifndef MAGIC_KEY_LAYER2
+#define MAGIC_KEY_LAYER2 2
+#endif
+
+#ifndef MAGIC_KEY_LAYER3
+#define MAGIC_KEY_LAYER3 3
+#endif
+
+#ifndef MAGIC_KEY_LAYER4
+#define MAGIC_KEY_LAYER4 4
+#endif
+
+#ifndef MAGIC_KEY_LAYER5
+#define MAGIC_KEY_LAYER5 5
+#endif
+
+#ifndef MAGIC_KEY_LAYER6
+#define MAGIC_KEY_LAYER6 6
+#endif
+
+#ifndef MAGIC_KEY_LAYER7
+#define MAGIC_KEY_LAYER7 7
+#endif
+
+#ifndef MAGIC_KEY_LAYER8
+#define MAGIC_KEY_LAYER8 8
#endif
+
+#ifndef MAGIC_KEY_LAYER9
+#define MAGIC_KEY_LAYER9 9
+#endif
+
+#ifndef MAGIC_KEY_BOOTLOADER
+#define MAGIC_KEY_BOOTLOADER PAUSE
+#endif
+
+#ifndef MAGIC_KEY_LOCK
+#define MAGIC_KEY_LOCK CAPS
+#endif
+
+#ifndef MAGIC_KEY_EEPROM
+#define MAGIC_KEY_EEPROM E
+#endif
+
+#ifndef MAGIC_KEY_NKRO
+#define MAGIC_KEY_NKRO N
+#endif
+
+#ifndef MAGIC_KEY_SLEEP_LED
+#define MAGIC_KEY_SLEEP_LED Z
+
+#endif
+
+#define XMAGIC_KC(key) KC_##key
+#define MAGIC_KC(key) XMAGIC_KC(key)
+
+#endif \ No newline at end of file
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index eb7b096be..e66808485 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -70,6 +70,7 @@ void keyboard_setup(void)
void keyboard_init(void)
{
+
timer_init();
matrix_init();
#ifdef PS2_MOUSE_ENABLE
@@ -90,6 +91,11 @@ void keyboard_init(void)
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif
+
+#ifdef FORCE_NKRO
+ keyboard_nkro = true;
+#endif
+
}
/*