You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

action.c 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. #include "host.h"
  2. #include "timer.h"
  3. #include "keymap.h"
  4. #include "keycode.h"
  5. #include "keyboard.h"
  6. #include "mousekey.h"
  7. #include "command.h"
  8. #include "util.h"
  9. #include "debug.h"
  10. #include "action.h"
  11. static void process(keyrecord_t *record);
  12. void test_func(keyevent_t event, uint8_t opt)
  13. {
  14. if (event.pressed) {
  15. debug("test_func:pressed: "); debug_hex(opt); debug("\n");
  16. } else {
  17. debug("test_func:released: "); debug_hex(opt); debug("\n");
  18. }
  19. }
  20. /* layer */
  21. uint8_t default_layer = 0;
  22. uint8_t current_layer = 0;
  23. /* tap term(ms) */
  24. #define TAP_TERM 200
  25. /* This counts up when tap occurs */
  26. uint8_t tap_count = 0;
  27. keyevent_t tapping_event = {};
  28. keyrecord_t tapping_key = {};
  29. /* TAPPING: This indicates that whether tap or not is not decided yet. */
  30. // NOTE: keyevent_t.time 0 means no event.
  31. #define IS_TAPPING() (tapping_key.event.time != 0)
  32. #define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed)
  33. #define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
  34. #define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
  35. #define WITHIN_TAP_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAP_TERM)
  36. /* waiting keys buffer */
  37. #define WAITING_BUFFER_SIZE 8
  38. static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
  39. /* point to empty cell to enq */
  40. static uint8_t waiting_buffer_head = 0;
  41. /* point to the oldest data cell to deq */
  42. static uint8_t waiting_buffer_tail = 0;
  43. static bool waiting_buffer_enq(keyrecord_t record)
  44. {
  45. if (IS_NOEVENT(record.event)) {
  46. return true;
  47. }
  48. if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) {
  49. debug("waiting_buffer_enq: Over flow.\n");
  50. return false;
  51. }
  52. debug("waiting_buffer_enq["); debug_dec(waiting_buffer_head); debug("] = ");
  53. debug_hex16(record.event.key.raw); debug("\n");
  54. waiting_buffer[waiting_buffer_head] = record;
  55. waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE;
  56. return true;
  57. }
  58. static keyrecord_t waiting_buffer_deq(void)
  59. {
  60. if (waiting_buffer_head == waiting_buffer_tail) {
  61. return (keyrecord_t){};
  62. }
  63. uint8_t last_tail = waiting_buffer_tail;
  64. waiting_buffer_tail = waiting_buffer_tail + 1 % WAITING_BUFFER_SIZE;
  65. return waiting_buffer[last_tail];
  66. }
  67. static bool waiting_buffer_is_empty(void)
  68. {
  69. return (waiting_buffer_head == waiting_buffer_tail);
  70. }
  71. static void waiting_buffer_clear(void)
  72. {
  73. waiting_buffer_head = 0;
  74. waiting_buffer_tail = 0;
  75. }
  76. static bool waiting_buffer_typed(keyevent_t event)
  77. {
  78. for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
  79. if (KEYEQ(event.key, waiting_buffer[i].event.key) && event.pressed != waiting_buffer[i].event.pressed) {
  80. return true;
  81. }
  82. }
  83. return false;
  84. }
  85. static bool waiting_buffer_has_anykey_pressed(void)
  86. {
  87. for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
  88. if (waiting_buffer[i].event.pressed) return true;
  89. }
  90. return false;
  91. }
  92. static void waiting_buffer_process(void)
  93. {
  94. }
  95. /*
  96. * Rule to judge tap:
  97. * Tap key is typed(pressed and released) within TAP_TERM
  98. * without interfaring by typing other key.
  99. */
  100. /* return true when key event is processed. */
  101. static bool process_tap(keyrecord_t *keyp)
  102. {
  103. keyevent_t event = keyp->event;
  104. // if tapping
  105. if (IS_TAPPING_PRESSED()) {
  106. if (WITHIN_TAP_TERM(event)) {
  107. if (tapping_key.tap_count == 0) {
  108. if (IS_TAPPING_KEY(event.key) && !event.pressed) {
  109. // first tap!
  110. debug("Tapping: First tap.\n");
  111. tapping_key.tap_count = 1;
  112. process(&tapping_key);
  113. // enqueue
  114. keyp->tap_count = tapping_key.tap_count;
  115. return false;
  116. } else if (!event.pressed && waiting_buffer_typed(event)) {
  117. // other key typed. not tap.
  118. debug("Tapping: End(No tap. Interfered by typing key).\n");
  119. process(&tapping_key);
  120. tapping_key = (keyrecord_t){};
  121. // enqueue
  122. return false;
  123. } else {
  124. // other key events shall be stored till tapping state settles.
  125. return false;
  126. }
  127. } else {
  128. if (IS_TAPPING_KEY(event.key) && !event.pressed) {
  129. keyp->tap_count = tapping_key.tap_count;
  130. debug("Tapping: tap release("); debug_dec(keyp->tap_count); debug(")\n");
  131. tapping_key = *keyp;
  132. return false;
  133. }
  134. else if (is_tap_key(keyp->event.key) && event.pressed) {
  135. debug("Tapping: Start with forcing to release last tap.\n");
  136. process(&(keyrecord_t){
  137. .tap_count = tapping_key.tap_count,
  138. .event.key = tapping_key.event.key,
  139. .event.time = event.time,
  140. .event.pressed = false
  141. });
  142. tapping_key = *keyp;
  143. return false;
  144. }
  145. else {
  146. if (!IS_NOEVENT(keyp->event)) debug("Tapping: key event while tap.\n");
  147. process(keyp);
  148. return true;
  149. }
  150. }
  151. }
  152. // not within TAP_TERM
  153. else {
  154. if (tapping_key.tap_count == 0) {
  155. // timeout. not tap.
  156. debug("Tapping: End. Not tap(time out).\n");
  157. process(&tapping_key);
  158. tapping_key = (keyrecord_t){};
  159. return false;
  160. } else {
  161. if (IS_TAPPING_KEY(event.key) && !event.pressed) {
  162. debug("Tapping: End. tap release.");
  163. keyp->tap_count = tapping_key.tap_count;
  164. process(keyp);
  165. tapping_key = (keyrecord_t){};
  166. return true;
  167. } else {
  168. // other key after tap time out.
  169. process(keyp);
  170. return true;
  171. }
  172. }
  173. }
  174. } else if (IS_TAPPING_RELEASED()) {
  175. if (WITHIN_TAP_TERM(event)) {
  176. if (tapping_key.tap_count > 0 && IS_TAPPING_KEY(event.key) && event.pressed) {
  177. // sequential tap.
  178. keyp->tap_count = tapping_key.tap_count + 1;
  179. debug("Tapping: tap press("); debug_dec(keyp->tap_count); debug(")\n");
  180. process(keyp);
  181. tapping_key = *keyp;
  182. return true;
  183. } else if (event.pressed && is_tap_key(event.key)) {
  184. // Sequential tap can be interfered with other tap key.
  185. debug("Tapping: Start with interfering other tap.\n");
  186. tapping_key = *keyp;
  187. return true;
  188. } else {
  189. if (!IS_NOEVENT(keyp->event)) debug("Tapping: other key just after tap.\n");
  190. process(keyp);
  191. return true;
  192. }
  193. } else {
  194. // timeout. no sequential tap.
  195. debug("Tapping: End(Time out after releasing last tap).\n");
  196. tapping_key = (keyrecord_t){};
  197. process(keyp);
  198. return true;
  199. }
  200. } else {
  201. if (event.pressed && is_tap_key(event.key)) {
  202. debug("Tapping: Start(Press tap key).\n");
  203. tapping_key = *keyp;
  204. return true;
  205. } else {
  206. process(keyp);
  207. return true;
  208. }
  209. }
  210. }
  211. void action_exec(keyevent_t event)
  212. {
  213. if (!IS_NOEVENT(event)) {
  214. debug("event: ");
  215. debug_hex16(event.time); debug(": ");
  216. debug_hex16(event.key.raw);
  217. debug("[");
  218. if (event.pressed) debug("down"); else debug("up");
  219. debug("]\n");
  220. }
  221. keyrecord_t record = { .event = event };
  222. // pre-process on tapping
  223. if (process_tap(&record)) {
  224. if (!IS_NOEVENT(record.event)) debug("processed.\n");
  225. } else {
  226. if (!IS_NOEVENT(record.event)) debug("enqueued.\n");
  227. if (!waiting_buffer_enq(record)) {
  228. // clear all in case of overflow.
  229. clear_keyboard();
  230. waiting_buffer_clear();
  231. tapping_key = (keyrecord_t){};
  232. }
  233. }
  234. // TODO: need to process every time?
  235. // process waiting_buffer
  236. for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) {
  237. if (process_tap(&waiting_buffer[waiting_buffer_tail])) {
  238. debug("processed: waiting_buffer["); debug_dec(waiting_buffer_tail); debug("] = ");
  239. debug_hex16(waiting_buffer[waiting_buffer_tail].event.key.raw); debug("\n");
  240. } else {
  241. break;
  242. }
  243. }
  244. }
  245. static void process(keyrecord_t *record)
  246. {
  247. // TODO: use record
  248. keyevent_t event = record->event;
  249. uint8_t tap_count = record->tap_count;
  250. if (IS_NOEVENT(event)) { return; }
  251. action_t action = keymap_get_action(current_layer, event.key.pos.row, event.key.pos.col);
  252. debug("action: "); debug_hex16(action.code);
  253. if (event.pressed) debug("[down]\n"); else debug("[up]\n");
  254. switch (action.kind.id) {
  255. /* Key and Mods */
  256. case ACT_LMODS:
  257. // |pressed |released
  258. // --------------+---------------------------------+------------
  259. // key |down(key) |up(key)
  260. // mods |add(mods) |del(mods)
  261. // key with mods |add(mods), down(key), unset(mods)|up(key)
  262. if (event.pressed) {
  263. uint8_t tmp_mods = host_get_mods();
  264. if (action.key.mods) {
  265. host_add_mods(action.key.mods);
  266. host_send_keyboard_report();
  267. }
  268. register_code(action.key.code);
  269. if (action.key.mods && action.key.code) {
  270. host_set_mods(tmp_mods);
  271. host_send_keyboard_report();
  272. }
  273. } else {
  274. if (action.key.mods && !action.key.code) {
  275. host_del_mods(action.key.mods);
  276. host_send_keyboard_report();
  277. }
  278. unregister_code(action.key.code);
  279. }
  280. break;
  281. case ACT_RMODS:
  282. // |pressed |released
  283. // --------------+---------------------------------+------------
  284. // key |down(key) |up(key)
  285. // mods |add(mods) |del(mods)
  286. // key with mods |add(mods), down(key), unset(mods)|up(key)
  287. if (event.pressed) {
  288. uint8_t tmp_mods = host_get_mods();
  289. if (action.key.mods) {
  290. host_add_mods(action.key.mods<<4);
  291. host_send_keyboard_report();
  292. }
  293. register_code(action.key.code);
  294. if (action.key.mods && action.key.code) {
  295. host_set_mods(tmp_mods);
  296. host_send_keyboard_report();
  297. }
  298. } else {
  299. if (action.key.mods && !action.key.code) {
  300. host_del_mods(action.key.mods<<4);
  301. host_send_keyboard_report();
  302. }
  303. unregister_code(action.key.code);
  304. }
  305. break;
  306. case ACT_LMODS_TAP:
  307. case ACT_RMODS_TAP:
  308. {
  309. uint8_t tmp_mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods :
  310. action.key.mods<<4;
  311. if (event.pressed) {
  312. if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
  313. if (waiting_buffer_has_anykey_pressed()) {
  314. debug("MODS_TAP: Tap: Cancel: add_mods\n");
  315. // ad hoc: set 0 to cancel tap
  316. record->tap_count = 0;
  317. add_mods(tmp_mods);
  318. } else {
  319. debug("MODS_TAP: Tap: register_code\n");
  320. register_code(action.key.code);
  321. }
  322. } else {
  323. debug("MODS_TAP: No tap: add_mods\n");
  324. add_mods(tmp_mods);
  325. }
  326. } else {
  327. if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
  328. debug("MODS_TAP: Tap: unregister_code\n");
  329. unregister_code(action.key.code);
  330. } else {
  331. debug("MODS_TAP: No tap: add_mods\n");
  332. del_mods(tmp_mods);
  333. }
  334. }
  335. }
  336. break;
  337. /* other HID usage */
  338. case ACT_USAGE:
  339. #ifdef EXTRAKEY_ENABLE
  340. switch (action.usage.page) {
  341. case ACTION_USAGE_PAGE_SYSTEM:
  342. if (event.pressed) {
  343. host_system_send(action.usage.code);
  344. } else {
  345. host_system_send(0);
  346. }
  347. break;
  348. case ACTION_USAGE_PAGE_CONSUMER:
  349. if (event.pressed) {
  350. host_consumer_send(action.usage.code);
  351. } else {
  352. host_consumer_send(0);
  353. }
  354. break;
  355. }
  356. #endif
  357. break;
  358. /* Mouse key */
  359. case ACT_MOUSEKEY:
  360. #ifdef MOUSEKEY_ENABLE
  361. if (event.pressed) {
  362. mousekey_on(action.key.code);
  363. mousekey_send();
  364. } else {
  365. mousekey_off(action.key.code);
  366. mousekey_send();
  367. }
  368. #endif
  369. break;
  370. /* Layer key */
  371. case ACT_LAYER_PRESSED:
  372. // layer action when pressed
  373. switch (action.layer.code) {
  374. case 0x00:
  375. if (event.pressed) {
  376. layer_switch(action.layer.opt);
  377. }
  378. break;
  379. case 0xF0:
  380. // TODO: tap toggle
  381. break;
  382. case 0xFF:
  383. if (event.pressed) {
  384. default_layer = action.layer.opt;
  385. layer_switch(default_layer);
  386. }
  387. break;
  388. default:
  389. // with tap key
  390. if (event.pressed) {
  391. if (IS_TAPPING_KEY(event.key)) {
  392. if (tap_count > 0) {
  393. debug("LAYER_PRESSED: Tap: register_code\n");
  394. register_code(action.layer.code);
  395. } else {
  396. debug("LAYER_PRESSED: No tap: layer_switch\n");
  397. layer_switch(action.layer.opt);
  398. }
  399. } else {
  400. // TODO: while other key tapping
  401. debug("LAYER_PRESSED: No tap: layer_switch\n");
  402. layer_switch(action.layer.opt);
  403. }
  404. /*
  405. if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
  406. debug("LAYER_PRESSED: Tap: register_code\n");
  407. register_code(action.layer.code);
  408. } else {
  409. debug("LAYER_PRESSED: No tap: layer_switch\n");
  410. layer_switch(action.layer.opt);
  411. }
  412. */
  413. } else {
  414. if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
  415. debug("LAYER_PRESSED: Tap: unregister_code\n");
  416. unregister_code(action.layer.code);
  417. } else {
  418. debug("LAYER_PRESSED: No tap: NO ACTION\n");
  419. }
  420. }
  421. break;
  422. }
  423. break;
  424. case ACT_LAYER_RELEASED:
  425. switch (action.layer.code) {
  426. case 0x00:
  427. if (!event.pressed) {
  428. layer_switch(action.layer.opt);
  429. }
  430. break;
  431. case 0xF0:
  432. // Ignored. LAYER_RELEASED with tap toggle is invalid action.
  433. break;
  434. case 0xFF:
  435. if (!event.pressed) {
  436. default_layer = action.layer.opt;
  437. layer_switch(default_layer);
  438. }
  439. break;
  440. default:
  441. // Ignored. LAYER_RELEASED with tap key is invalid action.
  442. break;
  443. }
  444. break;
  445. case ACT_LAYER_BIT:
  446. switch (action.layer.code) {
  447. case 0x00:
  448. if (event.pressed) {
  449. layer_switch(current_layer | action.layer.opt);
  450. } else {
  451. layer_switch(current_layer & ~action.layer.opt);
  452. }
  453. break;
  454. case 0xF0:
  455. // TODO: tap toggle
  456. break;
  457. case 0xFF:
  458. // change default layer
  459. if (event.pressed) {
  460. default_layer = current_layer | action.layer.opt;
  461. layer_switch(default_layer);
  462. } else {
  463. default_layer = current_layer & ~action.layer.opt;
  464. layer_switch(default_layer);
  465. }
  466. break;
  467. default:
  468. // with tap key
  469. if (event.pressed) {
  470. if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
  471. debug("LAYER_BIT: Tap: register_code\n");
  472. register_code(action.layer.code);
  473. } else {
  474. debug("LAYER_BIT: No tap: layer_switch(bit on)\n");
  475. layer_switch(current_layer | action.layer.opt);
  476. }
  477. } else {
  478. if (IS_TAPPING_KEY(event.key) && tap_count > 0) {
  479. debug("LAYER_BIT: Tap: unregister_code\n");
  480. unregister_code(action.layer.code);
  481. } else {
  482. debug("LAYER_BIT: No tap: layer_switch(bit off)\n");
  483. layer_switch(current_layer & ~action.layer.opt);
  484. }
  485. }
  486. break;
  487. }
  488. case ACT_LAYER_EXT:
  489. switch (action.layer.opt) {
  490. case 0x00:
  491. // set default layer when pressed
  492. switch (action.layer.code) {
  493. case 0x00:
  494. if (event.pressed) {
  495. layer_switch(default_layer);
  496. }
  497. break;
  498. case 0xF0:
  499. // TODO: tap toggle
  500. break;
  501. case 0xFF:
  502. if (event.pressed) {
  503. default_layer = current_layer;
  504. layer_switch(default_layer);
  505. }
  506. break;
  507. default:
  508. // TODO: tap key
  509. break;
  510. }
  511. break;
  512. case 0x01:
  513. // set default layer when released
  514. switch (action.layer.code) {
  515. case 0x00:
  516. if (!event.pressed) {
  517. layer_switch(default_layer);
  518. }
  519. break;
  520. case 0xFF:
  521. if (!event.pressed) {
  522. default_layer = current_layer;
  523. layer_switch(default_layer);
  524. }
  525. break;
  526. case 0xF0:
  527. default:
  528. // Ignore tap.
  529. if (!event.pressed) {
  530. layer_switch(default_layer);
  531. }
  532. break;
  533. }
  534. break;
  535. }
  536. break;
  537. /* Extentions */
  538. case ACT_MACRO:
  539. break;
  540. case ACT_COMMAND:
  541. break;
  542. case ACT_FUNCTION:
  543. action_call_function(event, action.func.id);
  544. //test_func(event, action.func.opt);
  545. break;
  546. default:
  547. break;
  548. }
  549. }
  550. /*
  551. * Utilities for actions.
  552. */
  553. void register_code(uint8_t code)
  554. {
  555. if (code == KC_NO) {
  556. return;
  557. }
  558. else if IS_KEY(code) {
  559. // TODO: should push command_proc out of this block?
  560. if (!command_proc(code)) {
  561. host_add_key(code);
  562. host_send_keyboard_report();
  563. }
  564. }
  565. else if IS_MOD(code) {
  566. host_add_mods(MOD_BIT(code));
  567. host_send_keyboard_report();
  568. }
  569. }
  570. void unregister_code(uint8_t code)
  571. {
  572. if IS_KEY(code) {
  573. host_del_key(code);
  574. host_send_keyboard_report();
  575. }
  576. else if IS_MOD(code) {
  577. host_del_mods(MOD_BIT(code));
  578. host_send_keyboard_report();
  579. }
  580. }
  581. void add_mods(uint8_t mods)
  582. {
  583. if (mods) {
  584. host_add_mods(mods);
  585. host_send_keyboard_report();
  586. }
  587. }
  588. void del_mods(uint8_t mods)
  589. {
  590. if (mods) {
  591. host_del_mods(mods);
  592. host_send_keyboard_report();
  593. }
  594. }
  595. void set_mods(uint8_t mods)
  596. {
  597. host_set_mods(mods);
  598. host_send_keyboard_report();
  599. }
  600. void clear_keyboard(void)
  601. {
  602. host_clear_mods();
  603. clear_keyboard_but_mods();
  604. }
  605. void clear_keyboard_but_mods(void)
  606. {
  607. host_clear_keys();
  608. host_send_keyboard_report();
  609. #ifdef MOUSEKEY_ENABLE
  610. mousekey_clear();
  611. mousekey_send();
  612. #endif
  613. #ifdef EXTRAKEY_ENABLE
  614. host_system_send(0);
  615. host_consumer_send(0);
  616. #endif
  617. }
  618. bool sending_anykey(void)
  619. {
  620. return (host_has_anykey() || host_mouse_in_use() ||
  621. host_last_sysytem_report() || host_last_consumer_report());
  622. }
  623. void layer_switch(uint8_t new_layer)
  624. {
  625. if (current_layer != new_layer) {
  626. debug("Layer Switch: "); debug_hex(current_layer);
  627. debug(" -> "); debug_hex(new_layer); debug("\n");
  628. current_layer = new_layer;
  629. clear_keyboard_but_mods(); // To avoid stuck keys
  630. // TODO: update mods with full scan of matrix? if modifier changes between layers
  631. }
  632. }
  633. bool is_tap_key(key_t key)
  634. {
  635. action_t action = keymap_get_action(current_layer, key.pos.row, key.pos.col);
  636. switch (action.kind.id) {
  637. case ACT_LMODS_TAP:
  638. case ACT_RMODS_TAP:
  639. return true;
  640. case ACT_LAYER_PRESSED:
  641. case ACT_LAYER_BIT:
  642. switch (action.layer.code) {
  643. case 0x00:
  644. case 0xF1 ... 0xFF:
  645. return false;
  646. case 0xF0:
  647. default:
  648. return true;
  649. }
  650. return false;
  651. case ACT_FUNCTION:
  652. if (action.func.opt & 0x1) {
  653. return true;
  654. }
  655. return false;
  656. }
  657. return false;
  658. }