From b52e29582aa591eb9abbf131981f750de56e3e21 Mon Sep 17 00:00:00 2001 From: Michael Tharp Date: Sun, 14 Dec 2014 12:50:47 -0500 Subject: Improve anti-ghosting behavior for fast typing Keypresses would be forgotten if they began while ghosting, even if they were still pressed after ghosting ended. --- tmk_core/common/keyboard.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 1e3fb510a4..f0ead604ec 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -87,6 +87,9 @@ void keyboard_init(void) void keyboard_task(void) { static matrix_row_t matrix_prev[MATRIX_ROWS]; +#ifdef MATRIX_HAS_GHOST + static matrix_row_t matrix_ghost[MATRIX_ROWS]; +#endif static uint8_t led_status = 0; matrix_row_t matrix_row = 0; matrix_row_t matrix_change = 0; @@ -96,13 +99,21 @@ void keyboard_task(void) matrix_row = matrix_get_row(r); matrix_change = matrix_row ^ matrix_prev[r]; if (matrix_change) { - if (debug_matrix) matrix_print(); #ifdef MATRIX_HAS_GHOST if (has_ghost_in_row(r)) { - matrix_prev[r] = matrix_row; + /* Keep track of whether ghosted status has changed for + * debugging. But don't update matrix_prev until un-ghosted, or + * the last key would be lost. + */ + if (debug_matrix && matrix_ghost[r] != matrix_row) { + matrix_print(); + } + matrix_ghost[r] = matrix_row; continue; } + matrix_ghost[r] = matrix_row; #endif + if (debug_matrix) matrix_print(); for (uint8_t c = 0; c < MATRIX_COLS; c++) { if (matrix_change & ((matrix_row_t)1< Date: Thu, 23 Apr 2015 17:02:28 +0900 Subject: Fix handling of consumer usage #199 --- tmk_core/common/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 4c0b61b8c1..9f4fab5216 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -131,7 +131,7 @@ static action_t keycode_to_action(uint8_t keycode) case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); break; - case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: + case KC_AUDIO_MUTE ... KC_MEDIA_REWIND: action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); break; case KC_MS_UP ... KC_MS_ACCEL2: -- cgit v1.2.3 From 1f4a22ee81ec1986d1ca190c78c66231d37b50e2 Mon Sep 17 00:00:00 2001 From: Jun Wako Date: Thu, 23 Apr 2015 20:15:35 +0900 Subject: Remove unneeded tap delays #201 --- tmk_core/common/action.c | 7 ++++++- tmk_core/common/action_code.h | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index ec8eeae7bc..1f15bd0918 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -518,7 +518,12 @@ bool is_tap_key(keypos_t key) case ACT_RMODS_TAP: case ACT_LAYER_TAP: case ACT_LAYER_TAP_EXT: - return true; + switch (action.layer_tap.code) { + case 0x00 ... 0xdf: + case OP_TAP_TOGGLE: + return true; + } + return false; case ACT_MACRO: case ACT_FUNCTION: if (action.func.opt & FUNC_TAP) { return true; } diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index bc40e2c6fb..32ef07216d 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h @@ -70,13 +70,13 @@ along with this program. If not, see . * 1001|oopp|BBBB BBBB 8-bit Bitwise Operation??? * * ACT_LAYER_TAP(101x): - * 101E|LLLL| keycode On/Off with tap key - * 101E|LLLL|1110 mods On/Off with modifiers(0xE0-EF) - * 101E|LLLL|1111 0000 Invert with tap toggle(0xF0) - * 101E|LLLL|1111 0001 On/Off - * 101E|LLLL|1111 0010 Off/On - * 101E|LLLL|1111 0011 Set/Clear - * 101E|LLLL|1111 xxxx Reserved(0xF4-FF) + * 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP] + * 101E|LLLL|1110 mods On/Off with modifiers (0xE0-EF)[NOT TAP] + * 101E|LLLL|1111 0000 Invert with tap toggle (0xF0) [TAP] + * 101E|LLLL|1111 0001 On/Off (0xF1) [NOT TAP] + * 101E|LLLL|1111 0010 Off/On (0xF2) [NOT TAP] + * 101E|LLLL|1111 0011 Set/Clear (0xF3) [NOT TAP] + * 101E|LLLL|1111 xxxx Reserved (0xF4-FF) * ELLLL: layer 0-31(E: extra bit for layer 16-31) * * -- cgit v1.2.3 From 192024124b65fb65a65b44eef0bbc308c5971cea Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 13 May 2015 15:01:49 +0900 Subject: Add description of AVR bootloader and boot section --- tmk_core/common/avr/bootloader.c | 49 +++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index cda295b181..7c744e8c79 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -11,12 +11,49 @@ #endif -/* Boot Section Size in *BYTEs* - * Teensy halfKay 512 - * Teensy++ halfKay 1024 - * Atmel DFU loader 4096 - * LUFA bootloader 4096 - * USBaspLoader 2048 +/* Bootloader Size in *bytes* + * + * AVR Boot section size are defined by setting BOOTSZ fuse in fact. Consult with your MCU datasheet. + * Note that 'Word'(2 bytes) size and address are used in datasheet while TMK uses 'Byte'. + * + * + * Size of Bootloaders in bytes: + * Atmel DFU loader(ATmega32U4) 4096 + * Atmel DFU loader(AT90USB128) 8192 + * LUFA bootloader(ATmega32U4) 4096 + * Arduino Caterina(ATmega32U4) 4096 + * USBaspLoader(ATmega***) 2048 + * Teensy halfKay(ATmega32U4) 512 + * Teensy++ halfKay(AT90USB128) 1024 + * + * + * AVR Boot section is located at the end of Flash memory like the followings. + * + * + * byte Atmel/LUFA(ATMega32u4) byte Atmel(AT90SUB128) + * 0x0000 +---------------+ 0x00000 +---------------+ + * | | | | + * | | | | + * | Application | | Application | + * | | | | + * = = = = + * | | 32KB-4KB | | 128KB-8KB + * 0x6000 +---------------+ 0x1FC00 +---------------+ + * | Bootloader | 4KB | Bootloader | 8KB + * 0x7FFF +---------------+ 0x1FFFF +---------------+ + * + * + * byte Teensy(ATMega32u4) byte Teensy++(AT90SUB128) + * 0x0000 +---------------+ 0x00000 +---------------+ + * | | | | + * | | | | + * | Application | | Application | + * | | | | + * = = = = + * | | 32KB-512B | | 128KB-1KB + * 0x7E00 +---------------+ 0x1FC00 +---------------+ + * | Bootloader | 512B | Bootloader | 1KB + * 0x7FFF +---------------+ 0x1FFFF +---------------+ */ #ifndef BOOTLOADER_SIZE #warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h. -- cgit v1.2.3 From 67137a908aaf22fbd0509fbc127a092b9c0ff84f Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 13 May 2015 15:29:30 +0900 Subject: Reduce code size of magic commands --- tmk_core/common/command.c | 195 +++++++++++++++++++++------------------------- 1 file changed, 90 insertions(+), 105 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index fbaa9f2d75..1b6808be0e 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -112,30 +112,33 @@ bool command_console_extra(uint8_t code) ***********************************************************/ static void command_common_help(void) { - print("\n\n----- Command Help -----\n"); - print("c: enter console mode\n"); - print("d: toggle debug enable\n"); - print("x: toggle matrix debug\n"); - print("k: toggle keyboard debug\n"); - print("m: toggle mouse debug\n"); -#ifdef SLEEP_LED_ENABLE - print("z: toggle sleep LED test\n"); + 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" + +#ifdef KEYBOARD_LOCK_ENABLE + "Caps: Lock\n" +#endif + +#ifdef BOOTMAGIC_ENABLE + "e: eeprom\n" #endif - print("v: print device version & info\n"); - print("t: print timer count\n"); - print("s: print status\n"); - print("e: print eeprom config\n"); + #ifdef NKRO_ENABLE - print("n: toggle NKRO\n"); + "n: NKRO\n" +#endif + +#ifdef SLEEP_LED_ENABLE + "z: sleep LED test\n" #endif - print("0/F10: switch to Layer0 \n"); - print("1/F1: switch to Layer1 \n"); - print("2/F2: switch to Layer2 \n"); - print("3/F3: switch to Layer3 \n"); - print("4/F4: switch to Layer4 \n"); - print("PScr: power down/remote wake-up\n"); - print("Caps: Lock Keyboard(Child Proof)\n"); - print("Paus: jump to bootloader\n"); + ); } #ifdef BOOTMAGIC_ENABLE @@ -191,6 +194,7 @@ static bool command_common(uint8_t code) print_eeconfig(); break; #endif +#ifdef KEYBOARD_LOCK_ENABLE case KC_CAPSLOCK: if (host_get_driver()) { host_driver = host_get_driver(); @@ -202,6 +206,7 @@ static bool command_common(uint8_t code) print("Unlocked.\n"); } break; +#endif case KC_H: case KC_SLASH: /* ? */ command_common_help(); @@ -212,58 +217,56 @@ static bool command_common(uint8_t code) debug_mouse = false; debug_enable = false; command_console_help(); - print("\nEnter Console Mode\n"); print("C> "); command_state = CONSOLE; break; case KC_PAUSE: clear_keyboard(); - print("\n\nJump to bootloader... "); + print("\n\nbootloader... "); _delay_ms(1000); bootloader_jump(); // not return - print("not supported.\n"); break; case KC_D: if (debug_enable) { - print("\nDEBUG: disabled.\n"); + print("\ndebug: on\n"); debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; } else { - print("\nDEBUG: enabled.\n"); + print("\ndebug: off\n"); debug_enable = true; } break; case KC_X: // debug matrix toggle debug_matrix = !debug_matrix; if (debug_matrix) { - print("\nDEBUG: matrix enabled.\n"); + print("\nmatrix: on\n"); debug_enable = true; } else { - print("\nDEBUG: matrix disabled.\n"); + print("\nmatrix: off\n"); } break; case KC_K: // debug keyboard toggle debug_keyboard = !debug_keyboard; if (debug_keyboard) { - print("\nDEBUG: keyboard enabled.\n"); + print("\nkeyboard: on\n"); debug_enable = true; } else { - print("\nDEBUG: keyboard disabled.\n"); + print("\nkeyboard: off\n"); } break; case KC_M: // debug mouse toggle debug_mouse = !debug_mouse; if (debug_mouse) { - print("\nDEBUG: mouse enabled.\n"); + print("\nmouse: on\n"); debug_enable = true; } else { - print("\nDEBUG: mouse disabled.\n"); + print("\nmouse: off\n"); } break; case KC_V: // print version & information - print("\n\n----- Version -----\n"); + print("\n\t- Version -\n"); print("DESC: " STR(DESCRIPTION) "\n"); print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " @@ -307,14 +310,13 @@ static bool command_common(uint8_t code) " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n"); break; - case KC_T: // print timer - print_val_hex32(timer_count); - break; case KC_S: - print("\n\n----- Status -----\n"); + print("\n\t- Status -\n"); print_val_hex8(host_keyboard_leds()); print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_idle); + print_val_hex32(timer_count); + #ifdef PROTOCOL_PJRC print_val_hex8(UDCON); print_val_hex8(UDIEN); @@ -334,39 +336,21 @@ static bool command_common(uint8_t code) clear_keyboard(); //Prevents stuck keys. keyboard_nkro = !keyboard_nkro; if (keyboard_nkro) - print("NKRO: enabled\n"); + print("NKRO: on\n"); else - print("NKRO: disabled\n"); - break; -#endif -#ifdef EXTRAKEY_ENABLE - case KC_PSCREEN: - // TODO: Power key should take this feature? otherwise any key during suspend. -#ifdef PROTOCOL_PJRC - if (suspend && remote_wakeup) { - usb_remote_wakeup(); - } else { - host_system_send(SYSTEM_POWER_DOWN); - host_system_send(0); - _delay_ms(500); - } -#else - host_system_send(SYSTEM_POWER_DOWN); - _delay_ms(100); - host_system_send(0); - _delay_ms(500); -#endif + print("NKRO: off\n"); break; #endif case KC_ESC: case KC_GRV: case KC_0: + case KC_F10: switch_default_layer(0); break; case KC_1 ... KC_9: switch_default_layer((code - KC_1) + 1); break; - case KC_F1 ... KC_F12: + case KC_F1 ... KC_F9: switch_default_layer((code - KC_F1) + 1); break; default: @@ -382,11 +366,12 @@ static bool command_common(uint8_t code) ***********************************************************/ static void command_console_help(void) { - print("\n\n----- Console Help -----\n"); - print("ESC/q: quit\n"); + print("\n\t- Console -\n" + "ESC/q: quit\n" #ifdef MOUSEKEY_ENABLE - print("m: mousekey\n"); + "m: mousekey\n" #endif + ); } static bool command_console(uint8_t code) @@ -398,14 +383,12 @@ static bool command_console(uint8_t code) break; case KC_Q: case KC_ESC: - print("\nQuit Console Mode\n"); command_state = ONESHOT; return false; #ifdef MOUSEKEY_ENABLE case KC_M: mousekey_console_help(); - print("\nEnter Mousekey Console\n"); - print("M0>"); + print("M> "); command_state = MOUSEKEY; return true; #endif @@ -426,16 +409,17 @@ static uint8_t mousekey_param = 0; static void mousekey_param_print(void) { - print("\n\n----- Mousekey Parameters -----\n"); - print("1: mk_delay(*10ms): "); pdec(mk_delay); print("\n"); - print("2: mk_interval(ms): "); pdec(mk_interval); print("\n"); - print("3: mk_max_speed: "); pdec(mk_max_speed); print("\n"); - print("4: mk_time_to_max: "); pdec(mk_time_to_max); print("\n"); - print("5: mk_wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n"); - print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); + print("\n\t- Values -\n"); + print("1: delay(*10ms): "); pdec(mk_delay); print("\n"); + print("2: interval(ms): "); pdec(mk_interval); print("\n"); + print("3: max_speed: "); pdec(mk_max_speed); print("\n"); + 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"); } -#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n"); +//#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n"); +#define PRINT_SET_VAL(v) xprintf(#v " = %d\n", (v)) static void mousekey_param_inc(uint8_t param, uint8_t inc) { switch (param) { @@ -534,24 +518,25 @@ static void mousekey_param_dec(uint8_t param, uint8_t dec) static void mousekey_console_help(void) { - print("\n\n----- Mousekey Parameters Help -----\n"); - print("ESC/q: quit\n"); - print("1: select mk_delay(*10ms)\n"); - print("2: select mk_interval(ms)\n"); - print("3: select mk_max_speed\n"); - print("4: select mk_time_to_max\n"); - print("5: select mk_wheel_max_speed\n"); - print("6: select mk_wheel_time_to_max\n"); - print("p: print parameters\n"); - print("d: set default values\n"); - print("up: increase parameters(+1)\n"); - print("down: decrease parameters(-1)\n"); - print("pgup: increase parameters(+10)\n"); - print("pgdown: decrease parameters(-10)\n"); - print("\nspeed = delta * max_speed * (repeat / time_to_max)\n"); - print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA); - print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n"); - print("See http://en.wikipedia.org/wiki/Mouse_keys\n"); + print("\n\t- Mousekey -\n" + "ESC/q: quit\n" + "1: delay(*10ms)\n" + "2: interval(ms)\n" + "3: max_speed\n" + "4: time_to_max\n" + "5: wheel_max_speed\n" + "6: wheel_time_to_max\n" + "\n" + "p: print values\n" + "d: set defaults\n" + "up: +1\n" + "down: -1\n" + "pgup: +10\n" + "pgdown: -10\n" + "\n" + "speed = delta * max_speed * (repeat / time_to_max)\n"); + xprintf("where delta: cursor=%d, wheel=%d\n" + "See http://en.wikipedia.org/wiki/Mouse_keys\n", MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA); } static bool mousekey_console(uint8_t code) @@ -563,11 +548,14 @@ static bool mousekey_console(uint8_t code) break; case KC_Q: case KC_ESC: - mousekey_param = 0; - print("\nQuit Mousekey Console\n"); - print("C> "); - command_state = CONSOLE; - return false; + if (mousekey_param) { + mousekey_param = 0; + } else { + print("C> "); + command_state = CONSOLE; + return false; + } + break; case KC_P: mousekey_param_print(); break; @@ -577,12 +565,7 @@ static bool mousekey_console(uint8_t code) case KC_4: case KC_5: case KC_6: - case KC_7: - case KC_8: - case KC_9: - case KC_0: mousekey_param = numkey2num(code); - print("selected parameter: "); pdec(mousekey_param); print("\n"); break; case KC_UP: mousekey_param_inc(mousekey_param, 1); @@ -603,13 +586,16 @@ static bool mousekey_console(uint8_t code) mk_time_to_max = MOUSEKEY_TIME_TO_MAX; mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; - print("set default values.\n"); + print("set default\n"); break; default: print("?"); return false; } - print("M"); pdec(mousekey_param); print("> "); + if (mousekey_param) + xprintf("M%d> ", mousekey_param); + else + print("M>" ); return true; } #endif @@ -637,8 +623,7 @@ static uint8_t numkey2num(uint8_t code) static void switch_default_layer(uint8_t layer) { - print("switch_default_layer: "); print_dec(biton32(default_layer_state)); - print(" to "); print_dec(layer); print("\n"); + xprintf("L%d\n", layer); default_layer_set(1UL< Date: Sun, 17 May 2015 19:34:34 +0900 Subject: Add keyboard_setup() and matrix_setup() --- tmk_core/common/avr/suspend.c | 2 ++ tmk_core/common/keyboard.c | 6 ++++++ tmk_core/common/keyboard.h | 8 +++++--- tmk_core/common/matrix.h | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 80243f02bc..af99f52b5e 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -85,6 +85,8 @@ void suspend_power_down(void) power_down(WDTO_15MS); } +__attribute__ ((weak)) void matrix_power_up(void) {} +__attribute__ ((weak)) void matrix_power_down(void) {} bool suspend_wakeup_condition(void) { matrix_power_up(); diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index b03b124d76..eb7b096bed 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -62,6 +62,12 @@ static bool has_ghost_in_row(uint8_t row) #endif +__attribute__ ((weak)) void matrix_setup(void) {} +void keyboard_setup(void) +{ + matrix_setup(); +} + void keyboard_init(void) { timer_init(); diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index 6442716fc7..7738251b64 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h @@ -58,13 +58,15 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && } +/* it runs once at early stage of startup before keyboard_init. */ +void keyboard_setup(void); +/* it runs once after initializing host side protocol, debug and MCU peripherals. */ void keyboard_init(void); +/* it runs repeatedly in main loop */ void keyboard_task(void); +/* it runs when host LED status is updated */ void keyboard_set_leds(uint8_t leds); -__attribute__ ((weak)) void matrix_power_up(void) {} -__attribute__ ((weak)) void matrix_power_down(void) {} - #ifdef __cplusplus } #endif diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index 107ee72653..ec6f8cd431 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h @@ -43,7 +43,9 @@ extern "C" { uint8_t matrix_rows(void); /* number of matrix columns */ uint8_t matrix_cols(void); -/* intialize matrix for scaning. should be called once. */ +/* should be called at early stage of startup before matrix_init.(optional) */ +void matrix_setup(void); +/* intialize matrix for scaning. */ void matrix_init(void); /* scan all key states on matrix */ uint8_t matrix_scan(void); -- cgit v1.2.3 From c17b8a599e3ec3b0a327bcd66082541f2517ab30 Mon Sep 17 00:00:00 2001 From: Dan McGregor Date: Tue, 19 May 2015 11:29:28 -0700 Subject: Make action_for_key a weak symbol --- tmk_core/common/action.h | 1 + tmk_core/common/keymap.c | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'tmk_core/common') diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index 8a4736d7bc..e76161c17f 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h @@ -51,6 +51,7 @@ void action_exec(keyevent_t event); /* action for key */ action_t action_for_key(uint8_t layer, keypos_t key); +action_t action_for_key_default(uint8_t layer, keypos_t key); /* macro */ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 9f4fab5216..a43ca460f2 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -27,8 +27,13 @@ static action_t keycode_to_action(uint8_t keycode); /* converts key to action */ +__attribute__((__weak__)) action_t action_for_key(uint8_t layer, keypos_t key) { + return action_for_key_default(layer, key); +} + +action_t action_for_key_default(uint8_t layer, keypos_t key) uint8_t keycode = keymap_key_to_keycode(layer, key); switch (keycode) { case KC_FN0 ... KC_FN31: -- cgit v1.2.3 From 5b46031658a69104526ef43284acd943ba21b772 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 21 May 2015 20:30:10 +0900 Subject: Revert "Make action_for_key a weak symbol" This reverts commit c17b8a599e3ec3b0a327bcd66082541f2517ab30. The commit made compile error and its intention is unclear. --- tmk_core/common/action.h | 1 - tmk_core/common/keymap.c | 5 ----- 2 files changed, 6 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index e76161c17f..8a4736d7bc 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h @@ -51,7 +51,6 @@ void action_exec(keyevent_t event); /* action for key */ action_t action_for_key(uint8_t layer, keypos_t key); -action_t action_for_key_default(uint8_t layer, keypos_t key); /* macro */ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index a43ca460f2..9f4fab5216 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -27,13 +27,8 @@ static action_t keycode_to_action(uint8_t keycode); /* converts key to action */ -__attribute__((__weak__)) action_t action_for_key(uint8_t layer, keypos_t key) { - return action_for_key_default(layer, key); -} - -action_t action_for_key_default(uint8_t layer, keypos_t key) uint8_t keycode = keymap_key_to_keycode(layer, key); switch (keycode) { case KC_FN0 ... KC_FN31: -- cgit v1.2.3 From 070a6be63808cdb6c4ec9e12ad708718cfdc3dfb Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 26 Jun 2015 08:34:10 +0900 Subject: Add description for non-US keys on keycode.h --- tmk_core/common/keycode.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index ac4ef00db6..fc66dc0efc 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -214,7 +214,7 @@ enum hid_keyboard_keypad_usage { KC_LBRACKET, KC_RBRACKET, /* 0x30 */ KC_BSLASH, /* \ (and |) */ - KC_NONUS_HASH, /* Non-US # and ~ */ + KC_NONUS_HASH, /* Non-US # and ~ (Typically near the Enter key) */ KC_SCOLON, /* ; (and :) */ KC_QUOTE, /* ' and " */ KC_GRAVE, /* Grave accent and tilde */ @@ -264,7 +264,7 @@ enum hid_keyboard_keypad_usage { KC_KP_9, KC_KP_0, KC_KP_DOT, - KC_NONUS_BSLASH, /* Non-US \ and | */ + KC_NONUS_BSLASH, /* Non-US \ and | (Typically near the Left-Shift key) */ KC_APPLICATION, KC_POWER, KC_KP_EQUAL, -- cgit v1.2.3 From 6f5e8ce17e89005130cd0f9ecc6e346a77bb624b Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 15 Jul 2015 15:13:15 +0900 Subject: usb_usb: Support locking key indicator LED --- tmk_core/common/led.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tmk_core/common') diff --git a/tmk_core/common/led.h b/tmk_core/common/led.h index 402a247b9a..d5fc051bf5 100644 --- a/tmk_core/common/led.h +++ b/tmk_core/common/led.h @@ -28,6 +28,14 @@ along with this program. If not, see . #define USB_LED_KANA 4 +#ifdef __cplusplus +extern "C" { +#endif + void led_set(uint8_t usb_led); +#ifdef __cplusplus +} +#endif + #endif -- cgit v1.2.3 From 0c21b263f9bc11e3999d7ea28e78d36663abf02c Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 12 Sep 2015 11:25:41 +0900 Subject: Fix weak modifier clear in action macro --- tmk_core/common/action_macro.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tmk_core/common') diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c index ba93fc8b23..ffaf125c06 100644 --- a/tmk_core/common/action_macro.c +++ b/tmk_core/common/action_macro.c @@ -42,6 +42,7 @@ void action_macro_play(const macro_t *macro_p) dprintf("KEY_DOWN(%02X)\n", macro); if (IS_MOD(macro)) { add_weak_mods(MOD_BIT(macro)); + send_keyboard_report(); } else { register_code(macro); } @@ -51,6 +52,7 @@ void action_macro_play(const macro_t *macro_p) dprintf("KEY_UP(%02X)\n", macro); if (IS_MOD(macro)) { del_weak_mods(MOD_BIT(macro)); + send_keyboard_report(); } else { unregister_code(macro); } -- cgit v1.2.3 From a8d4daa7617c72cc32b5186271d4d35a7beffb82 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 12 Sep 2015 11:26:37 +0900 Subject: Fix parenthesis --- tmk_core/common/action_code.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 32ef07216d..4fe9c1d581 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h @@ -266,7 +266,7 @@ enum layer_pram_tap_op { #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) #define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) -#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f) +#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | ((mods)&0x0f)) /* With Tapping */ #define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) #define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE) -- cgit v1.2.3 From bb8c1d29fa123c430bccb5b8568d55a691bc1c81 Mon Sep 17 00:00:00 2001 From: skullY Date: Tue, 15 Sep 2015 09:17:02 -0700 Subject: Add an assignable RESET key --- tmk_core/common/keycode.h | 3 +++ tmk_core/common/keymap.c | 9 +++++++++ 2 files changed, 12 insertions(+) (limited to 'tmk_core/common') diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index fc66dc0efc..b2417a6c9d 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -426,6 +426,9 @@ enum internal_special_keycodes { KC_MEDIA_FAST_FORWARD, KC_MEDIA_REWIND, /* 0xBC */ + /* Jump to bootloader */ + KC_RESET = 0xBF, + /* Fn key */ KC_FN0 = 0xC0, KC_FN1, diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index 9f4fab5216..bf7ddee792 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -14,6 +14,7 @@ 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 . */ +#include #include "keymap.h" #include "report.h" #include "keycode.h" @@ -21,6 +22,7 @@ along with this program. If not, see . #include "action.h" #include "action_macro.h" #include "debug.h" +#include "print.h" static action_t keycode_to_action(uint8_t keycode); @@ -140,6 +142,13 @@ static action_t keycode_to_action(uint8_t keycode) case KC_TRNS: action.code = ACTION_TRANSPARENT; break; + case KC_RESET: + clear_keyboard(); + print("\n\nJump to bootloader... "); + _delay_ms(50); + bootloader_jump(); + print("not supported.\n"); + break; default: action.code = ACTION_NO; break; -- cgit v1.2.3 From 498654fc4c693c8a40e9285063797b9a6324ac18 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 16 Sep 2015 12:42:38 +0900 Subject: Change to KC_BOOTLOADER(KC_BTLD) --- tmk_core/common/keycode.h | 4 +++- tmk_core/common/keymap.c | 11 ++++------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h index b2417a6c9d..448195306f 100644 --- a/tmk_core/common/keycode.h +++ b/tmk_core/common/keycode.h @@ -156,6 +156,8 @@ along with this program. If not, see . #define KC_WSTP KC_WWW_STOP #define KC_WREF KC_WWW_REFRESH #define KC_WFAV KC_WWW_FAVORITES +/* Jump to bootloader */ +#define KC_BTLD KC_BOOTLOADER /* Transparent */ #define KC_TRANSPARENT 1 #define KC_TRNS KC_TRANSPARENT @@ -427,7 +429,7 @@ enum internal_special_keycodes { KC_MEDIA_REWIND, /* 0xBC */ /* Jump to bootloader */ - KC_RESET = 0xBF, + KC_BOOTLOADER = 0xBF, /* Fn key */ KC_FN0 = 0xC0, diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c index bf7ddee792..d489238085 100644 --- a/tmk_core/common/keymap.c +++ b/tmk_core/common/keymap.c @@ -14,15 +14,14 @@ 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 . */ -#include #include "keymap.h" #include "report.h" #include "keycode.h" #include "action_layer.h" #include "action.h" #include "action_macro.h" +#include "wait.h" #include "debug.h" -#include "print.h" static action_t keycode_to_action(uint8_t keycode); @@ -142,12 +141,10 @@ static action_t keycode_to_action(uint8_t keycode) case KC_TRNS: action.code = ACTION_TRANSPARENT; break; - case KC_RESET: + case KC_BOOTLOADER: clear_keyboard(); - print("\n\nJump to bootloader... "); - _delay_ms(50); - bootloader_jump(); - print("not supported.\n"); + wait_ms(50); + bootloader_jump(); // not return break; default: action.code = ACTION_NO; -- cgit v1.2.3 From e8a4a63ec45cf5052d8a054182ab83fdbafc3ff6 Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 20 Sep 2015 10:51:30 +0900 Subject: core: Fix message print of debug command --- tmk_core/common/command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 1b6808be0e..a53cac6148 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -228,13 +228,13 @@ static bool command_common(uint8_t code) break; case KC_D: if (debug_enable) { - print("\ndebug: on\n"); + print("\ndebug: off\n"); debug_matrix = false; debug_keyboard = false; debug_mouse = false; debug_enable = false; } else { - print("\ndebug: off\n"); + print("\ndebug: on\n"); debug_enable = true; } break; -- cgit v1.2.3 From ed9766a7d44cd727dbd59008eff4258745ff87cf Mon Sep 17 00:00:00 2001 From: tmk Date: Sun, 20 Sep 2015 14:34:13 +0900 Subject: core: Fix for disabling NKRO in Boot protocol --- tmk_core/common/action_util.c | 6 +++--- tmk_core/common/command.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'tmk_core/common') diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index dbee630d18..f81877dd9f 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c @@ -76,7 +76,7 @@ void send_keyboard_report(void) { void add_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { add_key_bit(key); return; } @@ -87,7 +87,7 @@ void add_key(uint8_t key) void del_key(uint8_t key) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { del_key_bit(key); return; } @@ -160,7 +160,7 @@ uint8_t has_anymod(void) uint8_t get_first_key(void) { #ifdef NKRO_ENABLE - if (keyboard_nkro) { + if (keyboard_protocol && keyboard_nkro) { uint8_t i = 0; for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) ; diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index a53cac6148..420e7eb9b4 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -315,6 +315,7 @@ static bool command_common(uint8_t code) print_val_hex8(host_keyboard_leds()); print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_idle); + print_val_hex8(keyboard_nkro); print_val_hex32(timer_count); #ifdef PROTOCOL_PJRC -- cgit v1.2.3 From 77afc5a76f5d299d606ab5b6d870a40aee9cb0e3 Mon Sep 17 00:00:00 2001 From: Jun Wako Date: Thu, 24 Sep 2015 01:35:10 +0900 Subject: core: Fix NKRO ifdef --- tmk_core/common/command.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tmk_core/common') diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 420e7eb9b4..d59bb01bbc 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -315,7 +315,9 @@ static bool command_common(uint8_t code) 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 -- cgit v1.2.3