action.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  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 <limits.h>
  15. #include "host.h"
  16. #include "keycode.h"
  17. #include "keyboard.h"
  18. #include "mousekey.h"
  19. #include "programmable_button.h"
  20. #include "command.h"
  21. #include "led.h"
  22. #include "action_layer.h"
  23. #include "action_tapping.h"
  24. #include "action_util.h"
  25. #include "action.h"
  26. #include "wait.h"
  27. #include "keycode_config.h"
  28. #include "debug.h"
  29. #include "quantum.h"
  30. #ifdef BACKLIGHT_ENABLE
  31. # include "backlight.h"
  32. #endif
  33. #ifdef POINTING_DEVICE_ENABLE
  34. # include "pointing_device.h"
  35. #endif
  36. #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) && defined(SWAP_HANDS_ENABLE)
  37. # include "encoder.h"
  38. #endif
  39. int tp_buttons;
  40. #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  41. int retro_tapping_counter = 0;
  42. #endif
  43. #if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
  44. # include "process_auto_shift.h"
  45. #endif
  46. #ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
  47. __attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
  48. return false;
  49. }
  50. #endif
  51. #ifdef RETRO_TAPPING_PER_KEY
  52. __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
  53. return false;
  54. }
  55. #endif
  56. /** \brief Called to execute an action.
  57. *
  58. * FIXME: Needs documentation.
  59. */
  60. void action_exec(keyevent_t event) {
  61. if (IS_EVENT(event)) {
  62. ac_dprintf("\n---- action_exec: start -----\n");
  63. ac_dprintf("EVENT: ");
  64. debug_event(event);
  65. ac_dprintf("\n");
  66. #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  67. retro_tapping_counter++;
  68. #endif
  69. }
  70. if (event.pressed) {
  71. // clear the potential weak mods left by previously pressed keys
  72. clear_weak_mods();
  73. }
  74. #ifdef SWAP_HANDS_ENABLE
  75. // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined.
  76. if (IS_EVENT(event)) {
  77. process_hand_swap(&event);
  78. }
  79. #endif
  80. keyrecord_t record = {.event = event};
  81. #ifndef NO_ACTION_ONESHOT
  82. if (keymap_config.oneshot_enable) {
  83. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  84. if (has_oneshot_layer_timed_out()) {
  85. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  86. }
  87. if (has_oneshot_mods_timed_out()) {
  88. clear_oneshot_mods();
  89. }
  90. # ifdef SWAP_HANDS_ENABLE
  91. if (has_oneshot_swaphands_timed_out()) {
  92. clear_oneshot_swaphands();
  93. }
  94. # endif
  95. # endif
  96. }
  97. #endif
  98. #ifndef NO_ACTION_TAPPING
  99. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
  100. if (event.pressed) {
  101. retroshift_poll_time(&event);
  102. }
  103. # endif
  104. if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
  105. action_tapping_process(record);
  106. }
  107. #else
  108. if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
  109. process_record(&record);
  110. }
  111. if (IS_EVENT(record.event)) {
  112. ac_dprintf("processed: ");
  113. debug_record(record);
  114. dprintln();
  115. }
  116. #endif
  117. }
  118. #ifdef SWAP_HANDS_ENABLE
  119. extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
  120. # ifdef ENCODER_MAP_ENABLE
  121. extern const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS];
  122. # endif // ENCODER_MAP_ENABLE
  123. bool swap_hands = false;
  124. bool swap_held = false;
  125. bool should_swap_hands(size_t index, uint8_t *swap_state, bool pressed) {
  126. size_t array_index = index / (CHAR_BIT);
  127. size_t bit_index = index % (CHAR_BIT);
  128. uint8_t bit_val = 1 << bit_index;
  129. bool do_swap = pressed ? swap_hands : swap_state[array_index] & bit_val;
  130. return do_swap;
  131. }
  132. void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) {
  133. size_t array_index = index / (CHAR_BIT);
  134. size_t bit_index = index % (CHAR_BIT);
  135. uint8_t bit_val = 1 << bit_index;
  136. if (on) {
  137. swap_state[array_index] |= bit_val;
  138. } else {
  139. swap_state[array_index] &= ~bit_val;
  140. }
  141. }
  142. void swap_hands_on(void) {
  143. swap_hands = true;
  144. }
  145. void swap_hands_off(void) {
  146. swap_hands = false;
  147. }
  148. void swap_hands_toggle(void) {
  149. swap_hands = !swap_hands;
  150. }
  151. bool is_swap_hands_on(void) {
  152. return swap_hands;
  153. }
  154. /** \brief Process Hand Swap
  155. *
  156. * FIXME: Needs documentation.
  157. */
  158. void process_hand_swap(keyevent_t *event) {
  159. keypos_t pos = event->key;
  160. if (IS_KEYEVENT(*event) && pos.row < MATRIX_ROWS && pos.col < MATRIX_COLS) {
  161. static uint8_t matrix_swap_state[((MATRIX_ROWS * MATRIX_COLS) + (CHAR_BIT)-1) / (CHAR_BIT)];
  162. size_t index = (size_t)(pos.row * MATRIX_COLS) + pos.col;
  163. bool do_swap = should_swap_hands(index, matrix_swap_state, event->pressed);
  164. if (do_swap) {
  165. event->key.row = pgm_read_byte(&hand_swap_config[pos.row][pos.col].row);
  166. event->key.col = pgm_read_byte(&hand_swap_config[pos.row][pos.col].col);
  167. set_swap_hands_state(index, matrix_swap_state, true);
  168. } else {
  169. set_swap_hands_state(index, matrix_swap_state, false);
  170. }
  171. }
  172. # ifdef ENCODER_MAP_ENABLE
  173. else if (IS_ENCODEREVENT(*event) && (pos.row == KEYLOC_ENCODER_CW || pos.row == KEYLOC_ENCODER_CCW)) {
  174. static uint8_t encoder_swap_state[((NUM_ENCODERS) + (CHAR_BIT)-1) / (CHAR_BIT)];
  175. size_t index = pos.col;
  176. bool do_swap = should_swap_hands(index, encoder_swap_state, event->pressed);
  177. if (do_swap) {
  178. event->key.row = pos.row;
  179. event->key.col = pgm_read_byte(&encoder_hand_swap_config[pos.col]);
  180. set_swap_hands_state(index, encoder_swap_state, true);
  181. } else {
  182. set_swap_hands_state(index, encoder_swap_state, false);
  183. }
  184. }
  185. # endif // ENCODER_MAP_ENABLE
  186. }
  187. #endif
  188. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  189. bool disable_action_cache = false;
  190. void process_record_nocache(keyrecord_t *record) {
  191. disable_action_cache = true;
  192. process_record(record);
  193. disable_action_cache = false;
  194. }
  195. #else
  196. void process_record_nocache(keyrecord_t *record) {
  197. process_record(record);
  198. }
  199. #endif
  200. __attribute__((weak)) bool process_record_quantum(keyrecord_t *record) {
  201. return true;
  202. }
  203. __attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {}
  204. #ifndef NO_ACTION_TAPPING
  205. /** \brief Allows for handling tap-hold actions immediately instead of waiting for TAPPING_TERM or another keypress.
  206. *
  207. * FIXME: Needs documentation.
  208. */
  209. void process_record_tap_hint(keyrecord_t *record) {
  210. if (!IS_KEYEVENT(record->event)) {
  211. return;
  212. }
  213. action_t action = layer_switch_get_action(record->event.key);
  214. switch (action.kind.id) {
  215. # ifdef SWAP_HANDS_ENABLE
  216. case ACT_SWAP_HANDS:
  217. switch (action.swap.code) {
  218. case OP_SH_ONESHOT:
  219. break;
  220. case OP_SH_TAP_TOGGLE:
  221. default:
  222. swap_hands = !swap_hands;
  223. swap_held = true;
  224. }
  225. break;
  226. # endif
  227. }
  228. }
  229. #endif
  230. /** \brief Take a key event (key press or key release) and processes it.
  231. *
  232. * FIXME: Needs documentation.
  233. */
  234. void process_record(keyrecord_t *record) {
  235. if (IS_NOEVENT(record->event)) {
  236. return;
  237. }
  238. if (!process_record_quantum(record)) {
  239. #ifndef NO_ACTION_ONESHOT
  240. if (is_oneshot_layer_active() && record->event.pressed && keymap_config.oneshot_enable) {
  241. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  242. }
  243. #endif
  244. return;
  245. }
  246. process_record_handler(record);
  247. post_process_record_quantum(record);
  248. }
  249. void process_record_handler(keyrecord_t *record) {
  250. #if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
  251. action_t action;
  252. if (record->keycode) {
  253. action = action_for_keycode(record->keycode);
  254. } else {
  255. action = store_or_get_action(record->event.pressed, record->event.key);
  256. }
  257. #else
  258. action_t action = store_or_get_action(record->event.pressed, record->event.key);
  259. #endif
  260. ac_dprintf("ACTION: ");
  261. debug_action(action);
  262. #ifndef NO_ACTION_LAYER
  263. ac_dprintf(" layer_state: ");
  264. layer_debug();
  265. ac_dprintf(" default_layer_state: ");
  266. default_layer_debug();
  267. #endif
  268. ac_dprintf("\n");
  269. process_action(record, action);
  270. }
  271. /**
  272. * @brief handles all the messy mouse stuff
  273. *
  274. * Handles all the edgecases and special stuff that is needed for coexistense
  275. * of the multiple mouse subsystems.
  276. *
  277. * @param mouse_keycode[in] uint8_t mouse keycode
  278. * @param pressed[in] bool
  279. */
  280. void register_mouse(uint8_t mouse_keycode, bool pressed) {
  281. #ifdef MOUSEKEY_ENABLE
  282. // if mousekeys is enabled, let it do the brunt of the work
  283. if (pressed) {
  284. mousekey_on(mouse_keycode);
  285. } else {
  286. mousekey_off(mouse_keycode);
  287. }
  288. // should mousekeys send report, or does something else handle this?
  289. switch (mouse_keycode) {
  290. # if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
  291. case QK_MOUSE_BUTTON_1 ... QK_MOUSE_BUTTON_8:
  292. // let pointing device handle the buttons
  293. // expand if/when it handles more of the code
  294. # if defined(POINTING_DEVICE_ENABLE)
  295. pointing_device_keycode_handler(mouse_keycode, pressed);
  296. # endif
  297. break;
  298. # endif
  299. default:
  300. mousekey_send();
  301. break;
  302. }
  303. #elif defined(POINTING_DEVICE_ENABLE)
  304. // if mousekeys isn't enabled, and pointing device is enabled, then
  305. // let pointing device do all the heavy lifting, then
  306. if (IS_MOUSE_KEYCODE(mouse_keycode)) {
  307. pointing_device_keycode_handler(mouse_keycode, pressed);
  308. }
  309. #endif
  310. #ifdef PS2_MOUSE_ENABLE
  311. // make sure that ps2 mouse has button report synced
  312. if (QK_MOUSE_BUTTON_1 <= mouse_keycode && mouse_keycode <= QK_MOUSE_BUTTON_3) {
  313. uint8_t tmp_button_msk = MOUSE_BTN_MASK(mouse_keycode - QK_MOUSE_BUTTON_1);
  314. tp_buttons = pressed ? tp_buttons | tmp_button_msk : tp_buttons & ~tmp_button_msk;
  315. }
  316. #endif
  317. }
  318. /** \brief Take an action and processes it.
  319. *
  320. * FIXME: Needs documentation.
  321. */
  322. void process_action(keyrecord_t *record, action_t action) {
  323. keyevent_t event = record->event;
  324. #ifndef NO_ACTION_TAPPING
  325. uint8_t tap_count = record->tap.count;
  326. #endif
  327. #ifndef NO_ACTION_ONESHOT
  328. bool do_release_oneshot = false;
  329. // notice we only clear the one shot layer if the pressed key is not a modifier.
  330. if (is_oneshot_layer_active() && event.pressed &&
  331. (action.kind.id == ACT_USAGE || !(IS_MODIFIER_KEYCODE(action.key.code)
  332. # ifndef NO_ACTION_TAPPING
  333. || ((action.kind.id == ACT_LMODS_TAP || action.kind.id == ACT_RMODS_TAP) && (action.layer_tap.code <= MODS_TAP_TOGGLE || tap_count == 0))
  334. # endif
  335. ))
  336. # ifdef SWAP_HANDS_ENABLE
  337. && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)
  338. # endif
  339. && keymap_config.oneshot_enable) {
  340. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  341. do_release_oneshot = !is_oneshot_layer_active();
  342. }
  343. #endif
  344. switch (action.kind.id) {
  345. /* Key and Mods */
  346. case ACT_LMODS:
  347. case ACT_RMODS: {
  348. uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods : action.key.mods << 4;
  349. if (event.pressed) {
  350. if (mods) {
  351. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  352. // e.g. LSFT(KC_LEFT_GUI): we don't want the LSFT to be weak as it would make it useless.
  353. // This also makes LSFT(KC_LEFT_GUI) behave exactly the same as LGUI(KC_LEFT_SHIFT).
  354. // Same applies for some keys like KC_MEH which are declared as MEH(KC_NO).
  355. add_mods(mods);
  356. } else {
  357. add_weak_mods(mods);
  358. }
  359. send_keyboard_report();
  360. }
  361. register_code(action.key.code);
  362. } else {
  363. unregister_code(action.key.code);
  364. if (mods) {
  365. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  366. del_mods(mods);
  367. } else {
  368. del_weak_mods(mods);
  369. }
  370. send_keyboard_report();
  371. }
  372. }
  373. } break;
  374. case ACT_LMODS_TAP:
  375. case ACT_RMODS_TAP: {
  376. #ifndef NO_ACTION_TAPPING
  377. uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4;
  378. switch (action.layer_tap.code) {
  379. # ifndef NO_ACTION_ONESHOT
  380. case MODS_ONESHOT:
  381. // Oneshot modifier
  382. if (!keymap_config.oneshot_enable) {
  383. if (event.pressed) {
  384. if (mods) {
  385. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  386. // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
  387. // This also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT).
  388. // Same applies for some keys like KC_MEH which are declared as MEH(KC_NO).
  389. add_mods(mods);
  390. } else {
  391. add_weak_mods(mods);
  392. }
  393. send_keyboard_report();
  394. }
  395. register_code(action.key.code);
  396. } else {
  397. unregister_code(action.key.code);
  398. if (mods) {
  399. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  400. del_mods(mods);
  401. } else {
  402. del_weak_mods(mods);
  403. }
  404. send_keyboard_report();
  405. }
  406. }
  407. } else {
  408. if (event.pressed) {
  409. if (tap_count == 0) {
  410. // Not a tap, but a hold: register the held mod
  411. ac_dprintf("MODS_TAP: Oneshot: 0\n");
  412. register_mods(mods);
  413. } else if (tap_count == 1) {
  414. ac_dprintf("MODS_TAP: Oneshot: start\n");
  415. add_oneshot_mods(mods);
  416. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  417. } else if (tap_count == ONESHOT_TAP_TOGGLE) {
  418. ac_dprintf("MODS_TAP: Toggling oneshot");
  419. register_mods(mods);
  420. del_oneshot_mods(mods);
  421. add_oneshot_locked_mods(mods);
  422. # endif
  423. }
  424. } else {
  425. if (tap_count == 0) {
  426. // Release hold: unregister the held mod and its variants
  427. unregister_mods(mods);
  428. del_oneshot_mods(mods);
  429. del_oneshot_locked_mods(mods);
  430. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  431. } else if (tap_count == 1 && (mods & get_mods())) {
  432. unregister_mods(mods);
  433. del_oneshot_mods(mods);
  434. del_oneshot_locked_mods(mods);
  435. # endif
  436. }
  437. }
  438. }
  439. break;
  440. # endif
  441. case MODS_TAP_TOGGLE:
  442. if (event.pressed) {
  443. if (tap_count <= TAPPING_TOGGLE) {
  444. register_mods(mods);
  445. }
  446. } else {
  447. if (tap_count < TAPPING_TOGGLE) {
  448. unregister_mods(mods);
  449. }
  450. }
  451. break;
  452. default:
  453. if (event.pressed) {
  454. if (tap_count > 0) {
  455. # ifdef HOLD_ON_OTHER_KEY_PRESS
  456. if (
  457. # ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
  458. get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
  459. # endif
  460. record->tap.interrupted) {
  461. ac_dprintf("mods_tap: tap: cancel: add_mods\n");
  462. // ad hoc: set 0 to cancel tap
  463. record->tap.count = 0;
  464. register_mods(mods);
  465. } else
  466. # endif
  467. {
  468. ac_dprintf("MODS_TAP: Tap: register_code\n");
  469. register_code(action.key.code);
  470. }
  471. } else {
  472. ac_dprintf("MODS_TAP: No tap: add_mods\n");
  473. register_mods(mods);
  474. }
  475. } else {
  476. if (tap_count > 0) {
  477. ac_dprintf("MODS_TAP: Tap: unregister_code\n");
  478. if (action.layer_tap.code == KC_CAPS_LOCK) {
  479. wait_ms(TAP_HOLD_CAPS_DELAY);
  480. } else {
  481. wait_ms(TAP_CODE_DELAY);
  482. }
  483. unregister_code(action.key.code);
  484. } else {
  485. ac_dprintf("MODS_TAP: No tap: add_mods\n");
  486. # if defined(RETRO_TAPPING) && defined(DUMMY_MOD_NEUTRALIZER_KEYCODE)
  487. // Send a dummy keycode to neutralize flashing modifiers
  488. // if the key was held and then released with no interruptions.
  489. if (retro_tapping_counter == 2) {
  490. neutralize_flashing_modifiers(get_mods());
  491. }
  492. # endif
  493. unregister_mods(mods);
  494. }
  495. }
  496. break;
  497. }
  498. #endif // NO_ACTION_TAPPING
  499. } break;
  500. #ifdef EXTRAKEY_ENABLE
  501. /* other HID usage */
  502. case ACT_USAGE:
  503. switch (action.usage.page) {
  504. case PAGE_SYSTEM:
  505. host_system_send(event.pressed ? action.usage.code : 0);
  506. break;
  507. case PAGE_CONSUMER:
  508. host_consumer_send(event.pressed ? action.usage.code : 0);
  509. break;
  510. }
  511. break;
  512. #endif // EXTRAKEY_ENABLE
  513. /* Mouse key */
  514. case ACT_MOUSEKEY:
  515. register_mouse(action.key.code, event.pressed);
  516. break;
  517. #ifndef NO_ACTION_LAYER
  518. case ACT_LAYER:
  519. if (action.layer_bitop.on == 0) {
  520. /* Default Layer Bitwise Operation */
  521. if (!event.pressed) {
  522. uint8_t shift = action.layer_bitop.part * 4;
  523. layer_state_t bits = ((layer_state_t)action.layer_bitop.bits) << shift;
  524. layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf) << shift) : 0;
  525. switch (action.layer_bitop.op) {
  526. case OP_BIT_AND:
  527. default_layer_and(bits | mask);
  528. break;
  529. case OP_BIT_OR:
  530. default_layer_or(bits | mask);
  531. break;
  532. case OP_BIT_XOR:
  533. default_layer_xor(bits | mask);
  534. break;
  535. case OP_BIT_SET:
  536. default_layer_set(bits | mask);
  537. break;
  538. }
  539. }
  540. } else {
  541. /* Layer Bitwise Operation */
  542. if (event.pressed ? (action.layer_bitop.on & ON_PRESS) : (action.layer_bitop.on & ON_RELEASE)) {
  543. uint8_t shift = action.layer_bitop.part * 4;
  544. layer_state_t bits = ((layer_state_t)action.layer_bitop.bits) << shift;
  545. layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf) << shift) : 0;
  546. switch (action.layer_bitop.op) {
  547. case OP_BIT_AND:
  548. layer_and(bits | mask);
  549. break;
  550. case OP_BIT_OR:
  551. layer_or(bits | mask);
  552. break;
  553. case OP_BIT_XOR:
  554. layer_xor(bits | mask);
  555. break;
  556. case OP_BIT_SET:
  557. layer_state_set(bits | mask);
  558. break;
  559. }
  560. }
  561. }
  562. break;
  563. case ACT_LAYER_MODS:
  564. if (event.pressed) {
  565. layer_on(action.layer_mods.layer);
  566. register_mods(action.layer_mods.mods);
  567. } else {
  568. unregister_mods(action.layer_mods.mods);
  569. layer_off(action.layer_mods.layer);
  570. }
  571. break;
  572. case ACT_LAYER_TAP:
  573. case ACT_LAYER_TAP_EXT:
  574. switch (action.layer_tap.code) {
  575. # ifndef NO_ACTION_TAPPING
  576. case OP_TAP_TOGGLE:
  577. /* tap toggle */
  578. if (event.pressed) {
  579. if (tap_count < TAPPING_TOGGLE) {
  580. layer_invert(action.layer_tap.val);
  581. }
  582. } else {
  583. if (tap_count <= TAPPING_TOGGLE) {
  584. layer_invert(action.layer_tap.val);
  585. }
  586. }
  587. break;
  588. # endif
  589. case OP_ON_OFF:
  590. event.pressed ? layer_on(action.layer_tap.val) : layer_off(action.layer_tap.val);
  591. break;
  592. case OP_OFF_ON:
  593. event.pressed ? layer_off(action.layer_tap.val) : layer_on(action.layer_tap.val);
  594. break;
  595. case OP_SET_CLEAR:
  596. event.pressed ? layer_move(action.layer_tap.val) : layer_clear();
  597. break;
  598. # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
  599. case OP_ONESHOT:
  600. // Oneshot modifier
  601. if (!keymap_config.oneshot_enable) {
  602. if (event.pressed) {
  603. layer_on(action.layer_tap.val);
  604. } else {
  605. layer_off(action.layer_tap.val);
  606. }
  607. } else {
  608. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  609. do_release_oneshot = false;
  610. if (event.pressed) {
  611. if (get_oneshot_layer_state() == ONESHOT_TOGGLED) {
  612. reset_oneshot_layer();
  613. layer_off(action.layer_tap.val);
  614. break;
  615. } else if (tap_count < ONESHOT_TAP_TOGGLE) {
  616. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  617. }
  618. } else {
  619. if (tap_count >= ONESHOT_TAP_TOGGLE) {
  620. reset_oneshot_layer();
  621. set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED);
  622. } else {
  623. clear_oneshot_layer_state(ONESHOT_PRESSED);
  624. }
  625. }
  626. # else
  627. if (event.pressed) {
  628. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  629. } else {
  630. clear_oneshot_layer_state(ONESHOT_PRESSED);
  631. if (tap_count > 1) {
  632. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  633. }
  634. }
  635. # endif
  636. }
  637. # else // NO_ACTION_ONESHOT && NO_ACTION_TAPPING
  638. if (event.pressed) {
  639. layer_on(action.layer_tap.val);
  640. } else {
  641. layer_off(action.layer_tap.val);
  642. }
  643. # endif // !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
  644. break;
  645. default:
  646. # ifndef NO_ACTION_TAPPING /* tap key */
  647. if (event.pressed) {
  648. if (tap_count > 0) {
  649. ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n");
  650. register_code(action.layer_tap.code);
  651. } else {
  652. ac_dprintf("KEYMAP_TAP_KEY: No tap: On on press\n");
  653. layer_on(action.layer_tap.val);
  654. }
  655. } else {
  656. if (tap_count > 0) {
  657. ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  658. if (action.layer_tap.code == KC_CAPS_LOCK) {
  659. wait_ms(TAP_HOLD_CAPS_DELAY);
  660. } else {
  661. wait_ms(TAP_CODE_DELAY);
  662. }
  663. unregister_code(action.layer_tap.code);
  664. } else {
  665. ac_dprintf("KEYMAP_TAP_KEY: No tap: Off on release\n");
  666. layer_off(action.layer_tap.val);
  667. }
  668. }
  669. # else
  670. if (event.pressed) {
  671. ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n");
  672. register_code(action.layer_tap.code);
  673. } else {
  674. ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  675. if (action.layer_tap.code == KC_CAPS) {
  676. wait_ms(TAP_HOLD_CAPS_DELAY);
  677. } else {
  678. wait_ms(TAP_CODE_DELAY);
  679. }
  680. unregister_code(action.layer_tap.code);
  681. }
  682. # endif
  683. break;
  684. }
  685. break;
  686. #endif // NO_ACTION_LAYER
  687. #ifdef SWAP_HANDS_ENABLE
  688. case ACT_SWAP_HANDS:
  689. switch (action.swap.code) {
  690. case OP_SH_TOGGLE:
  691. if (event.pressed) {
  692. swap_hands = !swap_hands;
  693. }
  694. break;
  695. case OP_SH_ON_OFF:
  696. swap_hands = event.pressed;
  697. break;
  698. case OP_SH_OFF_ON:
  699. swap_hands = !event.pressed;
  700. break;
  701. case OP_SH_ON:
  702. if (!event.pressed) {
  703. swap_hands = true;
  704. }
  705. break;
  706. case OP_SH_OFF:
  707. if (!event.pressed) {
  708. swap_hands = false;
  709. }
  710. break;
  711. # ifndef NO_ACTION_ONESHOT
  712. case OP_SH_ONESHOT:
  713. if (event.pressed) {
  714. set_oneshot_swaphands();
  715. } else {
  716. release_oneshot_swaphands();
  717. }
  718. break;
  719. # endif
  720. # ifndef NO_ACTION_TAPPING
  721. case OP_SH_TAP_TOGGLE:
  722. /* tap toggle */
  723. if (event.pressed) {
  724. if (swap_held) {
  725. swap_held = false;
  726. } else {
  727. swap_hands = !swap_hands;
  728. }
  729. } else {
  730. if (tap_count < TAPPING_TOGGLE) {
  731. swap_hands = !swap_hands;
  732. }
  733. }
  734. break;
  735. default:
  736. /* tap key */
  737. if (tap_count > 0) {
  738. if (swap_held) {
  739. swap_hands = !swap_hands; // undo hold set up in _tap_hint
  740. swap_held = false;
  741. }
  742. if (event.pressed) {
  743. register_code(action.swap.code);
  744. } else {
  745. wait_ms(TAP_CODE_DELAY);
  746. unregister_code(action.swap.code);
  747. *record = (keyrecord_t){}; // hack: reset tap mode
  748. }
  749. } else {
  750. if (swap_held && !event.pressed) {
  751. swap_hands = !swap_hands; // undo hold set up in _tap_hint
  752. swap_held = false;
  753. }
  754. }
  755. # endif
  756. }
  757. #endif
  758. default:
  759. break;
  760. }
  761. #ifndef NO_ACTION_LAYER
  762. // if this event is a layer action, update the leds
  763. switch (action.kind.id) {
  764. case ACT_LAYER:
  765. case ACT_LAYER_MODS:
  766. # ifndef NO_ACTION_TAPPING
  767. case ACT_LAYER_TAP:
  768. case ACT_LAYER_TAP_EXT:
  769. # endif
  770. led_set(host_keyboard_leds());
  771. break;
  772. default:
  773. break;
  774. }
  775. #endif
  776. #ifndef NO_ACTION_TAPPING
  777. # if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  778. if (!is_tap_action(action)) {
  779. retro_tapping_counter = 0;
  780. } else {
  781. if (event.pressed) {
  782. if (tap_count > 0) {
  783. retro_tapping_counter = 0;
  784. }
  785. } else {
  786. if (tap_count > 0) {
  787. retro_tapping_counter = 0;
  788. } else {
  789. if (
  790. # ifdef RETRO_TAPPING_PER_KEY
  791. get_retro_tapping(get_event_keycode(record->event, false), record) &&
  792. # endif
  793. retro_tapping_counter == 2) {
  794. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
  795. process_auto_shift(action.layer_tap.code, record);
  796. # else
  797. tap_code(action.layer_tap.code);
  798. # endif
  799. }
  800. retro_tapping_counter = 0;
  801. }
  802. }
  803. }
  804. # endif
  805. #endif
  806. #ifdef SWAP_HANDS_ENABLE
  807. # ifndef NO_ACTION_ONESHOT
  808. if (event.pressed && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)) {
  809. use_oneshot_swaphands();
  810. }
  811. # endif
  812. #endif
  813. #ifndef NO_ACTION_ONESHOT
  814. /* Because we switch layers after a oneshot event, we need to release the
  815. * key before we leave the layer or no key up event will be generated.
  816. */
  817. if (do_release_oneshot && !(get_oneshot_layer_state() & ONESHOT_PRESSED)) {
  818. record->event.pressed = false;
  819. layer_on(get_oneshot_layer());
  820. process_record(record);
  821. layer_off(get_oneshot_layer());
  822. }
  823. #endif
  824. }
  825. /** \brief Utilities for actions. (FIXME: Needs better description)
  826. *
  827. * FIXME: Needs documentation.
  828. */
  829. __attribute__((weak)) void register_code(uint8_t code) {
  830. if (code == KC_NO) {
  831. return;
  832. #ifdef LOCKING_SUPPORT_ENABLE
  833. } else if (KC_LOCKING_CAPS_LOCK == code) {
  834. # ifdef LOCKING_RESYNC_ENABLE
  835. // Resync: ignore if caps lock already is on
  836. if (host_keyboard_led_state().caps_lock) return;
  837. # endif
  838. add_key(KC_CAPS_LOCK);
  839. send_keyboard_report();
  840. wait_ms(TAP_HOLD_CAPS_DELAY);
  841. del_key(KC_CAPS_LOCK);
  842. send_keyboard_report();
  843. } else if (KC_LOCKING_NUM_LOCK == code) {
  844. # ifdef LOCKING_RESYNC_ENABLE
  845. if (host_keyboard_led_state().num_lock) return;
  846. # endif
  847. add_key(KC_NUM_LOCK);
  848. send_keyboard_report();
  849. wait_ms(100);
  850. del_key(KC_NUM_LOCK);
  851. send_keyboard_report();
  852. } else if (KC_LOCKING_SCROLL_LOCK == code) {
  853. # ifdef LOCKING_RESYNC_ENABLE
  854. if (host_keyboard_led_state().scroll_lock) return;
  855. # endif
  856. add_key(KC_SCROLL_LOCK);
  857. send_keyboard_report();
  858. wait_ms(100);
  859. del_key(KC_SCROLL_LOCK);
  860. send_keyboard_report();
  861. #endif
  862. } else if (IS_BASIC_KEYCODE(code)) {
  863. // TODO: should push command_proc out of this block?
  864. if (command_proc(code)) return;
  865. // Force a new key press if the key is already pressed
  866. // without this, keys with the same keycode, but different
  867. // modifiers will be reported incorrectly, see issue #1708
  868. if (is_key_pressed(code)) {
  869. del_key(code);
  870. send_keyboard_report();
  871. }
  872. add_key(code);
  873. send_keyboard_report();
  874. } else if (IS_MODIFIER_KEYCODE(code)) {
  875. add_mods(MOD_BIT(code));
  876. send_keyboard_report();
  877. #ifdef EXTRAKEY_ENABLE
  878. } else if (IS_SYSTEM_KEYCODE(code)) {
  879. host_system_send(KEYCODE2SYSTEM(code));
  880. } else if (IS_CONSUMER_KEYCODE(code)) {
  881. host_consumer_send(KEYCODE2CONSUMER(code));
  882. #endif
  883. } else if (IS_MOUSE_KEYCODE(code)) {
  884. register_mouse(code, true);
  885. }
  886. }
  887. /** \brief Utilities for actions. (FIXME: Needs better description)
  888. *
  889. * FIXME: Needs documentation.
  890. */
  891. __attribute__((weak)) void unregister_code(uint8_t code) {
  892. if (code == KC_NO) {
  893. return;
  894. #ifdef LOCKING_SUPPORT_ENABLE
  895. } else if (KC_LOCKING_CAPS_LOCK == code) {
  896. # ifdef LOCKING_RESYNC_ENABLE
  897. // Resync: ignore if caps lock already is off
  898. if (!host_keyboard_led_state().caps_lock) return;
  899. # endif
  900. add_key(KC_CAPS_LOCK);
  901. send_keyboard_report();
  902. del_key(KC_CAPS_LOCK);
  903. send_keyboard_report();
  904. } else if (KC_LOCKING_NUM_LOCK == code) {
  905. # ifdef LOCKING_RESYNC_ENABLE
  906. if (!host_keyboard_led_state().num_lock) return;
  907. # endif
  908. add_key(KC_NUM_LOCK);
  909. send_keyboard_report();
  910. del_key(KC_NUM_LOCK);
  911. send_keyboard_report();
  912. } else if (KC_LOCKING_SCROLL_LOCK == code) {
  913. # ifdef LOCKING_RESYNC_ENABLE
  914. if (!host_keyboard_led_state().scroll_lock) return;
  915. # endif
  916. add_key(KC_SCROLL_LOCK);
  917. send_keyboard_report();
  918. del_key(KC_SCROLL_LOCK);
  919. send_keyboard_report();
  920. #endif
  921. } else if (IS_BASIC_KEYCODE(code)) {
  922. del_key(code);
  923. send_keyboard_report();
  924. } else if (IS_MODIFIER_KEYCODE(code)) {
  925. del_mods(MOD_BIT(code));
  926. send_keyboard_report();
  927. #ifdef EXTRAKEY_ENABLE
  928. } else if (IS_SYSTEM_KEYCODE(code)) {
  929. host_system_send(0);
  930. } else if (IS_CONSUMER_KEYCODE(code)) {
  931. host_consumer_send(0);
  932. #endif
  933. } else if (IS_MOUSE_KEYCODE(code)) {
  934. register_mouse(code, false);
  935. }
  936. }
  937. /** \brief Tap a keycode with a delay.
  938. *
  939. * \param code The basic keycode to tap.
  940. * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
  941. */
  942. __attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
  943. register_code(code);
  944. wait_ms(delay);
  945. unregister_code(code);
  946. }
  947. /** \brief Tap a keycode with the default delay.
  948. *
  949. * \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
  950. */
  951. __attribute__((weak)) void tap_code(uint8_t code) {
  952. tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
  953. }
  954. /** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
  955. *
  956. * \param mods A bitfield of modifiers to register.
  957. */
  958. __attribute__((weak)) void register_mods(uint8_t mods) {
  959. if (mods) {
  960. add_mods(mods);
  961. send_keyboard_report();
  962. }
  963. }
  964. /** \brief Removes the given physically pressed modifiers and sends a keyboard report immediately.
  965. *
  966. * \param mods A bitfield of modifiers to unregister.
  967. */
  968. __attribute__((weak)) void unregister_mods(uint8_t mods) {
  969. if (mods) {
  970. del_mods(mods);
  971. send_keyboard_report();
  972. }
  973. }
  974. /** \brief Adds the given weak modifiers and sends a keyboard report immediately.
  975. *
  976. * \param mods A bitfield of modifiers to register.
  977. */
  978. __attribute__((weak)) void register_weak_mods(uint8_t mods) {
  979. if (mods) {
  980. add_weak_mods(mods);
  981. send_keyboard_report();
  982. }
  983. }
  984. /** \brief Removes the given weak modifiers and sends a keyboard report immediately.
  985. *
  986. * \param mods A bitfield of modifiers to unregister.
  987. */
  988. __attribute__((weak)) void unregister_weak_mods(uint8_t mods) {
  989. if (mods) {
  990. del_weak_mods(mods);
  991. send_keyboard_report();
  992. }
  993. }
  994. /** \brief Utilities for actions. (FIXME: Needs better description)
  995. *
  996. * FIXME: Needs documentation.
  997. */
  998. void clear_keyboard(void) {
  999. clear_mods();
  1000. clear_keyboard_but_mods();
  1001. }
  1002. /** \brief Utilities for actions. (FIXME: Needs better description)
  1003. *
  1004. * FIXME: Needs documentation.
  1005. */
  1006. void clear_keyboard_but_mods(void) {
  1007. clear_keys();
  1008. clear_keyboard_but_mods_and_keys();
  1009. }
  1010. /** \brief Utilities for actions. (FIXME: Needs better description)
  1011. *
  1012. * FIXME: Needs documentation.
  1013. */
  1014. void clear_keyboard_but_mods_and_keys(void) {
  1015. #ifdef EXTRAKEY_ENABLE
  1016. host_system_send(0);
  1017. host_consumer_send(0);
  1018. #endif
  1019. clear_weak_mods();
  1020. send_keyboard_report();
  1021. #ifdef MOUSEKEY_ENABLE
  1022. mousekey_clear();
  1023. mousekey_send();
  1024. #endif
  1025. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  1026. programmable_button_clear();
  1027. #endif
  1028. }
  1029. /** \brief Utilities for actions. (FIXME: Needs better description)
  1030. *
  1031. * FIXME: Needs documentation.
  1032. */
  1033. bool is_tap_record(keyrecord_t *record) {
  1034. if (IS_NOEVENT(record->event)) {
  1035. return false;
  1036. }
  1037. #if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
  1038. action_t action;
  1039. if (record->keycode) {
  1040. action = action_for_keycode(record->keycode);
  1041. } else {
  1042. action = layer_switch_get_action(record->event.key);
  1043. }
  1044. #else
  1045. action_t action = layer_switch_get_action(record->event.key);
  1046. #endif
  1047. return is_tap_action(action);
  1048. }
  1049. /** \brief Utilities for actions. (FIXME: Needs better description)
  1050. *
  1051. * FIXME: Needs documentation.
  1052. */
  1053. bool is_tap_action(action_t action) {
  1054. switch (action.kind.id) {
  1055. case ACT_LMODS_TAP:
  1056. case ACT_RMODS_TAP:
  1057. case ACT_LAYER_TAP:
  1058. case ACT_LAYER_TAP_EXT:
  1059. switch (action.layer_tap.code) {
  1060. case KC_NO ... KC_RIGHT_GUI:
  1061. case OP_TAP_TOGGLE:
  1062. case OP_ONESHOT:
  1063. return true;
  1064. }
  1065. return false;
  1066. case ACT_SWAP_HANDS:
  1067. switch (action.swap.code) {
  1068. case KC_NO ... KC_RIGHT_GUI:
  1069. case OP_SH_TAP_TOGGLE:
  1070. return true;
  1071. }
  1072. return false;
  1073. }
  1074. return false;
  1075. }
  1076. /** \brief Debug print (FIXME: Needs better description)
  1077. *
  1078. * FIXME: Needs documentation.
  1079. */
  1080. void debug_event(keyevent_t event) {
  1081. ac_dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
  1082. }
  1083. /** \brief Debug print (FIXME: Needs better description)
  1084. *
  1085. * FIXME: Needs documentation.
  1086. */
  1087. void debug_record(keyrecord_t record) {
  1088. debug_event(record.event);
  1089. #ifndef NO_ACTION_TAPPING
  1090. ac_dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
  1091. #endif
  1092. }
  1093. /** \brief Debug print (FIXME: Needs better description)
  1094. *
  1095. * FIXME: Needs documentation.
  1096. */
  1097. void debug_action(action_t action) {
  1098. switch (action.kind.id) {
  1099. case ACT_LMODS:
  1100. ac_dprintf("ACT_LMODS");
  1101. break;
  1102. case ACT_RMODS:
  1103. ac_dprintf("ACT_RMODS");
  1104. break;
  1105. case ACT_LMODS_TAP:
  1106. ac_dprintf("ACT_LMODS_TAP");
  1107. break;
  1108. case ACT_RMODS_TAP:
  1109. ac_dprintf("ACT_RMODS_TAP");
  1110. break;
  1111. case ACT_USAGE:
  1112. ac_dprintf("ACT_USAGE");
  1113. break;
  1114. case ACT_MOUSEKEY:
  1115. ac_dprintf("ACT_MOUSEKEY");
  1116. break;
  1117. case ACT_LAYER:
  1118. ac_dprintf("ACT_LAYER");
  1119. break;
  1120. case ACT_LAYER_MODS:
  1121. ac_dprintf("ACT_LAYER_MODS");
  1122. break;
  1123. case ACT_LAYER_TAP:
  1124. ac_dprintf("ACT_LAYER_TAP");
  1125. break;
  1126. case ACT_LAYER_TAP_EXT:
  1127. ac_dprintf("ACT_LAYER_TAP_EXT");
  1128. break;
  1129. case ACT_SWAP_HANDS:
  1130. ac_dprintf("ACT_SWAP_HANDS");
  1131. break;
  1132. default:
  1133. ac_dprintf("UNKNOWN");
  1134. break;
  1135. }
  1136. ac_dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
  1137. }