action.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. /*
  2. Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "host.h"
  15. #include "keycode.h"
  16. #include "keyboard.h"
  17. #include "mousekey.h"
  18. #include "command.h"
  19. #include "led.h"
  20. #include "backlight.h"
  21. #include "action_layer.h"
  22. #include "action_tapping.h"
  23. #include "action_macro.h"
  24. #include "action_util.h"
  25. #include "action.h"
  26. #ifdef DEBUG_ACTION
  27. #include "debug.h"
  28. #else
  29. #include "nodebug.h"
  30. #endif
  31. void action_exec(keyevent_t event)
  32. {
  33. if (!IS_NOEVENT(event)) {
  34. dprint("\n---- action_exec: start -----\n");
  35. dprint("EVENT: "); debug_event(event); dprintln();
  36. }
  37. keyrecord_t record = { .event = event };
  38. #ifndef NO_ACTION_TAPPING
  39. action_tapping_process(record);
  40. #else
  41. process_action(&record);
  42. if (!IS_NOEVENT(record.event)) {
  43. dprint("processed: "); debug_record(record); dprintln();
  44. }
  45. #endif
  46. }
  47. #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
  48. bool disable_action_cache = false;
  49. void process_action_nocache(keyrecord_t *record)
  50. {
  51. disable_action_cache = true;
  52. process_action(record);
  53. disable_action_cache = false;
  54. }
  55. #else
  56. void process_action_nocache(keyrecord_t *record)
  57. {
  58. process_action(record);
  59. }
  60. #endif
  61. __attribute__ ((weak))
  62. bool process_action_quantum(keyrecord_t *record) {
  63. return true;
  64. }
  65. void process_action(keyrecord_t *record)
  66. {
  67. bool do_release_oneshot = false;
  68. keyevent_t event = record->event;
  69. #ifndef NO_ACTION_TAPPING
  70. uint8_t tap_count = record->tap.count;
  71. #endif
  72. if (IS_NOEVENT(event)) { return; }
  73. #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  74. if (has_oneshot_layer_timed_out()) {
  75. dprintf("Oneshot layer: timeout\n");
  76. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  77. }
  78. #endif
  79. if (!process_action_quantum(record))
  80. return;
  81. action_t action = store_or_get_action(event.pressed, event.key);
  82. dprint("ACTION: "); debug_action(action);
  83. #ifndef NO_ACTION_LAYER
  84. dprint(" layer_state: "); layer_debug();
  85. dprint(" default_layer_state: "); default_layer_debug();
  86. #endif
  87. dprintln();
  88. if (event.pressed) {
  89. // clear the potential weak mods left by previously pressed keys
  90. clear_weak_mods();
  91. }
  92. #ifndef NO_ACTION_ONESHOT
  93. // notice we only clear the one shot layer if the pressed key is not a modifier.
  94. if (is_oneshot_layer_active() && event.pressed && !IS_MOD(action.key.code)) {
  95. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  96. do_release_oneshot = !is_oneshot_layer_active();
  97. }
  98. #endif
  99. switch (action.kind.id) {
  100. /* Key and Mods */
  101. case ACT_LMODS:
  102. case ACT_RMODS:
  103. {
  104. uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods :
  105. action.key.mods<<4;
  106. if (event.pressed) {
  107. if (mods) {
  108. if (IS_MOD(action.key.code)) {
  109. // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
  110. // this also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT)
  111. add_mods(mods);
  112. } else {
  113. add_weak_mods(mods);
  114. }
  115. send_keyboard_report();
  116. }
  117. register_code(action.key.code);
  118. } else {
  119. unregister_code(action.key.code);
  120. if (mods) {
  121. if (IS_MOD(action.key.code)) {
  122. del_mods(mods);
  123. } else {
  124. del_weak_mods(mods);
  125. }
  126. send_keyboard_report();
  127. }
  128. }
  129. }
  130. break;
  131. #ifndef NO_ACTION_TAPPING
  132. case ACT_LMODS_TAP:
  133. case ACT_RMODS_TAP:
  134. {
  135. uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods :
  136. action.key.mods<<4;
  137. switch (action.layer_tap.code) {
  138. #ifndef NO_ACTION_ONESHOT
  139. case MODS_ONESHOT:
  140. // Oneshot modifier
  141. if (event.pressed) {
  142. if (tap_count == 0) {
  143. dprint("MODS_TAP: Oneshot: 0\n");
  144. register_mods(mods);
  145. } else if (tap_count == 1) {
  146. dprint("MODS_TAP: Oneshot: start\n");
  147. set_oneshot_mods(mods);
  148. #if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  149. } else if (tap_count == ONESHOT_TAP_TOGGLE) {
  150. dprint("MODS_TAP: Toggling oneshot");
  151. clear_oneshot_mods();
  152. set_oneshot_locked_mods(mods);
  153. register_mods(mods);
  154. #endif
  155. } else {
  156. register_mods(mods);
  157. }
  158. } else {
  159. if (tap_count == 0) {
  160. clear_oneshot_mods();
  161. unregister_mods(mods);
  162. } else if (tap_count == 1) {
  163. // Retain Oneshot mods
  164. #if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  165. if (mods & get_mods()) {
  166. clear_oneshot_locked_mods();
  167. clear_oneshot_mods();
  168. unregister_mods(mods);
  169. }
  170. } else if (tap_count == ONESHOT_TAP_TOGGLE) {
  171. // Toggle Oneshot Layer
  172. #endif
  173. } else {
  174. clear_oneshot_mods();
  175. unregister_mods(mods);
  176. }
  177. }
  178. break;
  179. #endif
  180. case MODS_TAP_TOGGLE:
  181. if (event.pressed) {
  182. if (tap_count <= TAPPING_TOGGLE) {
  183. register_mods(mods);
  184. }
  185. } else {
  186. if (tap_count < TAPPING_TOGGLE) {
  187. unregister_mods(mods);
  188. }
  189. }
  190. break;
  191. default:
  192. if (event.pressed) {
  193. if (tap_count > 0) {
  194. #ifndef IGNORE_MOD_TAP_INTERRUPT
  195. if (record->tap.interrupted) {
  196. dprint("mods_tap: tap: cancel: add_mods\n");
  197. // ad hoc: set 0 to cancel tap
  198. record->tap.count = 0;
  199. register_mods(mods);
  200. } else
  201. #endif
  202. {
  203. dprint("MODS_TAP: Tap: register_code\n");
  204. register_code(action.key.code);
  205. }
  206. } else {
  207. dprint("MODS_TAP: No tap: add_mods\n");
  208. register_mods(mods);
  209. }
  210. } else {
  211. if (tap_count > 0) {
  212. dprint("MODS_TAP: Tap: unregister_code\n");
  213. unregister_code(action.key.code);
  214. } else {
  215. dprint("MODS_TAP: No tap: add_mods\n");
  216. unregister_mods(mods);
  217. }
  218. }
  219. break;
  220. }
  221. }
  222. break;
  223. #endif
  224. #ifdef EXTRAKEY_ENABLE
  225. /* other HID usage */
  226. case ACT_USAGE:
  227. switch (action.usage.page) {
  228. case PAGE_SYSTEM:
  229. if (event.pressed) {
  230. host_system_send(action.usage.code);
  231. } else {
  232. host_system_send(0);
  233. }
  234. break;
  235. case PAGE_CONSUMER:
  236. if (event.pressed) {
  237. host_consumer_send(action.usage.code);
  238. } else {
  239. host_consumer_send(0);
  240. }
  241. break;
  242. }
  243. break;
  244. #endif
  245. #ifdef MOUSEKEY_ENABLE
  246. /* Mouse key */
  247. case ACT_MOUSEKEY:
  248. if (event.pressed) {
  249. mousekey_on(action.key.code);
  250. mousekey_send();
  251. } else {
  252. mousekey_off(action.key.code);
  253. mousekey_send();
  254. }
  255. break;
  256. #endif
  257. #ifndef NO_ACTION_LAYER
  258. case ACT_LAYER:
  259. if (action.layer_bitop.on == 0) {
  260. /* Default Layer Bitwise Operation */
  261. if (!event.pressed) {
  262. uint8_t shift = action.layer_bitop.part*4;
  263. uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift;
  264. uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0;
  265. switch (action.layer_bitop.op) {
  266. case OP_BIT_AND: default_layer_and(bits | mask); break;
  267. case OP_BIT_OR: default_layer_or(bits | mask); break;
  268. case OP_BIT_XOR: default_layer_xor(bits | mask); break;
  269. case OP_BIT_SET: default_layer_and(mask); default_layer_or(bits); break;
  270. }
  271. }
  272. } else {
  273. /* Layer Bitwise Operation */
  274. if (event.pressed ? (action.layer_bitop.on & ON_PRESS) :
  275. (action.layer_bitop.on & ON_RELEASE)) {
  276. uint8_t shift = action.layer_bitop.part*4;
  277. uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift;
  278. uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0;
  279. switch (action.layer_bitop.op) {
  280. case OP_BIT_AND: layer_and(bits | mask); break;
  281. case OP_BIT_OR: layer_or(bits | mask); break;
  282. case OP_BIT_XOR: layer_xor(bits | mask); break;
  283. case OP_BIT_SET: layer_and(mask); layer_or(bits); break;
  284. }
  285. }
  286. }
  287. break;
  288. #ifndef NO_ACTION_TAPPING
  289. case ACT_LAYER_TAP:
  290. case ACT_LAYER_TAP_EXT:
  291. switch (action.layer_tap.code) {
  292. case 0xe0 ... 0xef:
  293. /* layer On/Off with modifiers(left only) */
  294. if (event.pressed) {
  295. layer_on(action.layer_tap.val);
  296. register_mods(action.layer_tap.code & 0x0f);
  297. } else {
  298. layer_off(action.layer_tap.val);
  299. unregister_mods(action.layer_tap.code & 0x0f);
  300. }
  301. break;
  302. case OP_TAP_TOGGLE:
  303. /* tap toggle */
  304. if (event.pressed) {
  305. if (tap_count < TAPPING_TOGGLE) {
  306. layer_invert(action.layer_tap.val);
  307. }
  308. } else {
  309. if (tap_count <= TAPPING_TOGGLE) {
  310. layer_invert(action.layer_tap.val);
  311. }
  312. }
  313. break;
  314. case OP_ON_OFF:
  315. event.pressed ? layer_on(action.layer_tap.val) :
  316. layer_off(action.layer_tap.val);
  317. break;
  318. case OP_OFF_ON:
  319. event.pressed ? layer_off(action.layer_tap.val) :
  320. layer_on(action.layer_tap.val);
  321. break;
  322. case OP_SET_CLEAR:
  323. event.pressed ? layer_move(action.layer_tap.val) :
  324. layer_clear();
  325. break;
  326. #ifndef NO_ACTION_ONESHOT
  327. case OP_ONESHOT:
  328. // Oneshot modifier
  329. #if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  330. do_release_oneshot = false;
  331. if (event.pressed) {
  332. del_mods(get_oneshot_locked_mods());
  333. if (get_oneshot_layer_state() == ONESHOT_TOGGLED) {
  334. reset_oneshot_layer();
  335. layer_off(action.layer_tap.val);
  336. break;
  337. } else if (tap_count < ONESHOT_TAP_TOGGLE) {
  338. layer_on(action.layer_tap.val);
  339. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  340. }
  341. } else {
  342. add_mods(get_oneshot_locked_mods());
  343. if (tap_count >= ONESHOT_TAP_TOGGLE) {
  344. reset_oneshot_layer();
  345. clear_oneshot_locked_mods();
  346. set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED);
  347. } else {
  348. clear_oneshot_layer_state(ONESHOT_PRESSED);
  349. }
  350. }
  351. #else
  352. if (event.pressed) {
  353. layer_on(action.layer_tap.val);
  354. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  355. } else {
  356. clear_oneshot_layer_state(ONESHOT_PRESSED);
  357. if (tap_count > 1) {
  358. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  359. }
  360. }
  361. #endif
  362. break;
  363. #endif
  364. default:
  365. /* tap key */
  366. if (event.pressed) {
  367. if (tap_count > 0) {
  368. dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
  369. register_code(action.layer_tap.code);
  370. } else {
  371. dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
  372. layer_on(action.layer_tap.val);
  373. }
  374. } else {
  375. if (tap_count > 0) {
  376. dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  377. unregister_code(action.layer_tap.code);
  378. } else {
  379. dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
  380. layer_off(action.layer_tap.val);
  381. }
  382. }
  383. break;
  384. }
  385. break;
  386. #endif
  387. #endif
  388. /* Extentions */
  389. #ifndef NO_ACTION_MACRO
  390. case ACT_MACRO:
  391. action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
  392. break;
  393. #endif
  394. #ifdef BACKLIGHT_ENABLE
  395. case ACT_BACKLIGHT:
  396. if (!event.pressed) {
  397. switch (action.backlight.opt) {
  398. case BACKLIGHT_INCREASE:
  399. backlight_increase();
  400. break;
  401. case BACKLIGHT_DECREASE:
  402. backlight_decrease();
  403. break;
  404. case BACKLIGHT_TOGGLE:
  405. backlight_toggle();
  406. break;
  407. case BACKLIGHT_STEP:
  408. backlight_step();
  409. break;
  410. case BACKLIGHT_LEVEL:
  411. backlight_level(action.backlight.level);
  412. break;
  413. }
  414. }
  415. break;
  416. #endif
  417. case ACT_COMMAND:
  418. break;
  419. #ifndef NO_ACTION_FUNCTION
  420. case ACT_FUNCTION:
  421. action_function(record, action.func.id, action.func.opt);
  422. break;
  423. #endif
  424. default:
  425. break;
  426. }
  427. #ifndef NO_ACTION_ONESHOT
  428. /* Because we switch layers after a oneshot event, we need to release the
  429. * key before we leave the layer or no key up event will be generated.
  430. */
  431. if (do_release_oneshot && !(get_oneshot_layer_state() & ONESHOT_PRESSED ) ) {
  432. record->event.pressed = false;
  433. layer_on(get_oneshot_layer());
  434. process_action(record);
  435. layer_off(get_oneshot_layer());
  436. }
  437. #endif
  438. }
  439. /*
  440. * Utilities for actions.
  441. */
  442. void register_code(uint8_t code)
  443. {
  444. if (code == KC_NO) {
  445. return;
  446. }
  447. #ifdef LOCKING_SUPPORT_ENABLE
  448. else if (KC_LOCKING_CAPS == code) {
  449. #ifdef LOCKING_RESYNC_ENABLE
  450. // Resync: ignore if caps lock already is on
  451. if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
  452. #endif
  453. add_key(KC_CAPSLOCK);
  454. send_keyboard_report();
  455. del_key(KC_CAPSLOCK);
  456. send_keyboard_report();
  457. }
  458. else if (KC_LOCKING_NUM == code) {
  459. #ifdef LOCKING_RESYNC_ENABLE
  460. if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return;
  461. #endif
  462. add_key(KC_NUMLOCK);
  463. send_keyboard_report();
  464. del_key(KC_NUMLOCK);
  465. send_keyboard_report();
  466. }
  467. else if (KC_LOCKING_SCROLL == code) {
  468. #ifdef LOCKING_RESYNC_ENABLE
  469. if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return;
  470. #endif
  471. add_key(KC_SCROLLLOCK);
  472. send_keyboard_report();
  473. del_key(KC_SCROLLLOCK);
  474. send_keyboard_report();
  475. }
  476. #endif
  477. else if IS_KEY(code) {
  478. // TODO: should push command_proc out of this block?
  479. if (command_proc(code)) return;
  480. #ifndef NO_ACTION_ONESHOT
  481. /* TODO: remove
  482. if (oneshot_state.mods && !oneshot_state.disabled) {
  483. uint8_t tmp_mods = get_mods();
  484. add_mods(oneshot_state.mods);
  485. add_key(code);
  486. send_keyboard_report();
  487. set_mods(tmp_mods);
  488. send_keyboard_report();
  489. oneshot_cancel();
  490. } else
  491. */
  492. #endif
  493. {
  494. add_key(code);
  495. send_keyboard_report();
  496. }
  497. }
  498. else if IS_MOD(code) {
  499. add_mods(MOD_BIT(code));
  500. send_keyboard_report();
  501. }
  502. else if IS_SYSTEM(code) {
  503. host_system_send(KEYCODE2SYSTEM(code));
  504. }
  505. else if IS_CONSUMER(code) {
  506. host_consumer_send(KEYCODE2CONSUMER(code));
  507. }
  508. }
  509. void unregister_code(uint8_t code)
  510. {
  511. if (code == KC_NO) {
  512. return;
  513. }
  514. #ifdef LOCKING_SUPPORT_ENABLE
  515. else if (KC_LOCKING_CAPS == code) {
  516. #ifdef LOCKING_RESYNC_ENABLE
  517. // Resync: ignore if caps lock already is off
  518. if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return;
  519. #endif
  520. add_key(KC_CAPSLOCK);
  521. send_keyboard_report();
  522. del_key(KC_CAPSLOCK);
  523. send_keyboard_report();
  524. }
  525. else if (KC_LOCKING_NUM == code) {
  526. #ifdef LOCKING_RESYNC_ENABLE
  527. if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return;
  528. #endif
  529. add_key(KC_NUMLOCK);
  530. send_keyboard_report();
  531. del_key(KC_NUMLOCK);
  532. send_keyboard_report();
  533. }
  534. else if (KC_LOCKING_SCROLL == code) {
  535. #ifdef LOCKING_RESYNC_ENABLE
  536. if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return;
  537. #endif
  538. add_key(KC_SCROLLLOCK);
  539. send_keyboard_report();
  540. del_key(KC_SCROLLLOCK);
  541. send_keyboard_report();
  542. }
  543. #endif
  544. else if IS_KEY(code) {
  545. del_key(code);
  546. send_keyboard_report();
  547. }
  548. else if IS_MOD(code) {
  549. del_mods(MOD_BIT(code));
  550. send_keyboard_report();
  551. }
  552. else if IS_SYSTEM(code) {
  553. host_system_send(0);
  554. }
  555. else if IS_CONSUMER(code) {
  556. host_consumer_send(0);
  557. }
  558. }
  559. void register_mods(uint8_t mods)
  560. {
  561. if (mods) {
  562. add_mods(mods);
  563. send_keyboard_report();
  564. }
  565. }
  566. void unregister_mods(uint8_t mods)
  567. {
  568. if (mods) {
  569. del_mods(mods);
  570. send_keyboard_report();
  571. }
  572. }
  573. void clear_keyboard(void)
  574. {
  575. clear_mods();
  576. clear_keyboard_but_mods();
  577. }
  578. void clear_keyboard_but_mods(void)
  579. {
  580. clear_weak_mods();
  581. clear_macro_mods();
  582. clear_keys();
  583. send_keyboard_report();
  584. #ifdef MOUSEKEY_ENABLE
  585. mousekey_clear();
  586. mousekey_send();
  587. #endif
  588. #ifdef EXTRAKEY_ENABLE
  589. host_system_send(0);
  590. host_consumer_send(0);
  591. #endif
  592. }
  593. bool is_tap_key(keypos_t key)
  594. {
  595. action_t action = layer_switch_get_action(key);
  596. switch (action.kind.id) {
  597. case ACT_LMODS_TAP:
  598. case ACT_RMODS_TAP:
  599. case ACT_LAYER_TAP:
  600. case ACT_LAYER_TAP_EXT:
  601. switch (action.layer_tap.code) {
  602. case 0x00 ... 0xdf:
  603. case OP_TAP_TOGGLE:
  604. case OP_ONESHOT:
  605. return true;
  606. }
  607. return false;
  608. case ACT_MACRO:
  609. case ACT_FUNCTION:
  610. if (action.func.opt & FUNC_TAP) { return true; }
  611. return false;
  612. }
  613. return false;
  614. }
  615. /*
  616. * debug print
  617. */
  618. void debug_event(keyevent_t event)
  619. {
  620. dprintf("%04X%c(%u)", (event.key.row<<8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
  621. }
  622. void debug_record(keyrecord_t record)
  623. {
  624. debug_event(record.event);
  625. #ifndef NO_ACTION_TAPPING
  626. dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
  627. #endif
  628. }
  629. void debug_action(action_t action)
  630. {
  631. switch (action.kind.id) {
  632. case ACT_LMODS: dprint("ACT_LMODS"); break;
  633. case ACT_RMODS: dprint("ACT_RMODS"); break;
  634. case ACT_LMODS_TAP: dprint("ACT_LMODS_TAP"); break;
  635. case ACT_RMODS_TAP: dprint("ACT_RMODS_TAP"); break;
  636. case ACT_USAGE: dprint("ACT_USAGE"); break;
  637. case ACT_MOUSEKEY: dprint("ACT_MOUSEKEY"); break;
  638. case ACT_LAYER: dprint("ACT_LAYER"); break;
  639. case ACT_LAYER_TAP: dprint("ACT_LAYER_TAP"); break;
  640. case ACT_LAYER_TAP_EXT: dprint("ACT_LAYER_TAP_EXT"); break;
  641. case ACT_MACRO: dprint("ACT_MACRO"); break;
  642. case ACT_COMMAND: dprint("ACT_COMMAND"); break;
  643. case ACT_FUNCTION: dprint("ACT_FUNCTION"); break;
  644. default: dprint("UNKNOWN"); break;
  645. }
  646. dprintf("[%X:%02X]", action.kind.param>>8, action.kind.param&0xff);
  647. }