action.c 23 KB

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