diff options
| -rw-r--r-- | common/action.c | 33 | ||||
| -rw-r--r-- | common/action_macro.c | 3 | ||||
| -rw-r--r-- | common/action_macro.h | 4 | ||||
| -rw-r--r-- | keyboard/gh60/config.h | 2 |
4 files changed, 36 insertions, 6 deletions
diff --git a/common/action.c b/common/action.c index 1b84d1e88..eda3a6d32 100644 --- a/common/action.c +++ b/common/action.c | |||
| @@ -30,14 +30,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | static void process_action(keyrecord_t *record); | 32 | static void process_action(keyrecord_t *record); |
| 33 | #ifndef NO_ACTION_TAPPING | ||
| 33 | static bool process_tapping(keyrecord_t *record); | 34 | static bool process_tapping(keyrecord_t *record); |
| 34 | static void waiting_buffer_scan_tap(void); | 35 | static void waiting_buffer_scan_tap(void); |
| 36 | #endif | ||
| 35 | 37 | ||
| 36 | static void debug_event(keyevent_t event); | 38 | static void debug_event(keyevent_t event); |
| 37 | static void debug_record(keyrecord_t record); | 39 | static void debug_record(keyrecord_t record); |
| 38 | static void debug_action(action_t action); | 40 | static void debug_action(action_t action); |
| 41 | #ifndef NO_ACTION_TAPPING | ||
| 39 | static void debug_tapping_key(void); | 42 | static void debug_tapping_key(void); |
| 40 | static void debug_waiting_buffer(void); | 43 | static void debug_waiting_buffer(void); |
| 44 | #endif | ||
| 41 | 45 | ||
| 42 | 46 | ||
| 43 | /* | 47 | /* |
| @@ -53,6 +57,7 @@ static void debug_waiting_buffer(void); | |||
| 53 | #define TAPPING_TOGGLE 5 | 57 | #define TAPPING_TOGGLE 5 |
| 54 | #endif | 58 | #endif |
| 55 | 59 | ||
| 60 | #ifndef NO_ACTION_TAPPING | ||
| 56 | /* stores a key event of current tap. */ | 61 | /* stores a key event of current tap. */ |
| 57 | static keyrecord_t tapping_key = {}; | 62 | static keyrecord_t tapping_key = {}; |
| 58 | 63 | ||
| @@ -158,7 +163,7 @@ static void oneshot_toggle(void) | |||
| 158 | { | 163 | { |
| 159 | oneshot_state.disabled = !oneshot_state.disabled; | 164 | oneshot_state.disabled = !oneshot_state.disabled; |
| 160 | } | 165 | } |
| 161 | 166 | #endif | |
| 162 | 167 | ||
| 163 | 168 | ||
| 164 | void action_exec(keyevent_t event) | 169 | void action_exec(keyevent_t event) |
| @@ -170,6 +175,7 @@ void action_exec(keyevent_t event) | |||
| 170 | 175 | ||
| 171 | keyrecord_t record = { .event = event }; | 176 | keyrecord_t record = { .event = event }; |
| 172 | 177 | ||
| 178 | #ifndef NO_ACTION_TAPPING | ||
| 173 | // pre-process on tapping | 179 | // pre-process on tapping |
| 174 | if (process_tapping(&record)) { | 180 | if (process_tapping(&record)) { |
| 175 | if (!IS_NOEVENT(record.event)) { | 181 | if (!IS_NOEVENT(record.event)) { |
| @@ -202,6 +208,12 @@ void action_exec(keyevent_t event) | |||
| 202 | if (!IS_NOEVENT(event)) { | 208 | if (!IS_NOEVENT(event)) { |
| 203 | debug("\n"); | 209 | debug("\n"); |
| 204 | } | 210 | } |
| 211 | #else | ||
| 212 | process_action(&record); | ||
| 213 | if (!IS_NOEVENT(record.event)) { | ||
| 214 | debug("processed: "); debug_record(record); debug("\n"); | ||
| 215 | } | ||
| 216 | #endif | ||
| 205 | } | 217 | } |
| 206 | 218 | ||
| 207 | static void process_action(keyrecord_t *record) | 219 | static void process_action(keyrecord_t *record) |
| @@ -244,6 +256,7 @@ static void process_action(keyrecord_t *record) | |||
| 244 | } | 256 | } |
| 245 | } | 257 | } |
| 246 | break; | 258 | break; |
| 259 | #ifndef NO_ACTION_TAPPING | ||
| 247 | case ACT_LMODS_TAP: | 260 | case ACT_LMODS_TAP: |
| 248 | case ACT_RMODS_TAP: | 261 | case ACT_RMODS_TAP: |
| 249 | { | 262 | { |
| @@ -319,10 +332,11 @@ static void process_action(keyrecord_t *record) | |||
| 319 | } | 332 | } |
| 320 | } | 333 | } |
| 321 | break; | 334 | break; |
| 335 | #endif | ||
| 322 | 336 | ||
| 337 | #ifdef EXTRAKEY_ENABLE | ||
| 323 | /* other HID usage */ | 338 | /* other HID usage */ |
| 324 | case ACT_USAGE: | 339 | case ACT_USAGE: |
| 325 | #ifdef EXTRAKEY_ENABLE | ||
| 326 | switch (action.usage.page) { | 340 | switch (action.usage.page) { |
| 327 | case PAGE_SYSTEM: | 341 | case PAGE_SYSTEM: |
| 328 | if (event.pressed) { | 342 | if (event.pressed) { |
| @@ -339,12 +353,12 @@ static void process_action(keyrecord_t *record) | |||
| 339 | } | 353 | } |
| 340 | break; | 354 | break; |
| 341 | } | 355 | } |
| 342 | #endif | ||
| 343 | break; | 356 | break; |
| 357 | #endif | ||
| 344 | 358 | ||
| 359 | #ifdef MOUSEKEY_ENABLE | ||
| 345 | /* Mouse key */ | 360 | /* Mouse key */ |
| 346 | case ACT_MOUSEKEY: | 361 | case ACT_MOUSEKEY: |
| 347 | #ifdef MOUSEKEY_ENABLE | ||
| 348 | if (event.pressed) { | 362 | if (event.pressed) { |
| 349 | mousekey_on(action.key.code); | 363 | mousekey_on(action.key.code); |
| 350 | mousekey_send(); | 364 | mousekey_send(); |
| @@ -352,8 +366,8 @@ static void process_action(keyrecord_t *record) | |||
| 352 | mousekey_off(action.key.code); | 366 | mousekey_off(action.key.code); |
| 353 | mousekey_send(); | 367 | mousekey_send(); |
| 354 | } | 368 | } |
| 355 | #endif | ||
| 356 | break; | 369 | break; |
| 370 | #endif | ||
| 357 | 371 | ||
| 358 | case ACT_KEYMAP: | 372 | case ACT_KEYMAP: |
| 359 | switch (action.layer.code) { | 373 | switch (action.layer.code) { |
| @@ -687,6 +701,7 @@ static void process_action(keyrecord_t *record) | |||
| 687 | } | 701 | } |
| 688 | } | 702 | } |
| 689 | 703 | ||
| 704 | #ifndef NO_ACTION_TAPPING | ||
| 690 | /* Tapping | 705 | /* Tapping |
| 691 | * | 706 | * |
| 692 | * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. | 707 | * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. |
| @@ -881,6 +896,7 @@ static void waiting_buffer_scan_tap(void) | |||
| 881 | } | 896 | } |
| 882 | } | 897 | } |
| 883 | } | 898 | } |
| 899 | #endif | ||
| 884 | 900 | ||
| 885 | 901 | ||
| 886 | 902 | ||
| @@ -908,6 +924,7 @@ void register_code(uint8_t code) | |||
| 908 | // TODO: should push command_proc out of this block? | 924 | // TODO: should push command_proc out of this block? |
| 909 | if (command_proc(code)) return; | 925 | if (command_proc(code)) return; |
| 910 | 926 | ||
| 927 | #ifndef NO_ACTION_TAPPING | ||
| 911 | if (oneshot_state.mods && oneshot_state.ready && !oneshot_state.disabled) { | 928 | if (oneshot_state.mods && oneshot_state.ready && !oneshot_state.disabled) { |
| 912 | uint8_t tmp_mods = host_get_mods(); | 929 | uint8_t tmp_mods = host_get_mods(); |
| 913 | host_add_mods(oneshot_state.mods); | 930 | host_add_mods(oneshot_state.mods); |
| @@ -916,7 +933,9 @@ void register_code(uint8_t code) | |||
| 916 | 933 | ||
| 917 | host_set_mods(tmp_mods); | 934 | host_set_mods(tmp_mods); |
| 918 | oneshot_state.ready = false; | 935 | oneshot_state.ready = false; |
| 919 | } else { | 936 | } else |
| 937 | #endif | ||
| 938 | { | ||
| 920 | host_add_key(code); | 939 | host_add_key(code); |
| 921 | host_send_keyboard_report(); | 940 | host_send_keyboard_report(); |
| 922 | } | 941 | } |
| @@ -1064,6 +1083,7 @@ static void debug_action(action_t action) | |||
| 1064 | debug_hex8(action.kind.param & 0xff); | 1083 | debug_hex8(action.kind.param & 0xff); |
| 1065 | debug("]"); | 1084 | debug("]"); |
| 1066 | } | 1085 | } |
| 1086 | #ifndef NO_ACTION_TAPPING | ||
| 1067 | static void debug_tapping_key(void) | 1087 | static void debug_tapping_key(void) |
| 1068 | { | 1088 | { |
| 1069 | debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); | 1089 | debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); |
| @@ -1076,3 +1096,4 @@ static void debug_waiting_buffer(void) | |||
| 1076 | } | 1096 | } |
| 1077 | debug("}\n"); | 1097 | debug("}\n"); |
| 1078 | } | 1098 | } |
| 1099 | #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/keyboard/gh60/config.h b/keyboard/gh60/config.h index bb4277ae6..bf5807644 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h | |||
| @@ -62,5 +62,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 62 | //#define NO_PRINT | 62 | //#define NO_PRINT |
| 63 | 63 | ||
| 64 | #define NO_ACTION_OVERLAY | 64 | #define NO_ACTION_OVERLAY |
| 65 | #define NO_ACTION_TAPPING | ||
| 66 | #define NO_ACTION_MACRO | ||
| 65 | 67 | ||
| 66 | #endif | 68 | #endif |
