summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common')
-rw-r--r--tmk_core/common/action.c45
-rw-r--r--tmk_core/common/action.h7
-rw-r--r--tmk_core/common/action_code.h2
-rw-r--r--tmk_core/common/action_layer.c89
-rw-r--r--tmk_core/common/action_layer.h12
-rw-r--r--tmk_core/common/action_macro.c8
-rw-r--r--tmk_core/common/action_tapping.c11
-rw-r--r--tmk_core/common/avr/eeconfig.c32
-rw-r--r--tmk_core/common/avr/suspend.c18
-rw-r--r--tmk_core/common/backlight.c10
-rw-r--r--tmk_core/common/bootmagic.c6
-rw-r--r--tmk_core/common/command.c373
-rw-r--r--tmk_core/common/command.h121
-rw-r--r--tmk_core/common/eeconfig.h14
-rw-r--r--tmk_core/common/keyboard.c14
-rw-r--r--tmk_core/common/keymap.c3
-rw-r--r--tmk_core/common/keymap.h3
-rw-r--r--tmk_core/common/magic.c36
-rw-r--r--tmk_core/common/magic.h6
-rw-r--r--tmk_core/common/print.h12
20 files changed, 646 insertions, 176 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 4197c53ed..0162fbd63 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -27,11 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_util.h"
#include "action.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
void action_exec(keyevent_t event)
@@ -53,6 +53,25 @@ void action_exec(keyevent_t event)
#endif
}
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+bool disable_action_cache = false;
+
+void process_action_nocache(keyrecord_t *record)
+{
+ disable_action_cache = true;
+ process_action(record);
+ disable_action_cache = false;
+}
+#else
+void process_action_nocache(keyrecord_t *record)
+{
+ process_action(record);
+}
+#endif
+
+__attribute__ ((weak))
+void process_action_kb(keyrecord_t *record) {}
+
void process_action(keyrecord_t *record)
{
keyevent_t event = record->event;
@@ -62,7 +81,9 @@ void process_action(keyrecord_t *record)
if (IS_NOEVENT(event)) { return; }
- action_t action = layer_switch_get_action(event.key);
+ process_action_kb(record);
+
+ action_t action = store_or_get_action(event.pressed, event.key);
dprint("ACTION: "); debug_action(action);
#ifndef NO_ACTION_LAYER
dprint(" layer_state: "); layer_debug();
@@ -83,14 +104,24 @@ void process_action(keyrecord_t *record)
action.key.mods<<4;
if (event.pressed) {
if (mods) {
- add_weak_mods(mods);
+ if (IS_MOD(action.key.code)) {
+ // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
+ // this also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT)
+ add_mods(mods);
+ } else {
+ add_weak_mods(mods);
+ }
send_keyboard_report();
}
register_code(action.key.code);
} else {
unregister_code(action.key.code);
if (mods) {
- del_weak_mods(mods);
+ if (IS_MOD(action.key.code)) {
+ del_mods(mods);
+ } else {
+ del_weak_mods(mods);
+ }
send_keyboard_report();
}
}
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 8a4736d7b..44ec3047b 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -58,7 +58,14 @@ 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. */
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+extern bool disable_action_cache;
+#endif
+void process_action_nocache(keyrecord_t *record);
void process_action(keyrecord_t *record);
void register_code(uint8_t code);
void unregister_code(uint8_t code);
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index 4fe9c1d58..2b0b0b077 100644
--- a/tmk_core/common/action_code.h
+++ b/tmk_core/common/action_code.h
@@ -301,7 +301,7 @@ enum backlight_opt {
#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
-#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level)
+#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | (level))
/* Command */
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
/* Function */
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index c535615f4..845fbbb21 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -4,14 +4,14 @@
#include "util.h"
#include "action_layer.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
-/*
+/*
* Default Layer State
*/
uint32_t default_layer_state = 0;
@@ -52,7 +52,7 @@ void default_layer_xor(uint32_t state)
#ifndef NO_ACTION_LAYER
-/*
+/*
* Keymap Layer State
*/
uint32_t layer_state = 0;
@@ -110,9 +110,71 @@ void layer_debug(void)
}
#endif
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+uint8_t source_layers_cache[(MATRIX_ROWS * MATRIX_COLS + 7) / 8][MAX_LAYER_BITS] = {0};
+void update_source_layers_cache(keypos_t key, uint8_t layer)
+{
+ const uint8_t key_number = key.col + (key.row * MATRIX_COLS);
+ const uint8_t storage_row = key_number / 8;
+ const uint8_t storage_bit = key_number % 8;
-action_t layer_switch_get_action(keypos_t key)
+ for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
+ source_layers_cache[storage_row][bit_number] ^=
+ (-((layer & (1U << bit_number)) != 0)
+ ^ source_layers_cache[storage_row][bit_number])
+ & (1U << storage_bit);
+ }
+}
+
+uint8_t read_source_layers_cache(keypos_t key)
+{
+ const uint8_t key_number = key.col + (key.row * MATRIX_COLS);
+ const uint8_t storage_row = key_number / 8;
+ const uint8_t storage_bit = key_number % 8;
+ uint8_t layer = 0;
+
+ for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
+ layer |=
+ ((source_layers_cache[storage_row][bit_number]
+ & (1U << storage_bit)) != 0)
+ << bit_number;
+ }
+
+ return layer;
+}
+#endif
+
+/*
+ * Make sure the action triggered when the key is released is the same
+ * one as the one triggered on press. It's important for the mod keys
+ * when the layer is switched after the down event but before the up
+ * event as they may get stuck otherwise.
+ */
+action_t store_or_get_action(bool pressed, keypos_t key)
+{
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+ if (disable_action_cache) {
+ return layer_switch_get_action(key);
+ }
+
+ uint8_t layer;
+
+ if (pressed) {
+ layer = layer_switch_get_layer(key);
+ update_source_layers_cache(key, layer);
+ }
+ else {
+ layer = read_source_layers_cache(key);
+ }
+ return action_for_key(layer, key);
+#else
+ return layer_switch_get_action(key);
+#endif
+}
+
+
+int8_t layer_switch_get_layer(keypos_t key)
{
action_t action;
action.code = ACTION_TRANSPARENT;
@@ -124,15 +186,18 @@ action_t layer_switch_get_action(keypos_t key)
if (layers & (1UL<<i)) {
action = action_for_key(i, key);
if (action.code != ACTION_TRANSPARENT) {
- return action;
+ return i;
}
}
}
/* fall back to layer 0 */
- action = action_for_key(0, key);
- return action;
+ return 0;
#else
- action = action_for_key(biton32(default_layer_state), key);
- return action;
+ return biton32(default_layer_state);
#endif
}
+
+action_t layer_switch_get_action(keypos_t key)
+{
+ return action_for_key(layer_switch_get_layer(key), key);
+}
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index b6da353cf..025cf5420 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -68,8 +68,20 @@ void layer_xor(uint32_t state);
#define layer_and(state)
#define layer_xor(state)
#define layer_debug()
+
+#endif
+
+/* pressed actions cache */
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+/* The number of bits needed to represent the layer number: log2(32). */
+#define MAX_LAYER_BITS 5
+void update_source_layers_cache(keypos_t key, uint8_t layer);
+uint8_t read_source_layers_cache(keypos_t key);
#endif
+action_t store_or_get_action(bool pressed, keypos_t key);
+/* return the topmost non-transparent layer currently associated with key */
+int8_t layer_switch_get_layer(keypos_t key);
/* return action depending on current layer status */
action_t layer_switch_get_action(keypos_t key);
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index 7726b1190..cc78c8232 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -19,11 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_macro.h"
#include "wait.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
#ifndef NO_ACTION_MACRO
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c
index 826c23309..6b6fa1dfe 100644
--- a/tmk_core/common/action_tapping.c
+++ b/tmk_core/common/action_tapping.c
@@ -6,11 +6,11 @@
#include "keycode.h"
#include "timer.h"
-#ifdef DEBUG_ACTION
+//#ifdef DEBUG_ACTION
#include "debug.h"
-#else
-#include "nodebug.h"
-#endif
+//#else
+//#include "nodebug.h"
+//#endif
#ifndef NO_ACTION_TAPPING
@@ -139,7 +139,7 @@ bool process_tapping(keyrecord_t *keyp)
if (event.pressed) {
tapping_key.tap.interrupted = true;
}
- // enqueue
+ // enqueue
return false;
}
}
@@ -324,6 +324,7 @@ bool waiting_buffer_typed(keyevent_t event)
return false;
}
+__attribute__((unused))
bool waiting_buffer_has_anykey_pressed(void)
{
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
diff --git a/tmk_core/common/avr/eeconfig.c b/tmk_core/common/avr/eeconfig.c
index 5bd47dc6a..c5391f5cf 100644
--- a/tmk_core/common/avr/eeconfig.c
+++ b/tmk_core/common/avr/eeconfig.c
@@ -5,24 +5,27 @@
void eeconfig_init(void)
{
- eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
- eeprom_write_byte(EECONFIG_DEBUG, 0);
- eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0);
- eeprom_write_byte(EECONFIG_KEYMAP, 0);
- eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
+ eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
+ eeprom_update_byte(EECONFIG_DEBUG, 0);
+ eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
+ eeprom_update_byte(EECONFIG_KEYMAP, 0);
+ eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
#ifdef BACKLIGHT_ENABLE
- eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
+ eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
+#endif
+#ifdef AUDIO_ENABLE
+ eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
#endif
}
void eeconfig_enable(void)
{
- eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
+ eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
}
void eeconfig_disable(void)
{
- eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
+ eeprom_update_word(EECONFIG_MAGIC, 0xFFFF);
}
bool eeconfig_is_enabled(void)
@@ -31,15 +34,20 @@ bool eeconfig_is_enabled(void)
}
uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
-void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); }
+void eeconfig_update_debug(uint8_t val) { eeprom_update_byte(EECONFIG_DEBUG, val); }
uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); }
-void eeconfig_write_default_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); }
+void eeconfig_update_default_layer(uint8_t val) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); }
uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); }
-void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); }
+void eeconfig_update_keymap(uint8_t val) { eeprom_update_byte(EECONFIG_KEYMAP, val); }
#ifdef BACKLIGHT_ENABLE
uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
-void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); }
+void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
+#endif
+
+#ifdef AUDIO_ENABLE
+uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); }
+void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); }
#endif
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index caf0b0625..498068019 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -9,10 +9,16 @@
#include "suspend.h"
#include "timer.h"
#include "led.h"
+
#ifdef PROTOCOL_LUFA
-#include "lufa.h"
+ #include "lufa.h"
#endif
+#ifdef AUDIO_ENABLE
+ #include "audio.h"
+#endif /* AUDIO_ENABLE */
+
+
#define wdt_intr_enable(value) \
__asm__ __volatile__ ( \
@@ -66,9 +72,17 @@ static void power_down(uint8_t wdto)
wdt_intr_enable(wdto);
#ifdef BACKLIGHT_ENABLE
-backlight_set(0);
+ backlight_set(0);
#endif
+ // Turn off LED indicators
+ led_set(0);
+
+ #ifdef AUDIO_ENABLE
+ // This sometimes disables the start-up noise, so it's been disabled
+ // stop_all_notes();
+ #endif /* AUDIO_ENABLE */
+
// TODO: more power saving
// See PicoPower application note
// - I/O port input with pullup
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c
index 558ad9b01..2f6fc1cd6 100644
--- a/tmk_core/common/backlight.c
+++ b/tmk_core/common/backlight.c
@@ -37,7 +37,7 @@ void backlight_increase(void)
{
backlight_config.level++;
backlight_config.enable = 1;
- eeconfig_write_backlight(backlight_config.raw);
+ eeconfig_update_backlight(backlight_config.raw);
}
dprintf("backlight increase: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
@@ -49,7 +49,7 @@ void backlight_decrease(void)
{
backlight_config.level--;
backlight_config.enable = !!backlight_config.level;
- eeconfig_write_backlight(backlight_config.raw);
+ eeconfig_update_backlight(backlight_config.raw);
}
dprintf("backlight decrease: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
@@ -58,7 +58,7 @@ void backlight_decrease(void)
void backlight_toggle(void)
{
backlight_config.enable ^= 1;
- eeconfig_write_backlight(backlight_config.raw);
+ eeconfig_update_backlight(backlight_config.raw);
dprintf("backlight toggle: %u\n", backlight_config.enable);
backlight_set(backlight_config.enable ? backlight_config.level : 0);
}
@@ -71,7 +71,7 @@ void backlight_step(void)
backlight_config.level = 0;
}
backlight_config.enable = !!backlight_config.level;
- eeconfig_write_backlight(backlight_config.raw);
+ eeconfig_update_backlight(backlight_config.raw);
dprintf("backlight step: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
}
@@ -80,6 +80,6 @@ void backlight_level(uint8_t level)
{
backlight_config.level ^= level;
backlight_config.enable = !!backlight_config.level;
- eeconfig_write_backlight(backlight_config.raw);
+ eeconfig_update_backlight(backlight_config.raw);
backlight_set(backlight_config.level);
}
diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c
index b002a5856..2c1b1adfc 100644
--- a/tmk_core/common/bootmagic.c
+++ b/tmk_core/common/bootmagic.c
@@ -52,7 +52,7 @@ void bootmagic(void)
debug_config.enable = !debug_config.enable;
}
}
- eeconfig_write_debug(debug_config.raw);
+ eeconfig_update_debug(debug_config.raw);
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
@@ -80,7 +80,7 @@ void bootmagic(void)
if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) {
keymap_config.nkro = !keymap_config.nkro;
}
- eeconfig_write_keymap(keymap_config.raw);
+ eeconfig_update_keymap(keymap_config.raw);
#ifdef NKRO_ENABLE
keyboard_nkro = keymap_config.nkro;
@@ -97,7 +97,7 @@ void bootmagic(void)
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); }
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); }
if (default_layer) {
- eeconfig_write_default_layer(default_layer);
+ eeconfig_update_default_layer(default_layer);
default_layer_set((uint32_t)default_layer);
} else {
default_layer = eeconfig_read_default_layer();
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index d59bb01bb..f06abaf7f 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -49,9 +49,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "usbdrv.h"
#endif
+#ifdef AUDIO_ENABLE
+ #include "audio.h"
+#endif /* AUDIO_ENABLE */
+
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,38 +118,144 @@ 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)
{
+#ifndef NO_PRINT
print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");
debug_config_t dc;
@@ -172,30 +284,45 @@ static void print_eeconfig(void)
print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
print(".enable: "); print_dec(bc.enable); print("\n");
print(".level: "); print_dec(bc.level); print("\n");
-#endif
+#endif /* BACKLIGHT_ENABLE */
+
+#endif /* !NO_PRINT */
+
}
-#endif
+#endif /* BOOTMAGIC_ENABLE */
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 +334,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 +351,36 @@ 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... ");
+ #ifdef AUDIO_ENABLE
+ play_goodbye_tone();
+ #endif
_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 +389,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 +400,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 +434,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;
@@ -412,6 +562,7 @@ static uint8_t mousekey_param = 0;
static void mousekey_param_print(void)
{
+#ifndef NO_PRINT
print("\n\t- Values -\n");
print("1: delay(*10ms): "); pdec(mk_delay); print("\n");
print("2: interval(ms): "); pdec(mk_interval); print("\n");
@@ -419,6 +570,8 @@ static void mousekey_param_print(void)
print("4: time_to_max: "); pdec(mk_time_to_max); print("\n");
print("5: wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n");
print("6: wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
+#endif /* !NO_PRINT */
+
}
//#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
@@ -538,7 +691,7 @@ static void mousekey_console_help(void)
"pgdown: -10\n"
"\n"
"speed = delta * max_speed * (repeat / time_to_max)\n");
- xprintf("where delta: cursor=%d, wheel=%d\n"
+ xprintf("where delta: cursor=%d, wheel=%d\n"
"See http://en.wikipedia.org/wiki/Mouse_keys\n", MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA);
}
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/eeconfig.h b/tmk_core/common/eeconfig.h
index 3cd1a174f..ca47e0d2f 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_KEYMAP (uint8_t *)4
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
#define EECONFIG_BACKLIGHT (uint8_t *)6
+#define EECONFIG_AUDIO (uint8_t *)7
/* debug bit */
@@ -59,17 +60,22 @@ void eeconfig_enable(void);
void eeconfig_disable(void);
uint8_t eeconfig_read_debug(void);
-void eeconfig_write_debug(uint8_t val);
+void eeconfig_update_debug(uint8_t val);
uint8_t eeconfig_read_default_layer(void);
-void eeconfig_write_default_layer(uint8_t val);
+void eeconfig_update_default_layer(uint8_t val);
uint8_t eeconfig_read_keymap(void);
-void eeconfig_write_keymap(uint8_t val);
+void eeconfig_update_keymap(uint8_t val);
#ifdef BACKLIGHT_ENABLE
uint8_t eeconfig_read_backlight(void);
-void eeconfig_write_backlight(uint8_t val);
+void eeconfig_update_backlight(uint8_t val);
+#endif
+
+#ifdef AUDIO_ENABLE
+uint8_t eeconfig_read_audio(void);
+void eeconfig_update_audio(uint8_t val);
#endif
#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index eb7b096be..1d9981848 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -27,7 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "command.h"
#include "util.h"
#include "sendchar.h"
-#include "bootmagic.h"
+#ifdef BOOTMAGIC_ENABLE
+ #include "bootmagic.h"
+#else
+ #include "magic.h"
+#endif
#include "eeconfig.h"
#include "backlight.h"
#ifdef MOUSEKEY_ENABLE
@@ -70,6 +74,7 @@ void keyboard_setup(void)
void keyboard_init(void)
{
+
timer_init();
matrix_init();
#ifdef PS2_MOUSE_ENABLE
@@ -85,11 +90,18 @@ void keyboard_init(void)
#ifdef BOOTMAGIC_ENABLE
bootmagic();
+#else
+ magic();
#endif
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif
+
+#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
+ keyboard_nkro = true;
+#endif
+
}
/*
diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c
index 11f4aa8aa..8955fc710 100644
--- a/tmk_core/common/keymap.c
+++ b/tmk_core/common/keymap.c
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_macro.h"
#include "wait.h"
#include "debug.h"
-
+#include "bootloader.h"
static action_t keycode_to_action(uint8_t keycode);
@@ -143,6 +143,7 @@ static action_t keycode_to_action(uint8_t keycode)
action.code = ACTION_TRANSPARENT;
break;
case KC_BOOTLOADER:
+ action.code = ACTION_NO;
clear_keyboard();
wait_ms(50);
bootloader_jump(); // not return
diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h
index e1a6f992e..abc9bdb32 100644
--- a/tmk_core/common/keymap.h
+++ b/tmk_core/common/keymap.h
@@ -22,8 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include "action.h"
-
-#ifdef BOOTMAGIC_ENABLE
/* NOTE: Not portable. Bit field order depends on implementation */
typedef union {
uint8_t raw;
@@ -39,7 +37,6 @@ typedef union {
};
} keymap_config_t;
keymap_config_t keymap_config;
-#endif
/* translates key to keycode */
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
new file mode 100644
index 000000000..f21d1346c
--- /dev/null
+++ b/tmk_core/common/magic.c
@@ -0,0 +1,36 @@
+#include <stdint.h>
+#include <stdbool.h>
+#include <util/delay.h>
+#include "matrix.h"
+#include "bootloader.h"
+#include "debug.h"
+#include "keymap.h"
+#include "host.h"
+#include "action_layer.h"
+#include "eeconfig.h"
+#include "magic.h"
+
+keymap_config_t keymap_config;
+
+void magic(void)
+{
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+
+ /* debug enable */
+ debug_config.raw = eeconfig_read_debug();
+
+ /* keymap config */
+ keymap_config.raw = eeconfig_read_keymap();
+
+#ifdef NKRO_ENABLE
+ keyboard_nkro = keymap_config.nkro;
+#endif
+
+ uint8_t default_layer = 0;
+ default_layer = eeconfig_read_default_layer();
+ default_layer_set((uint32_t)default_layer);
+
+} \ No newline at end of file
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h
new file mode 100644
index 000000000..3fa2d8b81
--- /dev/null
+++ b/tmk_core/common/magic.h
@@ -0,0 +1,6 @@
+#ifndef MAGIC_H
+#define MAGIC_H
+
+void magic(void);
+
+#endif
diff --git a/tmk_core/common/print.h b/tmk_core/common/print.h
index c0e9e1430..4f3dde65a 100644
--- a/tmk_core/common/print.h
+++ b/tmk_core/common/print.h
@@ -2,17 +2,17 @@
/* Very basic print functions, intended to be used with usb_debug_only.c
* http://www.pjrc.com/teensy/
* Copyright (c) 2008 PJRC.COM, LLC
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -91,9 +91,9 @@ void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
#else /* NO_PRINT */
-#define xprintf
-#define print
-#define println
+#define xprintf(fmt, ...)
+#define print(s)
+#define println(s)
#define print_set_sendchar(func)
#define print_dec(data)
#define print_decs(data)