diff options
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | common.mk | 10 | ||||
| -rw-r--r-- | common/action.c | 547 | ||||
| -rw-r--r-- | common/action_macro.c | 3 | ||||
| -rw-r--r-- | common/action_macro.h | 4 | ||||
| -rw-r--r-- | common/action_oneshot.c | 21 | ||||
| -rw-r--r-- | common/action_oneshot.h | 52 | ||||
| -rw-r--r-- | common/command.c | 15 | ||||
| -rw-r--r-- | common/command.h | 4 | ||||
| -rw-r--r-- | common/debug.h | 31 | ||||
| -rw-r--r-- | common/keyboard.c | 2 | ||||
| -rw-r--r-- | common/layer_switch.c | 8 | ||||
| -rw-r--r-- | common/layer_switch.h | 30 | ||||
| -rw-r--r-- | common/print.c | 13 | ||||
| -rw-r--r-- | common/print.h | 40 | ||||
| -rw-r--r-- | keyboard/gh60/Makefile.lufa | 3 | ||||
| -rw-r--r-- | keyboard/gh60/Makefile.pjrc | 3 | ||||
| -rw-r--r-- | keyboard/gh60/config.h | 20 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.iwrap | 5 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.lufa | 1 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.pjrc | 9 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.vusb | 5 | ||||
| -rw-r--r-- | keyboard/hhkb/config.h | 30 |
23 files changed, 531 insertions, 326 deletions
| @@ -171,6 +171,7 @@ Note that ***comment out*** to disable them. | |||
| 171 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 171 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
| 172 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 172 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 173 | CONSOLE_ENABLE = yes # Console for debug(+400) | 173 | CONSOLE_ENABLE = yes # Console for debug(+400) |
| 174 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 174 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 175 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend |
| 175 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | 176 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA |
| 176 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 177 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| @@ -2,10 +2,10 @@ COMMON_DIR = common | |||
| 2 | SRC += $(COMMON_DIR)/host.c \ | 2 | SRC += $(COMMON_DIR)/host.c \ |
| 3 | $(COMMON_DIR)/keyboard.c \ | 3 | $(COMMON_DIR)/keyboard.c \ |
| 4 | $(COMMON_DIR)/action.c \ | 4 | $(COMMON_DIR)/action.c \ |
| 5 | $(COMMON_DIR)/action_oneshot.c \ | ||
| 5 | $(COMMON_DIR)/action_macro.c \ | 6 | $(COMMON_DIR)/action_macro.c \ |
| 6 | $(COMMON_DIR)/layer_switch.c \ | 7 | $(COMMON_DIR)/layer_switch.c \ |
| 7 | $(COMMON_DIR)/keymap.c \ | 8 | $(COMMON_DIR)/keymap.c \ |
| 8 | $(COMMON_DIR)/command.c \ | ||
| 9 | $(COMMON_DIR)/timer.c \ | 9 | $(COMMON_DIR)/timer.c \ |
| 10 | $(COMMON_DIR)/print.c \ | 10 | $(COMMON_DIR)/print.c \ |
| 11 | $(COMMON_DIR)/debug.c \ | 11 | $(COMMON_DIR)/debug.c \ |
| @@ -31,6 +31,14 @@ endif | |||
| 31 | 31 | ||
| 32 | ifdef CONSOLE_ENABLE | 32 | ifdef CONSOLE_ENABLE |
| 33 | OPT_DEFS += -DCONSOLE_ENABLE | 33 | OPT_DEFS += -DCONSOLE_ENABLE |
| 34 | else | ||
| 35 | OPT_DEFS += -DNO_PRINT | ||
| 36 | OPT_DEFS += -DNO_DEBUG | ||
| 37 | endif | ||
| 38 | |||
| 39 | ifdef COMMAND_ENABLE | ||
| 40 | SRC += $(COMMON_DIR)/command.c | ||
| 41 | OPT_DEFS += -DCOMMAND_ENABLE | ||
| 34 | endif | 42 | endif |
| 35 | 43 | ||
| 36 | ifdef NKRO_ENABLE | 44 | ifdef NKRO_ENABLE |
diff --git a/common/action.c b/common/action.c index 4fafbfa79..c218808ab 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -25,21 +25,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #include "debug.h" | 25 | #include "debug.h" |
| 26 | #include "led.h" | 26 | #include "led.h" |
| 27 | #include "layer_switch.h" | 27 | #include "layer_switch.h" |
| 28 | #include "action_oneshot.h" | ||
| 28 | #include "action_macro.h" | 29 | #include "action_macro.h" |
| 29 | #include "action.h" | 30 | #include "action.h" |
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | static void process_action(keyrecord_t *record); | 33 | static void process_action(keyrecord_t *record); |
| 33 | static bool process_tapping(keyrecord_t *record); | ||
| 34 | static void waiting_buffer_scan_tap(void); | ||
| 35 | |||
| 36 | static void debug_event(keyevent_t event); | 34 | static void debug_event(keyevent_t event); |
| 37 | static void debug_record(keyrecord_t record); | 35 | static void debug_record(keyrecord_t record); |
| 38 | static void debug_action(action_t action); | 36 | static void debug_action(action_t action); |
| 39 | static void debug_tapping_key(void); | ||
| 40 | static void debug_waiting_buffer(void); | ||
| 41 | |||
| 42 | 37 | ||
| 38 | #ifndef NO_ACTION_TAPPING | ||
| 43 | /* | 39 | /* |
| 44 | * Tapping | 40 | * Tapping |
| 45 | */ | 41 | */ |
| @@ -70,94 +66,22 @@ static keyrecord_t tapping_key = {}; | |||
| 70 | */ | 66 | */ |
| 71 | #define WAITING_BUFFER_SIZE 8 | 67 | #define WAITING_BUFFER_SIZE 8 |
| 72 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; | 68 | static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; |
| 73 | |||
| 74 | /* point to empty cell to enq */ | 69 | /* point to empty cell to enq */ |
| 75 | static uint8_t waiting_buffer_head = 0; | 70 | static uint8_t waiting_buffer_head = 0; |
| 76 | |||
| 77 | /* point to the oldest data cell to deq */ | 71 | /* point to the oldest data cell to deq */ |
| 78 | static uint8_t waiting_buffer_tail = 0; | 72 | static uint8_t waiting_buffer_tail = 0; |
| 79 | 73 | ||
| 80 | static bool waiting_buffer_enq(keyrecord_t record) | ||
| 81 | { | ||
| 82 | if (IS_NOEVENT(record.event)) { | ||
| 83 | return true; | ||
| 84 | } | ||
| 85 | |||
| 86 | if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) { | ||
| 87 | debug("waiting_buffer_enq: Over flow.\n"); | ||
| 88 | return false; | ||
| 89 | } | ||
| 90 | |||
| 91 | waiting_buffer[waiting_buffer_head] = record; | ||
| 92 | waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE; | ||
| 93 | |||
| 94 | debug("waiting_buffer_enq: "); debug_waiting_buffer(); | ||
| 95 | return true; | ||
| 96 | } | ||
| 97 | |||
| 98 | static void waiting_buffer_clear(void) | ||
| 99 | { | ||
| 100 | waiting_buffer_head = 0; | ||
| 101 | waiting_buffer_tail = 0; | ||
| 102 | } | ||
| 103 | 74 | ||
| 75 | static bool process_tapping(keyrecord_t *record); | ||
| 76 | static bool waiting_buffer_enq(keyrecord_t record); | ||
| 77 | static void waiting_buffer_clear(void); | ||
| 104 | #if TAPPING_TERM >= 500 | 78 | #if TAPPING_TERM >= 500 |
| 105 | static bool waiting_buffer_typed(keyevent_t event) | 79 | static bool waiting_buffer_typed(keyevent_t event); |
| 106 | { | 80 | #endif |
| 107 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { | 81 | static void waiting_buffer_scan_tap(void); |
| 108 | if (KEYEQ(event.key, waiting_buffer[i].event.key) && event.pressed != waiting_buffer[i].event.pressed) { | 82 | static void debug_tapping_key(void); |
| 109 | return true; | 83 | static void debug_waiting_buffer(void); |
| 110 | } | ||
| 111 | } | ||
| 112 | return false; | ||
| 113 | } | ||
| 114 | #endif | 84 | #endif |
| 115 | |||
| 116 | bool waiting_buffer_has_anykey_pressed(void) | ||
| 117 | { | ||
| 118 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { | ||
| 119 | if (waiting_buffer[i].event.pressed) return true; | ||
| 120 | } | ||
| 121 | return false; | ||
| 122 | } | ||
| 123 | |||
| 124 | |||
| 125 | /* Oneshot modifier | ||
| 126 | * | ||
| 127 | * Problem: Want to capitalize like 'The' but the result tends to be 'THe'. | ||
| 128 | * Solution: Oneshot modifier have its effect on only one key coming next. | ||
| 129 | * Tap Shift, then type 't', 'h' and 'e'. Not need to hold Shift key. | ||
| 130 | * | ||
| 131 | * Hold: works as normal modifier. | ||
| 132 | * Tap: one shot modifier. | ||
| 133 | * 2 Tap: cancel one shot modifier. | ||
| 134 | * 5-Tap: toggles enable/disable oneshot feature. | ||
| 135 | */ | ||
| 136 | static struct { | ||
| 137 | uint8_t mods; | ||
| 138 | uint8_t time; | ||
| 139 | bool ready; | ||
| 140 | bool disabled; | ||
| 141 | } oneshot_state; | ||
| 142 | |||
| 143 | static void oneshot_start(uint8_t mods, uint16_t time) | ||
| 144 | { | ||
| 145 | oneshot_state.mods = mods; | ||
| 146 | oneshot_state.time = time; | ||
| 147 | oneshot_state.ready = true; | ||
| 148 | } | ||
| 149 | |||
| 150 | static void oneshot_cancel(void) | ||
| 151 | { | ||
| 152 | oneshot_state.mods = 0; | ||
| 153 | oneshot_state.time = 0; | ||
| 154 | oneshot_state.ready = false; | ||
| 155 | } | ||
| 156 | |||
| 157 | static void oneshot_toggle(void) | ||
| 158 | { | ||
| 159 | oneshot_state.disabled = !oneshot_state.disabled; | ||
| 160 | } | ||
| 161 | 85 | ||
| 162 | 86 | ||
| 163 | 87 | ||
| @@ -170,13 +94,12 @@ void action_exec(keyevent_t event) | |||
| 170 | 94 | ||
| 171 | keyrecord_t record = { .event = event }; | 95 | keyrecord_t record = { .event = event }; |
| 172 | 96 | ||
| 173 | // pre-process on tapping | 97 | #ifndef NO_ACTION_TAPPING |
| 174 | if (process_tapping(&record)) { | 98 | if (process_tapping(&record)) { |
| 175 | if (!IS_NOEVENT(record.event)) { | 99 | if (!IS_NOEVENT(record.event)) { |
| 176 | debug("processed: "); debug_record(record); debug("\n"); | 100 | debug("processed: "); debug_record(record); debug("\n"); |
| 177 | } | 101 | } |
| 178 | } else { | 102 | } else { |
| 179 | // enqueue | ||
| 180 | if (!waiting_buffer_enq(record)) { | 103 | if (!waiting_buffer_enq(record)) { |
| 181 | // clear all in case of overflow. | 104 | // clear all in case of overflow. |
| 182 | debug("OVERFLOW: CLEAR ALL STATES\n"); | 105 | debug("OVERFLOW: CLEAR ALL STATES\n"); |
| @@ -190,7 +113,6 @@ void action_exec(keyevent_t event) | |||
| 190 | if (!IS_NOEVENT(event) && waiting_buffer_head != waiting_buffer_tail) { | 113 | if (!IS_NOEVENT(event) && waiting_buffer_head != waiting_buffer_tail) { |
| 191 | debug("---- action_exec: process waiting_buffer -----\n"); | 114 | debug("---- action_exec: process waiting_buffer -----\n"); |
| 192 | } | 115 | } |
| 193 | |||
| 194 | for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { | 116 | for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { |
| 195 | if (process_tapping(&waiting_buffer[waiting_buffer_tail])) { | 117 | if (process_tapping(&waiting_buffer[waiting_buffer_tail])) { |
| 196 | debug("processed: waiting_buffer["); debug_dec(waiting_buffer_tail); debug("] = "); | 118 | debug("processed: waiting_buffer["); debug_dec(waiting_buffer_tail); debug("] = "); |
| @@ -202,6 +124,12 @@ void action_exec(keyevent_t event) | |||
| 202 | if (!IS_NOEVENT(event)) { | 124 | if (!IS_NOEVENT(event)) { |
| 203 | debug("\n"); | 125 | debug("\n"); |
| 204 | } | 126 | } |
| 127 | #else | ||
| 128 | process_action(&record); | ||
| 129 | if (!IS_NOEVENT(record.event)) { | ||
| 130 | debug("processed: "); debug_record(record); debug("\n"); | ||
| 131 | } | ||
| 132 | #endif | ||
| 205 | } | 133 | } |
| 206 | 134 | ||
| 207 | static void process_action(keyrecord_t *record) | 135 | static void process_action(keyrecord_t *record) |
| @@ -244,12 +172,14 @@ static void process_action(keyrecord_t *record) | |||
| 244 | } | 172 | } |
| 245 | } | 173 | } |
| 246 | break; | 174 | break; |
| 175 | #ifndef NO_ACTION_TAPPING | ||
| 247 | case ACT_LMODS_TAP: | 176 | case ACT_LMODS_TAP: |
| 248 | case ACT_RMODS_TAP: | 177 | case ACT_RMODS_TAP: |
| 249 | { | 178 | { |
| 250 | uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : | 179 | uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : |
| 251 | action.key.mods<<4; | 180 | action.key.mods<<4; |
| 252 | switch (action.layer.code) { | 181 | switch (action.layer.code) { |
| 182 | #ifndef NO_ACTION_ONESHOT | ||
| 253 | case 0x00: | 183 | case 0x00: |
| 254 | // Oneshot modifier | 184 | // Oneshot modifier |
| 255 | if (event.pressed) { | 185 | if (event.pressed) { |
| @@ -259,7 +189,7 @@ static void process_action(keyrecord_t *record) | |||
| 259 | } | 189 | } |
| 260 | else if (tap_count == 1) { | 190 | else if (tap_count == 1) { |
| 261 | debug("MODS_TAP: Oneshot: start\n"); | 191 | debug("MODS_TAP: Oneshot: start\n"); |
| 262 | oneshot_start(mods, event.time); | 192 | oneshot_start(mods); |
| 263 | } | 193 | } |
| 264 | else if (tap_count == TAPPING_TOGGLE) { | 194 | else if (tap_count == TAPPING_TOGGLE) { |
| 265 | debug("MODS_TAP: Oneshot: toggle\n"); | 195 | debug("MODS_TAP: Oneshot: toggle\n"); |
| @@ -290,6 +220,7 @@ static void process_action(keyrecord_t *record) | |||
| 290 | } | 220 | } |
| 291 | } | 221 | } |
| 292 | break; | 222 | break; |
| 223 | #endif | ||
| 293 | default: | 224 | default: |
| 294 | if (event.pressed) { | 225 | if (event.pressed) { |
| 295 | if (tap_count > 0) { | 226 | if (tap_count > 0) { |
| @@ -319,10 +250,10 @@ static void process_action(keyrecord_t *record) | |||
| 319 | } | 250 | } |
| 320 | } | 251 | } |
| 321 | break; | 252 | break; |
| 322 | 253 | #endif | |
| 254 | #ifdef EXTRAKEY_ENABLE | ||
| 323 | /* other HID usage */ | 255 | /* other HID usage */ |
| 324 | case ACT_USAGE: | 256 | case ACT_USAGE: |
| 325 | #ifdef EXTRAKEY_ENABLE | ||
| 326 | switch (action.usage.page) { | 257 | switch (action.usage.page) { |
| 327 | case PAGE_SYSTEM: | 258 | case PAGE_SYSTEM: |
| 328 | if (event.pressed) { | 259 | if (event.pressed) { |
| @@ -339,12 +270,11 @@ static void process_action(keyrecord_t *record) | |||
| 339 | } | 270 | } |
| 340 | break; | 271 | break; |
| 341 | } | 272 | } |
| 342 | #endif | ||
| 343 | break; | 273 | break; |
| 344 | 274 | #endif | |
| 275 | #ifdef MOUSEKEY_ENABLE | ||
| 345 | /* Mouse key */ | 276 | /* Mouse key */ |
| 346 | case ACT_MOUSEKEY: | 277 | case ACT_MOUSEKEY: |
| 347 | #ifdef MOUSEKEY_ENABLE | ||
| 348 | if (event.pressed) { | 278 | if (event.pressed) { |
| 349 | mousekey_on(action.key.code); | 279 | mousekey_on(action.key.code); |
| 350 | mousekey_send(); | 280 | mousekey_send(); |
| @@ -352,9 +282,9 @@ static void process_action(keyrecord_t *record) | |||
| 352 | mousekey_off(action.key.code); | 282 | mousekey_off(action.key.code); |
| 353 | mousekey_send(); | 283 | mousekey_send(); |
| 354 | } | 284 | } |
| 355 | #endif | ||
| 356 | break; | 285 | break; |
| 357 | 286 | #endif | |
| 287 | #ifndef NO_ACTION_KEYMAP | ||
| 358 | case ACT_KEYMAP: | 288 | case ACT_KEYMAP: |
| 359 | switch (action.layer.code) { | 289 | switch (action.layer.code) { |
| 360 | /* Keymap clear */ | 290 | /* Keymap clear */ |
| @@ -516,7 +446,8 @@ static void process_action(keyrecord_t *record) | |||
| 516 | break; | 446 | break; |
| 517 | } | 447 | } |
| 518 | break; | 448 | break; |
| 519 | 449 | #endif | |
| 450 | #ifndef NO_ACTION_OVERLAY | ||
| 520 | case ACT_OVERLAY: | 451 | case ACT_OVERLAY: |
| 521 | switch (action.layer.code) { | 452 | switch (action.layer.code) { |
| 522 | // Overlay Invert bit4 | 453 | // Overlay Invert bit4 |
| @@ -670,21 +601,218 @@ static void process_action(keyrecord_t *record) | |||
| 670 | break; | 601 | break; |
| 671 | } | 602 | } |
| 672 | break; | 603 | break; |
| 673 | 604 | #endif | |
| 674 | /* Extentions */ | 605 | /* Extentions */ |
| 606 | #ifndef NO_ACTION_MACRO | ||
| 675 | case ACT_MACRO: | 607 | case ACT_MACRO: |
| 676 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); | 608 | action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); |
| 677 | break; | 609 | break; |
| 610 | #endif | ||
| 678 | case ACT_COMMAND: | 611 | case ACT_COMMAND: |
| 679 | break; | 612 | break; |
| 613 | #ifndef NO_ACTION_FUNCTION | ||
| 680 | case ACT_FUNCTION: | 614 | case ACT_FUNCTION: |
| 681 | action_function(record, action.func.id, action.func.opt); | 615 | action_function(record, action.func.id, action.func.opt); |
| 682 | break; | 616 | break; |
| 617 | #endif | ||
| 683 | default: | 618 | default: |
| 684 | break; | 619 | break; |
| 685 | } | 620 | } |
| 686 | } | 621 | } |
| 687 | 622 | ||
| 623 | |||
| 624 | |||
| 625 | |||
| 626 | /* | ||
| 627 | * Utilities for actions. | ||
| 628 | */ | ||
| 629 | void register_code(uint8_t code) | ||
| 630 | { | ||
| 631 | if (code == KC_NO) { | ||
| 632 | return; | ||
| 633 | } | ||
| 634 | #ifdef CAPSLOCK_LOCKING_ENABLE | ||
| 635 | else if (KC_LOCKING_CAPS == code) { | ||
| 636 | #ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE | ||
| 637 | // Resync: ignore if caps lock already is on | ||
| 638 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return; | ||
| 639 | #endif | ||
| 640 | host_add_key(KC_CAPSLOCK); | ||
| 641 | host_send_keyboard_report(); | ||
| 642 | host_del_key(KC_CAPSLOCK); | ||
| 643 | host_send_keyboard_report(); | ||
| 644 | } | ||
| 645 | #endif | ||
| 646 | else if IS_KEY(code) { | ||
| 647 | // TODO: should push command_proc out of this block? | ||
| 648 | if (command_proc(code)) return; | ||
| 649 | |||
| 650 | #ifndef NO_ACTION_ONESHOT | ||
| 651 | if (oneshot_state.mods && !oneshot_state.disabled) { | ||
| 652 | uint8_t tmp_mods = host_get_mods(); | ||
| 653 | host_add_mods(oneshot_state.mods); | ||
| 654 | |||
| 655 | host_add_key(code); | ||
| 656 | host_send_keyboard_report(); | ||
| 657 | |||
| 658 | host_set_mods(tmp_mods); | ||
| 659 | oneshot_cancel(); | ||
| 660 | } else | ||
| 661 | #endif | ||
| 662 | { | ||
| 663 | host_add_key(code); | ||
| 664 | host_send_keyboard_report(); | ||
| 665 | } | ||
| 666 | } | ||
| 667 | else if IS_MOD(code) { | ||
| 668 | host_add_mods(MOD_BIT(code)); | ||
| 669 | host_send_keyboard_report(); | ||
| 670 | } | ||
| 671 | } | ||
| 672 | |||
| 673 | void unregister_code(uint8_t code) | ||
| 674 | { | ||
| 675 | if (code == KC_NO) { | ||
| 676 | return; | ||
| 677 | } | ||
| 678 | #ifdef CAPSLOCK_LOCKING_ENABLE | ||
| 679 | else if (KC_LOCKING_CAPS == code) { | ||
| 680 | #ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE | ||
| 681 | // Resync: ignore if caps lock already is off | ||
| 682 | if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return; | ||
| 683 | #endif | ||
| 684 | host_add_key(KC_CAPSLOCK); | ||
| 685 | host_send_keyboard_report(); | ||
| 686 | host_del_key(KC_CAPSLOCK); | ||
| 687 | host_send_keyboard_report(); | ||
| 688 | } | ||
| 689 | #endif | ||
| 690 | else if IS_KEY(code) { | ||
| 691 | host_del_key(code); | ||
| 692 | host_send_keyboard_report(); | ||
| 693 | } | ||
| 694 | else if IS_MOD(code) { | ||
| 695 | host_del_mods(MOD_BIT(code)); | ||
| 696 | host_send_keyboard_report(); | ||
| 697 | } | ||
| 698 | } | ||
| 699 | |||
| 700 | void add_mods(uint8_t mods) | ||
| 701 | { | ||
| 702 | if (mods) { | ||
| 703 | host_add_mods(mods); | ||
| 704 | host_send_keyboard_report(); | ||
| 705 | } | ||
| 706 | } | ||
| 707 | |||
| 708 | void del_mods(uint8_t mods) | ||
| 709 | { | ||
| 710 | if (mods) { | ||
| 711 | host_del_mods(mods); | ||
| 712 | host_send_keyboard_report(); | ||
| 713 | } | ||
| 714 | } | ||
| 715 | |||
| 716 | void set_mods(uint8_t mods) | ||
| 717 | { | ||
| 718 | host_set_mods(mods); | ||
| 719 | host_send_keyboard_report(); | ||
| 720 | } | ||
| 721 | |||
| 722 | void clear_keyboard(void) | ||
| 723 | { | ||
| 724 | host_clear_mods(); | ||
| 725 | clear_keyboard_but_mods(); | ||
| 726 | } | ||
| 727 | |||
| 728 | void clear_keyboard_but_mods(void) | ||
| 729 | { | ||
| 730 | host_clear_keys(); | ||
| 731 | host_send_keyboard_report(); | ||
| 732 | #ifdef MOUSEKEY_ENABLE | ||
| 733 | mousekey_clear(); | ||
| 734 | mousekey_send(); | ||
| 735 | #endif | ||
| 736 | #ifdef EXTRAKEY_ENABLE | ||
| 737 | host_system_send(0); | ||
| 738 | host_consumer_send(0); | ||
| 739 | #endif | ||
| 740 | } | ||
| 741 | |||
| 742 | bool sending_anykey(void) | ||
| 743 | { | ||
| 744 | return (host_has_anykey() || host_mouse_in_use() || | ||
| 745 | host_last_sysytem_report() || host_last_consumer_report()); | ||
| 746 | } | ||
| 747 | |||
| 748 | bool is_tap_key(key_t key) | ||
| 749 | { | ||
| 750 | action_t action = layer_switch_get_action(key); | ||
| 751 | |||
| 752 | switch (action.kind.id) { | ||
| 753 | case ACT_LMODS_TAP: | ||
| 754 | case ACT_RMODS_TAP: | ||
| 755 | return true; | ||
| 756 | case ACT_KEYMAP: | ||
| 757 | case ACT_OVERLAY: | ||
| 758 | switch (action.layer.code) { | ||
| 759 | case 0x04 ... 0xEF: /* tap key */ | ||
| 760 | case OP_INV: | ||
| 761 | return true; | ||
| 762 | default: | ||
| 763 | return false; | ||
| 764 | } | ||
| 765 | case ACT_MACRO: | ||
| 766 | case ACT_FUNCTION: | ||
| 767 | if (action.func.opt & FUNC_TAP) { return true; } | ||
| 768 | return false; | ||
| 769 | } | ||
| 770 | return false; | ||
| 771 | } | ||
| 772 | |||
| 773 | |||
| 774 | /* | ||
| 775 | * debug print | ||
| 776 | */ | ||
| 777 | static void debug_event(keyevent_t event) | ||
| 778 | { | ||
| 779 | debug_hex16((event.key.row<<8) | event.key.col); | ||
| 780 | if (event.pressed) debug("d("); else debug("u("); | ||
| 781 | debug_dec(event.time); debug(")"); | ||
| 782 | } | ||
| 783 | |||
| 784 | static void debug_record(keyrecord_t record) | ||
| 785 | { | ||
| 786 | debug_event(record.event); debug(":"); debug_dec(record.tap.count); | ||
| 787 | if (record.tap.interrupted) debug("-"); | ||
| 788 | } | ||
| 789 | |||
| 790 | static void debug_action(action_t action) | ||
| 791 | { | ||
| 792 | switch (action.kind.id) { | ||
| 793 | case ACT_LMODS: debug("ACT_LMODS"); break; | ||
| 794 | case ACT_RMODS: debug("ACT_RMODS"); break; | ||
| 795 | case ACT_LMODS_TAP: debug("ACT_LMODS_TAP"); break; | ||
| 796 | case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; | ||
| 797 | case ACT_USAGE: debug("ACT_USAGE"); break; | ||
| 798 | case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; | ||
| 799 | case ACT_KEYMAP: debug("ACT_KEYMAP"); break; | ||
| 800 | case ACT_OVERLAY: debug("ACT_OVERLAY"); break; | ||
| 801 | case ACT_MACRO: debug("ACT_MACRO"); break; | ||
| 802 | case ACT_COMMAND: debug("ACT_COMMAND"); break; | ||
| 803 | case ACT_FUNCTION: debug("ACT_FUNCTION"); break; | ||
| 804 | default: debug("UNKNOWN"); break; | ||
| 805 | } | ||
| 806 | debug("["); | ||
| 807 | debug_hex4(action.kind.param>>8); | ||
| 808 | debug(":"); | ||
| 809 | debug_hex8(action.kind.param & 0xff); | ||
| 810 | debug("]"); | ||
| 811 | } | ||
| 812 | |||
| 813 | |||
| 814 | |||
| 815 | #ifndef NO_ACTION_TAPPING | ||
| 688 | /* Tapping | 816 | /* Tapping |
| 689 | * | 817 | * |
| 690 | * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. | 818 | * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. |
| @@ -857,215 +985,85 @@ static bool process_tapping(keyrecord_t *keyp) | |||
| 857 | } | 985 | } |
| 858 | } | 986 | } |
| 859 | 987 | ||
| 860 | /* scan buffer for tapping */ | ||
| 861 | static void waiting_buffer_scan_tap(void) | ||
| 862 | { | ||
| 863 | // tapping already is settled | ||
| 864 | if (tapping_key.tap.count > 0) return; | ||
| 865 | // invalid state: tapping_key released && tap.count == 0 | ||
| 866 | if (!tapping_key.event.pressed) return; | ||
| 867 | |||
| 868 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { | ||
| 869 | if (IS_TAPPING_KEY(waiting_buffer[i].event.key) && | ||
| 870 | !waiting_buffer[i].event.pressed && | ||
| 871 | WITHIN_TAPPING_TERM(waiting_buffer[i].event)) { | ||
| 872 | tapping_key.tap.count = 1; | ||
| 873 | waiting_buffer[i].tap.count = 1; | ||
| 874 | process_action(&tapping_key); | ||
| 875 | |||
| 876 | debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n"); | ||
| 877 | debug_waiting_buffer(); | ||
| 878 | return; | ||
| 879 | } | ||
| 880 | } | ||
| 881 | } | ||
| 882 | |||
| 883 | |||
| 884 | 988 | ||
| 885 | /* | 989 | /* |
| 886 | * Utilities for actions. | 990 | * Waiting buffer |
| 887 | */ | 991 | */ |
| 888 | void register_code(uint8_t code) | 992 | static bool waiting_buffer_enq(keyrecord_t record) |
| 889 | { | 993 | { |
| 890 | if (code == KC_NO) { | 994 | if (IS_NOEVENT(record.event)) { |
| 891 | return; | 995 | return true; |
| 892 | } | 996 | } |
| 893 | #ifdef CAPSLOCK_LOCKING_ENABLE | 997 | |
| 894 | else if (KC_LOCKING_CAPS == code) { | 998 | if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) { |
| 895 | #ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE | 999 | debug("waiting_buffer_enq: Over flow.\n"); |
| 896 | // Resync: ignore if caps lock already is on | 1000 | return false; |
| 897 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return; | ||
| 898 | #endif | ||
| 899 | host_add_key(KC_CAPSLOCK); | ||
| 900 | host_send_keyboard_report(); | ||
| 901 | host_del_key(KC_CAPSLOCK); | ||
| 902 | host_send_keyboard_report(); | ||
| 903 | } | 1001 | } |
| 904 | #endif | ||
| 905 | else if IS_KEY(code) { | ||
| 906 | // TODO: should push command_proc out of this block? | ||
| 907 | if (command_proc(code)) return; | ||
| 908 | 1002 | ||
| 909 | if (oneshot_state.mods && oneshot_state.ready && !oneshot_state.disabled) { | 1003 | waiting_buffer[waiting_buffer_head] = record; |
| 910 | uint8_t tmp_mods = host_get_mods(); | 1004 | waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE; |
| 911 | host_add_mods(oneshot_state.mods); | ||
| 912 | host_add_key(code); | ||
| 913 | host_send_keyboard_report(); | ||
| 914 | 1005 | ||
| 915 | host_set_mods(tmp_mods); | 1006 | debug("waiting_buffer_enq: "); debug_waiting_buffer(); |
| 916 | oneshot_state.ready = false; | 1007 | return true; |
| 917 | } else { | ||
| 918 | host_add_key(code); | ||
| 919 | host_send_keyboard_report(); | ||
| 920 | } | ||
| 921 | } | ||
| 922 | else if IS_MOD(code) { | ||
| 923 | host_add_mods(MOD_BIT(code)); | ||
| 924 | host_send_keyboard_report(); | ||
| 925 | } | ||
| 926 | } | 1008 | } |
| 927 | 1009 | ||
| 928 | void unregister_code(uint8_t code) | 1010 | static void waiting_buffer_clear(void) |
| 929 | { | 1011 | { |
| 930 | if (code == KC_NO) { | 1012 | waiting_buffer_head = 0; |
| 931 | return; | 1013 | waiting_buffer_tail = 0; |
| 932 | } | ||
| 933 | #ifdef CAPSLOCK_LOCKING_ENABLE | ||
| 934 | else if (KC_LOCKING_CAPS == code) { | ||
| 935 | #ifdef CAPSLOCK_LOCKING_RESYNC_ENABLE | ||
| 936 | // Resync: ignore if caps lock already is off | ||
| 937 | if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return; | ||
| 938 | #endif | ||
| 939 | host_add_key(KC_CAPSLOCK); | ||
| 940 | host_send_keyboard_report(); | ||
| 941 | host_del_key(KC_CAPSLOCK); | ||
| 942 | host_send_keyboard_report(); | ||
| 943 | } | ||
| 944 | #endif | ||
| 945 | else if IS_KEY(code) { | ||
| 946 | host_del_key(code); | ||
| 947 | host_send_keyboard_report(); | ||
| 948 | } | ||
| 949 | else if IS_MOD(code) { | ||
| 950 | host_del_mods(MOD_BIT(code)); | ||
| 951 | host_send_keyboard_report(); | ||
| 952 | } | ||
| 953 | } | 1014 | } |
| 954 | 1015 | ||
| 955 | void add_mods(uint8_t mods) | 1016 | #if TAPPING_TERM >= 500 |
| 1017 | static bool waiting_buffer_typed(keyevent_t event) | ||
| 956 | { | 1018 | { |
| 957 | if (mods) { | 1019 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { |
| 958 | host_add_mods(mods); | 1020 | if (KEYEQ(event.key, waiting_buffer[i].event.key) && event.pressed != waiting_buffer[i].event.pressed) { |
| 959 | host_send_keyboard_report(); | 1021 | return true; |
| 1022 | } | ||
| 960 | } | 1023 | } |
| 1024 | return false; | ||
| 961 | } | 1025 | } |
| 1026 | #endif | ||
| 962 | 1027 | ||
| 963 | void del_mods(uint8_t mods) | 1028 | bool waiting_buffer_has_anykey_pressed(void) |
| 964 | { | 1029 | { |
| 965 | if (mods) { | 1030 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { |
| 966 | host_del_mods(mods); | 1031 | if (waiting_buffer[i].event.pressed) return true; |
| 967 | host_send_keyboard_report(); | ||
| 968 | } | 1032 | } |
| 1033 | return false; | ||
| 969 | } | 1034 | } |
| 970 | 1035 | /* scan buffer for tapping */ | |
| 971 | void set_mods(uint8_t mods) | 1036 | static void waiting_buffer_scan_tap(void) |
| 972 | { | ||
| 973 | host_set_mods(mods); | ||
| 974 | host_send_keyboard_report(); | ||
| 975 | } | ||
| 976 | |||
| 977 | void clear_keyboard(void) | ||
| 978 | { | ||
| 979 | host_clear_mods(); | ||
| 980 | clear_keyboard_but_mods(); | ||
| 981 | } | ||
| 982 | |||
| 983 | void clear_keyboard_but_mods(void) | ||
| 984 | { | ||
| 985 | host_clear_keys(); | ||
| 986 | host_send_keyboard_report(); | ||
| 987 | #ifdef MOUSEKEY_ENABLE | ||
| 988 | mousekey_clear(); | ||
| 989 | mousekey_send(); | ||
| 990 | #endif | ||
| 991 | #ifdef EXTRAKEY_ENABLE | ||
| 992 | host_system_send(0); | ||
| 993 | host_consumer_send(0); | ||
| 994 | #endif | ||
| 995 | } | ||
| 996 | |||
| 997 | bool sending_anykey(void) | ||
| 998 | { | 1037 | { |
| 999 | return (host_has_anykey() || host_mouse_in_use() || | 1038 | // tapping already is settled |
| 1000 | host_last_sysytem_report() || host_last_consumer_report()); | 1039 | if (tapping_key.tap.count > 0) return; |
| 1001 | } | 1040 | // invalid state: tapping_key released && tap.count == 0 |
| 1041 | if (!tapping_key.event.pressed) return; | ||
| 1002 | 1042 | ||
| 1003 | bool is_tap_key(key_t key) | 1043 | for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { |
| 1004 | { | 1044 | if (IS_TAPPING_KEY(waiting_buffer[i].event.key) && |
| 1005 | action_t action = layer_switch_get_action(key); | 1045 | !waiting_buffer[i].event.pressed && |
| 1046 | WITHIN_TAPPING_TERM(waiting_buffer[i].event)) { | ||
| 1047 | tapping_key.tap.count = 1; | ||
| 1048 | waiting_buffer[i].tap.count = 1; | ||
| 1049 | process_action(&tapping_key); | ||
| 1006 | 1050 | ||
| 1007 | switch (action.kind.id) { | 1051 | debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n"); |
| 1008 | case ACT_LMODS_TAP: | 1052 | debug_waiting_buffer(); |
| 1009 | case ACT_RMODS_TAP: | 1053 | return; |
| 1010 | return true; | 1054 | } |
| 1011 | case ACT_KEYMAP: | ||
| 1012 | case ACT_OVERLAY: | ||
| 1013 | switch (action.layer.code) { | ||
| 1014 | case 0x04 ... 0xEF: /* tap key */ | ||
| 1015 | case OP_INV: | ||
| 1016 | return true; | ||
| 1017 | default: | ||
| 1018 | return false; | ||
| 1019 | } | ||
| 1020 | case ACT_MACRO: | ||
| 1021 | case ACT_FUNCTION: | ||
| 1022 | if (action.func.opt & FUNC_TAP) { return true; } | ||
| 1023 | return false; | ||
| 1024 | } | 1055 | } |
| 1025 | return false; | ||
| 1026 | } | 1056 | } |
| 1027 | 1057 | ||
| 1028 | 1058 | ||
| 1029 | /* | 1059 | /* |
| 1030 | * debug print | 1060 | * debug print |
| 1031 | */ | 1061 | */ |
| 1032 | static void debug_event(keyevent_t event) | ||
| 1033 | { | ||
| 1034 | debug_hex16((event.key.row<<8) | event.key.col); | ||
| 1035 | if (event.pressed) debug("d("); else debug("u("); | ||
| 1036 | debug_dec(event.time); debug(")"); | ||
| 1037 | } | ||
| 1038 | static void debug_record(keyrecord_t record) | ||
| 1039 | { | ||
| 1040 | debug_event(record.event); debug(":"); debug_dec(record.tap.count); | ||
| 1041 | if (record.tap.interrupted) debug("-"); | ||
| 1042 | } | ||
| 1043 | static void debug_action(action_t action) | ||
| 1044 | { | ||
| 1045 | switch (action.kind.id) { | ||
| 1046 | case ACT_LMODS: debug("ACT_LMODS"); break; | ||
| 1047 | case ACT_RMODS: debug("ACT_RMODS"); break; | ||
| 1048 | case ACT_LMODS_TAP: debug("ACT_LMODS_TAP"); break; | ||
| 1049 | case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; | ||
| 1050 | case ACT_USAGE: debug("ACT_USAGE"); break; | ||
| 1051 | case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; | ||
| 1052 | case ACT_KEYMAP: debug("ACT_KEYMAP"); break; | ||
| 1053 | case ACT_OVERLAY: debug("ACT_OVERLAY"); break; | ||
| 1054 | case ACT_MACRO: debug("ACT_MACRO"); break; | ||
| 1055 | case ACT_COMMAND: debug("ACT_COMMAND"); break; | ||
| 1056 | case ACT_FUNCTION: debug("ACT_FUNCTION"); break; | ||
| 1057 | default: debug("UNKNOWN"); break; | ||
| 1058 | } | ||
| 1059 | debug("["); | ||
| 1060 | debug_hex4(action.kind.param>>8); | ||
| 1061 | debug(":"); | ||
| 1062 | debug_hex8(action.kind.param & 0xff); | ||
| 1063 | debug("]"); | ||
| 1064 | } | ||
| 1065 | static void debug_tapping_key(void) | 1062 | static void debug_tapping_key(void) |
| 1066 | { | 1063 | { |
| 1067 | debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); | 1064 | debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); |
| 1068 | } | 1065 | } |
| 1066 | |||
| 1069 | static void debug_waiting_buffer(void) | 1067 | static void debug_waiting_buffer(void) |
| 1070 | { | 1068 | { |
| 1071 | debug("{ "); | 1069 | debug("{ "); |
| @@ -1074,3 +1072,4 @@ static void debug_waiting_buffer(void) | |||
| 1074 | } | 1072 | } |
| 1075 | debug("}\n"); | 1073 | debug("}\n"); |
| 1076 | } | 1074 | } |
| 1075 | #endif | ||
diff --git a/common/action_macro.c b/common/action_macro.c index ca7ffa822..6d81a1efb 100644 --- a/common/action_macro.c +++ b/common/action_macro.c | |||
| @@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | #include "action_macro.h" | 20 | #include "action_macro.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | #ifndef NO_ACTION_MACRO | ||
| 24 | |||
| 23 | #define MACRO_READ() (macro = pgm_read_byte(macro_p++)) | 25 | #define MACRO_READ() (macro = pgm_read_byte(macro_p++)) |
| 24 | void action_macro_play(const prog_macro_t *macro_p) | 26 | void action_macro_play(const prog_macro_t *macro_p) |
| 25 | { | 27 | { |
| @@ -64,3 +66,4 @@ void action_macro_play(const prog_macro_t *macro_p) | |||
| 64 | { uint8_t ms = interval; while (ms--) _delay_ms(1); } | 66 | { uint8_t ms = interval; while (ms--) _delay_ms(1); } |
| 65 | } | 67 | } |
| 66 | } | 68 | } |
| 69 | #endif | ||
diff --git a/common/action_macro.h b/common/action_macro.h index db6577959..ee5c7c426 100644 --- a/common/action_macro.h +++ b/common/action_macro.h | |||
| @@ -28,7 +28,11 @@ typedef uint8_t macro_t; | |||
| 28 | typedef macro_t prog_macro_t PROGMEM; | 28 | typedef macro_t prog_macro_t PROGMEM; |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | #ifndef NO_ACTION_MACRO | ||
| 31 | void action_macro_play(const prog_macro_t *macro); | 32 | void action_macro_play(const prog_macro_t *macro); |
| 33 | #else | ||
| 34 | #define action_macro_play(macro) | ||
| 35 | #endif | ||
| 32 | 36 | ||
| 33 | 37 | ||
| 34 | 38 | ||
diff --git a/common/action_oneshot.c b/common/action_oneshot.c new file mode 100644 index 000000000..d34f44b5a --- /dev/null +++ b/common/action_oneshot.c | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #include "action_oneshot.h" | ||
| 2 | |||
| 3 | |||
| 4 | #ifndef NO_ACTION_ONESHOT | ||
| 5 | oneshot_state_t oneshot_state; | ||
| 6 | |||
| 7 | void oneshot_start(uint8_t mods) | ||
| 8 | { | ||
| 9 | oneshot_state.mods = mods; | ||
| 10 | } | ||
| 11 | |||
| 12 | void oneshot_cancel(void) | ||
| 13 | { | ||
| 14 | oneshot_state.mods = 0; | ||
| 15 | } | ||
| 16 | |||
| 17 | void oneshot_toggle(void) | ||
| 18 | { | ||
| 19 | oneshot_state.disabled = !oneshot_state.disabled; | ||
| 20 | } | ||
| 21 | #endif | ||
diff --git a/common/action_oneshot.h b/common/action_oneshot.h new file mode 100644 index 000000000..36ef9e9bc --- /dev/null +++ b/common/action_oneshot.h | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #ifndef ACTION_ONESHOT_H | ||
| 18 | #define ACTION_ONESHOT_H | ||
| 19 | |||
| 20 | #include <stdint.h> | ||
| 21 | #include <stdbool.h> | ||
| 22 | |||
| 23 | #ifdef NO_ACTION_TAPPING | ||
| 24 | #define NO_ACTION_ONESHOT | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifndef NO_ACTION_ONESHOT | ||
| 28 | /* Oneshot modifier | ||
| 29 | * | ||
| 30 | * Problem: Want to capitalize like 'The' but the result tends to be 'THe'. | ||
| 31 | * Solution: Oneshot modifier have its effect on only one key coming next. | ||
| 32 | * Tap Shift, then type 't', 'h' and 'e'. Not need to hold Shift key. | ||
| 33 | * | ||
| 34 | * Hold: works as normal modifier. | ||
| 35 | * Tap: one shot modifier. | ||
| 36 | * 2 Tap: cancel one shot modifier. | ||
| 37 | * 5-Tap: toggles enable/disable oneshot feature. | ||
| 38 | */ | ||
| 39 | typedef struct { | ||
| 40 | uint8_t mods; | ||
| 41 | bool disabled; | ||
| 42 | } oneshot_state_t; | ||
| 43 | |||
| 44 | |||
| 45 | oneshot_state_t oneshot_state; | ||
| 46 | |||
| 47 | void oneshot_start(uint8_t mods); | ||
| 48 | void oneshot_cancel(void); | ||
| 49 | void oneshot_toggle(void); | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #endif | ||
diff --git a/common/command.c b/common/command.c index 372ca291e..cb98e1d5f 100644 --- a/common/command.c +++ b/common/command.c | |||
| @@ -98,7 +98,6 @@ bool command_extra(uint8_t code) | |||
| 98 | ***********************************************************/ | 98 | ***********************************************************/ |
| 99 | static void command_common_help(void) | 99 | static void command_common_help(void) |
| 100 | { | 100 | { |
| 101 | print_enable = true; | ||
| 102 | print("\n\n----- Command Help -----\n"); | 101 | print("\n\n----- Command Help -----\n"); |
| 103 | print("c: enter console mode\n"); | 102 | print("c: enter console mode\n"); |
| 104 | print("d: toggle debug enable\n"); | 103 | print("d: toggle debug enable\n"); |
| @@ -137,7 +136,8 @@ static void print_eeprom_config(void) | |||
| 137 | eebyte = eeconfig_read_keyconf(); | 136 | eebyte = eeconfig_read_keyconf(); |
| 138 | print("keyconf: "); print_hex8(eebyte); print("\n"); | 137 | print("keyconf: "); print_hex8(eebyte); print("\n"); |
| 139 | 138 | ||
| 140 | keyconf kc = (keyconf){ .raw = eebyte }; | 139 | keyconf kc; |
| 140 | kc = (keyconf){ .raw = eebyte }; | ||
| 141 | print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n"); | 141 | print("keyconf.swap_control_capslock: "); print_hex8(kc.swap_control_capslock); print("\n"); |
| 142 | print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n"); | 142 | print("keyconf.capslock_to_control: "); print_hex8(kc.capslock_to_control); print("\n"); |
| 143 | print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n"); | 143 | print("keyconf.swap_lalt_lgui: "); print_hex8(kc.swap_lalt_lgui); print("\n"); |
| @@ -173,7 +173,6 @@ static bool command_common(uint8_t code) | |||
| 173 | command_common_help(); | 173 | command_common_help(); |
| 174 | break; | 174 | break; |
| 175 | case KC_C: | 175 | case KC_C: |
| 176 | print_enable = true; | ||
| 177 | debug_matrix = false; | 176 | debug_matrix = false; |
| 178 | debug_keyboard = false; | 177 | debug_keyboard = false; |
| 179 | debug_mouse = false; | 178 | debug_mouse = false; |
| @@ -239,15 +238,6 @@ static bool command_common(uint8_t code) | |||
| 239 | case KC_T: // print timer | 238 | case KC_T: // print timer |
| 240 | print_val_hex32(timer_count); | 239 | print_val_hex32(timer_count); |
| 241 | break; | 240 | break; |
| 242 | case KC_P: // print toggle | ||
| 243 | if (print_enable) { | ||
| 244 | print("print disabled.\n"); | ||
| 245 | print_enable = false; | ||
| 246 | } else { | ||
| 247 | print_enable = true; | ||
| 248 | print("print enabled.\n"); | ||
| 249 | } | ||
| 250 | break; | ||
| 251 | case KC_S: | 241 | case KC_S: |
| 252 | print("\n\n----- Status -----\n"); | 242 | print("\n\n----- Status -----\n"); |
| 253 | print_val_hex8(host_keyboard_leds()); | 243 | print_val_hex8(host_keyboard_leds()); |
| @@ -320,7 +310,6 @@ static bool command_common(uint8_t code) | |||
| 320 | ***********************************************************/ | 310 | ***********************************************************/ |
| 321 | static void command_console_help(void) | 311 | static void command_console_help(void) |
| 322 | { | 312 | { |
| 323 | print_enable = true; | ||
| 324 | print("\n\n----- Console Help -----\n"); | 313 | print("\n\n----- Console Help -----\n"); |
| 325 | print("ESC/q: quit\n"); | 314 | print("ESC/q: quit\n"); |
| 326 | #ifdef MOUSEKEY_ENABLE | 315 | #ifdef MOUSEKEY_ENABLE |
diff --git a/common/command.h b/common/command.h index dafd4d0f3..be739fafe 100644 --- a/common/command.h +++ b/common/command.h | |||
| @@ -18,8 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 18 | #ifndef COMMAND_H | 18 | #ifndef COMMAND_H |
| 19 | #define COMMAND | 19 | #define COMMAND |
| 20 | 20 | ||
| 21 | #ifdef COMMAND_ENABLE | ||
| 21 | bool command_proc(uint8_t code); | 22 | bool command_proc(uint8_t code); |
| 22 | /* This allows to extend commands. Return 0 when command is not processed. */ | 23 | /* This allows to extend commands. Return 0 when command is not processed. */ |
| 23 | bool command_extra(uint8_t code); | 24 | bool command_extra(uint8_t code); |
| 25 | #else | ||
| 26 | #define command_proc(code) false | ||
| 27 | #endif | ||
| 24 | 28 | ||
| 25 | #endif | 29 | #endif |
diff --git a/common/debug.h b/common/debug.h index e63d46f0e..e16ea14af 100644 --- a/common/debug.h +++ b/common/debug.h | |||
| @@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 22 | #include "print.h" | 22 | #include "print.h" |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | #ifndef NO_DEBUG | ||
| 26 | |||
| 25 | #define debug(s) do { if (debug_enable) print(s); } while (0) | 27 | #define debug(s) do { if (debug_enable) print(s); } while (0) |
| 26 | #define debugln(s) do { if (debug_enable) println(s); } while (0) | 28 | #define debugln(s) do { if (debug_enable) println(s); } while (0) |
| 27 | #define debug_S(s) do { if (debug_enable) print_S(s); } while (0) | 29 | #define debug_S(s) do { if (debug_enable) print_S(s); } while (0) |
| @@ -31,9 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 31 | print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ | 33 | print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ |
| 32 | } \ | 34 | } \ |
| 33 | } while (0) | 35 | } while (0) |
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | #define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0) | 36 | #define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0) |
| 38 | #define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0) | 37 | #define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0) |
| 39 | #define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0) | 38 | #define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0) |
| @@ -46,11 +45,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 46 | #define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0) | 45 | #define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0) |
| 47 | #define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0) | 46 | #define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0) |
| 48 | #define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0) | 47 | #define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0) |
| 49 | |||
| 50 | #define debug_hex(data) debug_hex8(data) | 48 | #define debug_hex(data) debug_hex8(data) |
| 51 | #define debug_bin(data) debug_bin8(data) | 49 | #define debug_bin(data) debug_bin8(data) |
| 52 | #define debug_bin_reverse(data) debug_bin8(data) | 50 | #define debug_bin_reverse(data) debug_bin8(data) |
| 53 | 51 | ||
| 52 | #else | ||
| 53 | |||
| 54 | #define debug(s) | ||
| 55 | #define debugln(s) | ||
| 56 | #define debug_S(s) | ||
| 57 | #define debug_P(s) | ||
| 58 | #define debug_msg(s) | ||
| 59 | #define debug_dec(data) | ||
| 60 | #define debug_decs(data) | ||
| 61 | #define debug_hex4(data) | ||
| 62 | #define debug_hex8(data) | ||
| 63 | #define debug_hex16(data) | ||
| 64 | #define debug_hex32(data) | ||
| 65 | #define debug_bin8(data) | ||
| 66 | #define debug_bin16(data) | ||
| 67 | #define debug_bin32(data) | ||
| 68 | #define debug_bin_reverse8(data) | ||
| 69 | #define debug_bin_reverse16(data) | ||
| 70 | #define debug_bin_reverse32(data) | ||
| 71 | #define debug_hex(data) | ||
| 72 | #define debug_bin(data) | ||
| 73 | #define debug_bin_reverse(data) | ||
| 74 | |||
| 75 | #endif | ||
| 76 | |||
| 54 | 77 | ||
| 55 | #ifdef __cplusplus | 78 | #ifdef __cplusplus |
| 56 | extern "C" { | 79 | extern "C" { |
diff --git a/common/keyboard.c b/common/keyboard.c index 42c57ac96..cb0dc06e6 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -54,7 +54,7 @@ static bool has_ghost_in_row(uint8_t row) | |||
| 54 | void keyboard_init(void) | 54 | void keyboard_init(void) |
| 55 | { | 55 | { |
| 56 | // TODO: configuration of sendchar impl | 56 | // TODO: configuration of sendchar impl |
| 57 | print_sendchar_func = sendchar; | 57 | print_set_sendchar(sendchar); |
| 58 | 58 | ||
| 59 | timer_init(); | 59 | timer_init(); |
| 60 | matrix_init(); | 60 | matrix_init(); |
diff --git a/common/layer_switch.c b/common/layer_switch.c index 19e286f88..a5d426a89 100644 --- a/common/layer_switch.c +++ b/common/layer_switch.c | |||
| @@ -24,6 +24,7 @@ void default_layer_set(uint8_t layer) | |||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | #ifndef NO_ACTION_KEYMAP | ||
| 27 | /* | 28 | /* |
| 28 | * Keymap Layer (0-15) | 29 | * Keymap Layer (0-15) |
| 29 | */ | 30 | */ |
| @@ -95,9 +96,11 @@ void keymap_debug(void) | |||
| 95 | { | 96 | { |
| 96 | debug_hex16(keymap_stat); debug("("); debug_dec(keymap_get_layer()); debug(")"); | 97 | debug_hex16(keymap_stat); debug("("); debug_dec(keymap_get_layer()); debug(")"); |
| 97 | } | 98 | } |
| 99 | #endif | ||
| 98 | 100 | ||
| 99 | 101 | ||
| 100 | 102 | ||
| 103 | #ifndef NO_ACTION_OVERLAY | ||
| 101 | /* | 104 | /* |
| 102 | * Overlay Layer (16-31 = 0-15|0x10) | 105 | * Overlay Layer (16-31 = 0-15|0x10) |
| 103 | */ | 106 | */ |
| @@ -169,12 +172,14 @@ void overlay_debug(void) | |||
| 169 | { | 172 | { |
| 170 | debug_hex16(overlay_stat); debug("("); debug_dec(overlay_get_layer()); debug(")"); | 173 | debug_hex16(overlay_stat); debug("("); debug_dec(overlay_get_layer()); debug(")"); |
| 171 | } | 174 | } |
| 175 | #endif | ||
| 172 | 176 | ||
| 173 | action_t layer_switch_get_action(key_t key) | 177 | action_t layer_switch_get_action(key_t key) |
| 174 | { | 178 | { |
| 175 | action_t action; | 179 | action_t action; |
| 176 | action.code = ACTION_TRANSPARENT; | 180 | action.code = ACTION_TRANSPARENT; |
| 177 | 181 | ||
| 182 | #ifndef NO_ACTION_OVERLAY | ||
| 178 | /* overlay: top layer first */ | 183 | /* overlay: top layer first */ |
| 179 | for (int8_t i = 15; i >= 0; i--) { | 184 | for (int8_t i = 15; i >= 0; i--) { |
| 180 | if (overlay_stat & (1<<i)) { | 185 | if (overlay_stat & (1<<i)) { |
| @@ -184,7 +189,9 @@ action_t layer_switch_get_action(key_t key) | |||
| 184 | } | 189 | } |
| 185 | } | 190 | } |
| 186 | } | 191 | } |
| 192 | #endif | ||
| 187 | 193 | ||
| 194 | #ifndef NO_ACTION_KEYMAP | ||
| 188 | /* keymap: top layer first */ | 195 | /* keymap: top layer first */ |
| 189 | for (int8_t i = 15; i >= 0; i--) { | 196 | for (int8_t i = 15; i >= 0; i--) { |
| 190 | if (keymap_stat & (1<<i)) { | 197 | if (keymap_stat & (1<<i)) { |
| @@ -194,6 +201,7 @@ action_t layer_switch_get_action(key_t key) | |||
| 194 | } | 201 | } |
| 195 | } | 202 | } |
| 196 | } | 203 | } |
| 204 | #endif | ||
| 197 | 205 | ||
| 198 | /* default layer */ | 206 | /* default layer */ |
| 199 | action = action_for_key(default_layer, key); | 207 | action = action_for_key(default_layer, key); |
diff --git a/common/layer_switch.h b/common/layer_switch.h index a566ab12b..eb4cf61ba 100644 --- a/common/layer_switch.h +++ b/common/layer_switch.h | |||
| @@ -38,6 +38,7 @@ void default_layer_set(uint8_t layer); | |||
| 38 | /* | 38 | /* |
| 39 | * Keymap Layer | 39 | * Keymap Layer |
| 40 | */ | 40 | */ |
| 41 | #ifndef NO_ACTION_KEYMAP | ||
| 41 | extern uint16_t keymap_stat; | 42 | extern uint16_t keymap_stat; |
| 42 | /* return current active layer */ | 43 | /* return current active layer */ |
| 43 | uint8_t keymap_get_layer(void); | 44 | uint8_t keymap_get_layer(void); |
| @@ -52,11 +53,26 @@ void keymap_or(uint16_t stat); | |||
| 52 | void keymap_and(uint16_t stat); | 53 | void keymap_and(uint16_t stat); |
| 53 | void keymap_xor(uint16_t stat); | 54 | void keymap_xor(uint16_t stat); |
| 54 | void keymap_debug(void); | 55 | void keymap_debug(void); |
| 56 | #else | ||
| 57 | #define keymap_stat 0 | ||
| 58 | #define keymap_get_layer() | ||
| 59 | #define keymap_clear() | ||
| 60 | #define keymap_set(stat) | ||
| 61 | #define keymap_move(layer) | ||
| 62 | #define keymap_on(layer) | ||
| 63 | #define keymap_off(layer) | ||
| 64 | #define keymap_invert(layer) | ||
| 65 | #define keymap_or(stat) | ||
| 66 | #define keymap_and(stat) | ||
| 67 | #define keymap_xor(stat) | ||
| 68 | #define keymap_debug() | ||
| 69 | #endif | ||
| 55 | 70 | ||
| 56 | 71 | ||
| 57 | /* | 72 | /* |
| 58 | * Overlay Layer | 73 | * Overlay Layer |
| 59 | */ | 74 | */ |
| 75 | #ifndef NO_ACTION_OVERLAY | ||
| 60 | extern uint16_t overlay_stat; | 76 | extern uint16_t overlay_stat; |
| 61 | /* return current active layer */ | 77 | /* return current active layer */ |
| 62 | uint8_t overlay_get_layer(void); | 78 | uint8_t overlay_get_layer(void); |
| @@ -71,6 +87,20 @@ void overlay_or(uint16_t stat); | |||
| 71 | void overlay_and(uint16_t stat); | 87 | void overlay_and(uint16_t stat); |
| 72 | void overlay_xor(uint16_t stat); | 88 | void overlay_xor(uint16_t stat); |
| 73 | void overlay_debug(void); | 89 | void overlay_debug(void); |
| 90 | #else | ||
| 91 | #define overlay_stat 0 | ||
| 92 | #define overlay_get_layer() | ||
| 93 | #define overlay_clear() | ||
| 94 | #define overlay_set(stat) | ||
| 95 | #define overlay_move(layer) | ||
| 96 | #define overlay_on(layer) | ||
| 97 | #define overlay_off(layer) | ||
| 98 | #define overlay_invert(layer) | ||
| 99 | #define overlay_or(stat) | ||
| 100 | #define overlay_and(stat) | ||
| 101 | #define overlay_xor(stat) | ||
| 102 | #define overlay_debug() | ||
| 103 | #endif | ||
| 74 | 104 | ||
| 75 | 105 | ||
| 76 | 106 | ||
diff --git a/common/print.c b/common/print.c index 08d211f20..329f83512 100644 --- a/common/print.c +++ b/common/print.c | |||
| @@ -27,12 +27,17 @@ | |||
| 27 | #include "print.h" | 27 | #include "print.h" |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | #define sendchar(c) do { if (print_enable && print_sendchar_func) (print_sendchar_func)(c); } while (0) | 30 | #ifndef NO_PRINT |
| 31 | 31 | ||
| 32 | #define sendchar(c) do { if (print_sendchar_func) (print_sendchar_func)(c); } while (0) | ||
| 32 | 33 | ||
| 33 | int8_t (*print_sendchar_func)(uint8_t) = 0; | ||
| 34 | bool print_enable = true; | ||
| 35 | 34 | ||
| 35 | static int8_t (*print_sendchar_func)(uint8_t) = 0; | ||
| 36 | |||
| 37 | void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) | ||
| 38 | { | ||
| 39 | print_sendchar_func = sendchar_func; | ||
| 40 | } | ||
| 36 | 41 | ||
| 37 | /* print string stored in data memory(SRAM) | 42 | /* print string stored in data memory(SRAM) |
| 38 | * print_P("hello world"); | 43 | * print_P("hello world"); |
| @@ -184,3 +189,5 @@ void print_bin_reverse32(uint32_t data) | |||
| 184 | print_bin_reverse8(data>>16); | 189 | print_bin_reverse8(data>>16); |
| 185 | print_bin_reverse8(data>>24); | 190 | print_bin_reverse8(data>>24); |
| 186 | } | 191 | } |
| 192 | |||
| 193 | #endif | ||
diff --git a/common/print.h b/common/print.h index b22509477..80858b3bc 100644 --- a/common/print.h +++ b/common/print.h | |||
| @@ -30,13 +30,12 @@ | |||
| 30 | #include <avr/pgmspace.h> | 30 | #include <avr/pgmspace.h> |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | // avoid collision with arduino/Print.h | ||
| 34 | #ifndef __cplusplus | ||
| 35 | // this macro allows you to write print("some text") and | 33 | // this macro allows you to write print("some text") and |
| 36 | // the string is automatically placed into flash memory :) | 34 | // the string is automatically placed into flash memory :) |
| 35 | // TODO: avoid collision with arduino/Print.h | ||
| 36 | #ifndef __cplusplus | ||
| 37 | #define print(s) print_P(PSTR(s)) | 37 | #define print(s) print_P(PSTR(s)) |
| 38 | #endif | 38 | #endif |
| 39 | |||
| 40 | #define println(s) print_P(PSTR(s "\n")) | 39 | #define println(s) print_P(PSTR(s "\n")) |
| 41 | 40 | ||
| 42 | /* for old name */ | 41 | /* for old name */ |
| @@ -49,15 +48,12 @@ | |||
| 49 | #define pbin_reverse(data) print_bin_reverse8(data) | 48 | #define pbin_reverse(data) print_bin_reverse8(data) |
| 50 | #define pbin_reverse16(data) print_bin_reverse16(data) | 49 | #define pbin_reverse16(data) print_bin_reverse16(data) |
| 51 | 50 | ||
| 52 | |||
| 53 | /* print value utility */ | 51 | /* print value utility */ |
| 54 | #define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0) | 52 | #define print_val_dec(v) do { print_P(PSTR(#v ": ")); print_dec(v); print_P(PSTR("\n")); } while (0) |
| 55 | #define print_val_decs(v) do { print_P(PSTR(#v ": ")); print_decs(v); print_P(PSTR("\n")); } while (0) | 53 | #define print_val_decs(v) do { print_P(PSTR(#v ": ")); print_decs(v); print_P(PSTR("\n")); } while (0) |
| 56 | |||
| 57 | #define print_val_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) | 54 | #define print_val_hex8(v) do { print_P(PSTR(#v ": ")); print_hex8(v); print_P(PSTR("\n")); } while (0) |
| 58 | #define print_val_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) | 55 | #define print_val_hex16(v) do { print_P(PSTR(#v ": ")); print_hex16(v); print_P(PSTR("\n")); } while (0) |
| 59 | #define print_val_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) | 56 | #define print_val_hex32(v) do { print_P(PSTR(#v ": ")); print_hex32(v); print_P(PSTR("\n")); } while (0) |
| 60 | |||
| 61 | #define print_val_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) | 57 | #define print_val_bin8(v) do { print_P(PSTR(#v ": ")); print_bin8(v); print_P(PSTR("\n")); } while (0) |
| 62 | #define print_val_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) | 58 | #define print_val_bin16(v) do { print_P(PSTR(#v ": ")); print_bin16(v); print_P(PSTR("\n")); } while (0) |
| 63 | #define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) | 59 | #define print_val_bin32(v) do { print_P(PSTR(#v ": ")); print_bin32(v); print_P(PSTR("\n")); } while (0) |
| @@ -67,13 +63,13 @@ | |||
| 67 | 63 | ||
| 68 | 64 | ||
| 69 | 65 | ||
| 66 | #ifndef NO_PRINT | ||
| 67 | |||
| 70 | #ifdef __cplusplus | 68 | #ifdef __cplusplus |
| 71 | extern "C" { | 69 | extern "C" { |
| 72 | #endif | 70 | #endif |
| 73 | |||
| 74 | /* function pointer of sendchar to be used by print utility */ | 71 | /* function pointer of sendchar to be used by print utility */ |
| 75 | extern int8_t (*print_sendchar_func)(uint8_t); | 72 | void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t)); |
| 76 | extern bool print_enable; | ||
| 77 | 73 | ||
| 78 | /* print string stored in data memory(SRAM) */ | 74 | /* print string stored in data memory(SRAM) */ |
| 79 | void print_S(const char *s); | 75 | void print_S(const char *s); |
| @@ -100,9 +96,31 @@ void print_bin32(uint32_t data); | |||
| 100 | void print_bin_reverse8(uint8_t data); | 96 | void print_bin_reverse8(uint8_t data); |
| 101 | void print_bin_reverse16(uint16_t data); | 97 | void print_bin_reverse16(uint16_t data); |
| 102 | void print_bin_reverse32(uint32_t data); | 98 | void print_bin_reverse32(uint32_t data); |
| 103 | |||
| 104 | #ifdef __cplusplus | 99 | #ifdef __cplusplus |
| 105 | } | 100 | } |
| 106 | #endif | 101 | #endif |
| 107 | 102 | ||
| 103 | #else | ||
| 104 | |||
| 105 | #define print_set_sendchar(func) | ||
| 106 | #define print_S(s) | ||
| 107 | #define print_P(s) | ||
| 108 | #define print_CRLF() | ||
| 109 | #define print_dec(data) | ||
| 110 | #define print_decs(data) | ||
| 111 | #define print_hex4(data) | ||
| 112 | #define print_hex8(data) | ||
| 113 | #define print_hex16(data) | ||
| 114 | #define print_hex32(data) | ||
| 115 | #define print_bin4(data) | ||
| 116 | #define print_bin8(data) | ||
| 117 | #define print_bin16(data) | ||
| 118 | #define print_bin32(data) | ||
| 119 | #define print_bin_reverse8(data) | ||
| 120 | #define print_bin_reverse16(data) | ||
| 121 | #define print_bin_reverse32(data) | ||
| 122 | |||
| 123 | #endif | ||
| 124 | |||
| 125 | |||
| 108 | #endif | 126 | #endif |
diff --git a/keyboard/gh60/Makefile.lufa b/keyboard/gh60/Makefile.lufa index 8042ff3f4..f153bc311 100644 --- a/keyboard/gh60/Makefile.lufa +++ b/keyboard/gh60/Makefile.lufa | |||
| @@ -103,13 +103,14 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | |||
| 103 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 103 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
| 104 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 104 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
| 105 | CONSOLE_ENABLE = yes # Console for debug(+400) | 105 | CONSOLE_ENABLE = yes # Console for debug(+400) |
| 106 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 106 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend | 107 | SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend |
| 107 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA | 108 | #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA |
| 108 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 109 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 109 | 110 | ||
| 110 | 111 | ||
| 111 | # Optimize size but this may cause error "relocation truncated to fit" | 112 | # Optimize size but this may cause error "relocation truncated to fit" |
| 112 | EXTRALDFLAGS = -Wl,--relax | 113 | #EXTRALDFLAGS = -Wl,--relax |
| 113 | 114 | ||
| 114 | # Search Path | 115 | # Search Path |
| 115 | VPATH += $(TARGET_DIR) | 116 | VPATH += $(TARGET_DIR) |
diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc index f03ca9416..290f7cb87 100644 --- a/keyboard/gh60/Makefile.pjrc +++ b/keyboard/gh60/Makefile.pjrc | |||
| @@ -80,8 +80,9 @@ OPT_DEFS += -DBOOT_SIZE=4096 | |||
| 80 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | 80 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) |
| 81 | MOUSEKEY_ENABLE = yes # Mouse keys(+5000) | 81 | MOUSEKEY_ENABLE = yes # Mouse keys(+5000) |
| 82 | EXTRAKEY_ENABLE = yes # Audio control and System control(+600) | 82 | EXTRAKEY_ENABLE = yes # Audio control and System control(+600) |
| 83 | NKRO_ENABLE = yes # USB Nkey Rollover(+500) | ||
| 84 | CONSOLE_ENABLE = yes # Console for debug | 83 | CONSOLE_ENABLE = yes # Console for debug |
| 84 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 85 | NKRO_ENABLE = yes # USB Nkey Rollover(+500) | ||
| 85 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 86 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 86 | 87 | ||
| 87 | 88 | ||
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index 38d88eecc..7fe28470d 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h | |||
| @@ -57,4 +57,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 57 | #define BOOTLOADER_SIZE 4096 | 57 | #define BOOTLOADER_SIZE 4096 |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | |||
| 61 | /* | ||
| 62 | * Feature disable options | ||
| 63 | * These options are also useful to firmware size reduction. | ||
| 64 | */ | ||
| 65 | |||
| 66 | /* disable debug print */ | ||
| 67 | //#define NO_DEBUG | ||
| 68 | |||
| 69 | /* disable print */ | ||
| 70 | //#define NO_PRINT | ||
| 71 | |||
| 72 | /* disable action features */ | ||
| 73 | //#define NO_ACTION_KEYMAP | ||
| 74 | //#define NO_ACTION_OVERLAY | ||
| 75 | //#define NO_ACTION_TAPPING | ||
| 76 | //#define NO_ACTION_ONESHOT | ||
| 77 | //#define NO_ACTION_MACRO | ||
| 78 | //#define NO_ACTION_FUNCTION | ||
| 79 | |||
| 60 | #endif | 80 | #endif |
diff --git a/keyboard/hhkb/Makefile.iwrap b/keyboard/hhkb/Makefile.iwrap index f87df0d2b..8d7f4fc66 100644 --- a/keyboard/hhkb/Makefile.iwrap +++ b/keyboard/hhkb/Makefile.iwrap | |||
| @@ -44,8 +44,11 @@ F_CPU = 12000000 | |||
| 44 | # Build Options | 44 | # Build Options |
| 45 | # comment out to disable the options. | 45 | # comment out to disable the options. |
| 46 | # | 46 | # |
| 47 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration | ||
| 47 | MOUSEKEY_ENABLE = yes # Mouse keys | 48 | MOUSEKEY_ENABLE = yes # Mouse keys |
| 48 | EXTRAKEY_ENABLE = yes # Audio control and System control | 49 | EXTRAKEY_ENABLE = yes # Audio control and System control |
| 50 | CONSOLE_ENABLE = yes # Console for debug | ||
| 51 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 49 | #NKRO_ENABLE = yes # USB Nkey Rollover | 52 | #NKRO_ENABLE = yes # USB Nkey Rollover |
| 50 | 53 | ||
| 51 | 54 | ||
| @@ -83,7 +86,7 @@ PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE | |||
| 83 | 86 | ||
| 84 | 87 | ||
| 85 | # Search Path | 88 | # Search Path |
| 86 | VPATH = $(TARGET_DIR) | 89 | VPATH += $(TARGET_DIR) |
| 87 | VPATH += $(TOP_DIR) | 90 | VPATH += $(TOP_DIR) |
| 88 | 91 | ||
| 89 | #include $(TOP_DIR)/protocol/iwrap.mk | 92 | #include $(TOP_DIR)/protocol/iwrap.mk |
diff --git a/keyboard/hhkb/Makefile.lufa b/keyboard/hhkb/Makefile.lufa index 2755c9004..3e621c2b4 100644 --- a/keyboard/hhkb/Makefile.lufa +++ b/keyboard/hhkb/Makefile.lufa | |||
| @@ -104,6 +104,7 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration | |||
| 104 | MOUSEKEY_ENABLE = yes # Mouse keys | 104 | MOUSEKEY_ENABLE = yes # Mouse keys |
| 105 | EXTRAKEY_ENABLE = yes # Audio control and System control | 105 | EXTRAKEY_ENABLE = yes # Audio control and System control |
| 106 | CONSOLE_ENABLE = yes # Console for debug | 106 | CONSOLE_ENABLE = yes # Console for debug |
| 107 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 107 | #NKRO_ENABLE = yes # USB Nkey Rollover | 108 | #NKRO_ENABLE = yes # USB Nkey Rollover |
| 108 | 109 | ||
| 109 | 110 | ||
diff --git a/keyboard/hhkb/Makefile.pjrc b/keyboard/hhkb/Makefile.pjrc index f8836a2ca..f64cd9be4 100644 --- a/keyboard/hhkb/Makefile.pjrc +++ b/keyboard/hhkb/Makefile.pjrc | |||
| @@ -38,9 +38,12 @@ F_CPU = 16000000 | |||
| 38 | 38 | ||
| 39 | # Build Options | 39 | # Build Options |
| 40 | # comment out to disable the options. | 40 | # comment out to disable the options. |
| 41 | # | ||
| 42 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration | ||
| 41 | MOUSEKEY_ENABLE = yes # Mouse keys | 43 | MOUSEKEY_ENABLE = yes # Mouse keys |
| 42 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | ||
| 43 | EXTRAKEY_ENABLE = yes # Audio control and System control | 44 | EXTRAKEY_ENABLE = yes # Audio control and System control |
| 45 | CONSOLE_ENABLE = yes # Console for debug | ||
| 46 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 44 | NKRO_ENABLE = yes # USB Nkey Rollover | 47 | NKRO_ENABLE = yes # USB Nkey Rollover |
| 45 | 48 | ||
| 46 | 49 | ||
| @@ -51,8 +54,8 @@ PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex | |||
| 51 | 54 | ||
| 52 | 55 | ||
| 53 | # Search Path | 56 | # Search Path |
| 54 | VPATH = $(TARGET_DIR) | 57 | VPATH += $(TARGET_DIR) |
| 55 | VPATH = $(TOP_DIR) | 58 | VPATH += $(TOP_DIR) |
| 56 | 59 | ||
| 57 | include $(TOP_DIR)/protocol/pjrc.mk | 60 | include $(TOP_DIR)/protocol/pjrc.mk |
| 58 | include $(TOP_DIR)/common.mk | 61 | include $(TOP_DIR)/common.mk |
diff --git a/keyboard/hhkb/Makefile.vusb b/keyboard/hhkb/Makefile.vusb index 0e0e4a8cd..4343b210d 100644 --- a/keyboard/hhkb/Makefile.vusb +++ b/keyboard/hhkb/Makefile.vusb | |||
| @@ -44,8 +44,11 @@ F_CPU = 12000000 | |||
| 44 | # Build Options | 44 | # Build Options |
| 45 | # comment out to disable the options. | 45 | # comment out to disable the options. |
| 46 | # | 46 | # |
| 47 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration | ||
| 47 | MOUSEKEY_ENABLE = yes # Mouse keys | 48 | MOUSEKEY_ENABLE = yes # Mouse keys |
| 48 | EXTRAKEY_ENABLE = yes # Audio control and System control | 49 | EXTRAKEY_ENABLE = yes # Audio control and System control |
| 50 | CONSOLE_ENABLE = yes # Console for debug | ||
| 51 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 49 | #NKRO_ENABLE = yes # USB Nkey Rollover | 52 | #NKRO_ENABLE = yes # USB Nkey Rollover |
| 50 | 53 | ||
| 51 | 54 | ||
| @@ -83,7 +86,7 @@ PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE | |||
| 83 | 86 | ||
| 84 | 87 | ||
| 85 | # Search Path | 88 | # Search Path |
| 86 | VPATH = $(TARGET_DIR) | 89 | VPATH += $(TARGET_DIR) |
| 87 | VPATH += $(TOP_DIR) | 90 | VPATH += $(TOP_DIR) |
| 88 | 91 | ||
| 89 | include $(TOP_DIR)/protocol/vusb.mk | 92 | include $(TOP_DIR)/protocol/vusb.mk |
diff --git a/keyboard/hhkb/config.h b/keyboard/hhkb/config.h index ef2958981..e34d9a6ba 100644 --- a/keyboard/hhkb/config.h +++ b/keyboard/hhkb/config.h | |||
| @@ -71,18 +71,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 71 | /* tap count needed for toggling a feature */ | 71 | /* tap count needed for toggling a feature */ |
| 72 | #define TAPPING_TOGGLE 5 | 72 | #define TAPPING_TOGGLE 5 |
| 73 | 73 | ||
| 74 | /* PS/2 mouse */ | 74 | |
| 75 | #ifdef PS2_MOUSE_ENABLE | ||
| 76 | /* | 75 | /* |
| 77 | # define PS2_CLOCK_PORT PORTF | 76 | * Feature disable options |
| 78 | # define PS2_CLOCK_PIN PINF | 77 | * These options are also useful to firmware size reduction. |
| 79 | # define PS2_CLOCK_DDR DDRF | 78 | */ |
| 80 | # define PS2_CLOCK_BIT 0 | 79 | |
| 81 | # define PS2_DATA_PORT PORTF | 80 | /* disable debug print */ |
| 82 | # define PS2_DATA_PIN PINF | 81 | //#define NO_DEBUG |
| 83 | # define PS2_DATA_DDR DDRF | 82 | |
| 84 | # define PS2_DATA_BIT 1 | 83 | /* disable print */ |
| 85 | */ | 84 | //#define NO_PRINT |
| 86 | #endif | 85 | |
| 86 | /* disable action features */ | ||
| 87 | //#define NO_ACTION_KEYMAP | ||
| 88 | //#define NO_ACTION_OVERLAY | ||
| 89 | //#define NO_ACTION_TAPPING | ||
| 90 | //#define NO_ACTION_ONESHOT | ||
| 91 | //#define NO_ACTION_MACRO | ||
| 92 | //#define NO_ACTION_FUNCTION | ||
| 87 | 93 | ||
| 88 | #endif | 94 | #endif |
