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.

560 lines
14 KiB

2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
  1. /*
  2. Copyright 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 "report.h"
  16. #include "debug.h"
  17. #include "action_util.h"
  18. #include "action_layer.h"
  19. #include "timer.h"
  20. #include "keycode_config.h"
  21. #include <string.h>
  22. extern keymap_config_t keymap_config;
  23. static uint8_t real_mods = 0;
  24. static uint8_t weak_mods = 0;
  25. #ifdef KEY_OVERRIDE_ENABLE
  26. static uint8_t weak_override_mods = 0;
  27. static uint8_t suppressed_mods = 0;
  28. #endif
  29. // TODO: pointer variable is not needed
  30. // report_keyboard_t keyboard_report = {};
  31. report_keyboard_t *keyboard_report = &(report_keyboard_t){};
  32. #ifdef NKRO_ENABLE
  33. report_nkro_t *nkro_report = &(report_nkro_t){};
  34. #endif
  35. extern inline void add_key(uint8_t key);
  36. extern inline void del_key(uint8_t key);
  37. extern inline void clear_keys(void);
  38. #ifndef NO_ACTION_ONESHOT
  39. static uint8_t oneshot_mods = 0;
  40. static uint8_t oneshot_locked_mods = 0;
  41. uint8_t get_oneshot_locked_mods(void) {
  42. return oneshot_locked_mods;
  43. }
  44. void add_oneshot_locked_mods(uint8_t mods) {
  45. if ((oneshot_locked_mods & mods) != mods) {
  46. oneshot_locked_mods |= mods;
  47. oneshot_locked_mods_changed_kb(oneshot_locked_mods);
  48. }
  49. }
  50. void set_oneshot_locked_mods(uint8_t mods) {
  51. if (mods != oneshot_locked_mods) {
  52. oneshot_locked_mods = mods;
  53. oneshot_locked_mods_changed_kb(oneshot_locked_mods);
  54. }
  55. }
  56. void clear_oneshot_locked_mods(void) {
  57. if (oneshot_locked_mods) {
  58. oneshot_locked_mods = 0;
  59. oneshot_locked_mods_changed_kb(oneshot_locked_mods);
  60. }
  61. }
  62. void del_oneshot_locked_mods(uint8_t mods) {
  63. if (oneshot_locked_mods & mods) {
  64. oneshot_locked_mods &= ~mods;
  65. oneshot_locked_mods_changed_kb(oneshot_locked_mods);
  66. }
  67. }
  68. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  69. static uint16_t oneshot_time = 0;
  70. bool has_oneshot_mods_timed_out(void) {
  71. return TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT;
  72. }
  73. # else
  74. bool has_oneshot_mods_timed_out(void) {
  75. return false;
  76. }
  77. # endif
  78. #endif
  79. /* oneshot layer */
  80. #ifndef NO_ACTION_ONESHOT
  81. /** \brief oneshot_layer_data bits
  82. * LLLL LSSS
  83. * where:
  84. * L => are layer bits
  85. * S => oneshot state bits
  86. */
  87. static uint8_t oneshot_layer_data = 0;
  88. inline uint8_t get_oneshot_layer(void) {
  89. return oneshot_layer_data >> 3;
  90. }
  91. inline uint8_t get_oneshot_layer_state(void) {
  92. return oneshot_layer_data & 0b111;
  93. }
  94. # ifdef SWAP_HANDS_ENABLE
  95. enum {
  96. SHO_OFF,
  97. SHO_ACTIVE, // Swap hands button was pressed, and we didn't send any swapped keys yet
  98. SHO_PRESSED, // Swap hands button is currently pressed
  99. SHO_USED, // Swap hands button is still pressed, and we already sent swapped keys
  100. } swap_hands_oneshot = SHO_OFF;
  101. # endif
  102. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  103. static uint16_t oneshot_layer_time = 0;
  104. inline bool has_oneshot_layer_timed_out(void) {
  105. return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && !(get_oneshot_layer_state() & ONESHOT_TOGGLED);
  106. }
  107. # ifdef SWAP_HANDS_ENABLE
  108. static uint16_t oneshot_swaphands_time = 0;
  109. inline bool has_oneshot_swaphands_timed_out(void) {
  110. return TIMER_DIFF_16(timer_read(), oneshot_swaphands_time) >= ONESHOT_TIMEOUT && (swap_hands_oneshot == SHO_ACTIVE);
  111. }
  112. # endif
  113. # endif
  114. # ifdef SWAP_HANDS_ENABLE
  115. void set_oneshot_swaphands(void) {
  116. swap_hands_oneshot = SHO_PRESSED;
  117. swap_hands = true;
  118. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  119. oneshot_swaphands_time = timer_read();
  120. if (oneshot_layer_time != 0) {
  121. oneshot_layer_time = oneshot_swaphands_time;
  122. }
  123. # endif
  124. }
  125. void release_oneshot_swaphands(void) {
  126. if (swap_hands_oneshot == SHO_PRESSED) {
  127. swap_hands_oneshot = SHO_ACTIVE;
  128. }
  129. if (swap_hands_oneshot == SHO_USED) {
  130. clear_oneshot_swaphands();
  131. }
  132. }
  133. void use_oneshot_swaphands(void) {
  134. if (swap_hands_oneshot == SHO_PRESSED) {
  135. swap_hands_oneshot = SHO_USED;
  136. }
  137. if (swap_hands_oneshot == SHO_ACTIVE) {
  138. clear_oneshot_swaphands();
  139. }
  140. }
  141. void clear_oneshot_swaphands(void) {
  142. swap_hands_oneshot = SHO_OFF;
  143. swap_hands = false;
  144. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  145. oneshot_swaphands_time = 0;
  146. # endif
  147. }
  148. # endif
  149. /** \brief Set oneshot layer
  150. *
  151. * FIXME: needs doc
  152. */
  153. void set_oneshot_layer(uint8_t layer, uint8_t state) {
  154. if (keymap_config.oneshot_enable) {
  155. oneshot_layer_data = layer << 3 | state;
  156. layer_on(layer);
  157. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  158. oneshot_layer_time = timer_read();
  159. # endif
  160. oneshot_layer_changed_kb(get_oneshot_layer());
  161. } else {
  162. layer_on(layer);
  163. }
  164. }
  165. /** \brief Reset oneshot layer
  166. *
  167. * FIXME: needs doc
  168. */
  169. void reset_oneshot_layer(void) {
  170. oneshot_layer_data = 0;
  171. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  172. oneshot_layer_time = 0;
  173. # endif
  174. oneshot_layer_changed_kb(get_oneshot_layer());
  175. }
  176. /** \brief Clear oneshot layer
  177. *
  178. * FIXME: needs doc
  179. */
  180. void clear_oneshot_layer_state(oneshot_fullfillment_t state) {
  181. uint8_t start_state = oneshot_layer_data;
  182. oneshot_layer_data &= ~state;
  183. if ((!get_oneshot_layer_state() && start_state != oneshot_layer_data) && keymap_config.oneshot_enable) {
  184. layer_off(get_oneshot_layer());
  185. reset_oneshot_layer();
  186. }
  187. }
  188. /** \brief Is oneshot layer active
  189. *
  190. * FIXME: needs doc
  191. */
  192. bool is_oneshot_layer_active(void) {
  193. return get_oneshot_layer_state();
  194. }
  195. /** \brief set oneshot
  196. *
  197. * FIXME: needs doc
  198. */
  199. void oneshot_set(bool active) {
  200. if (keymap_config.oneshot_enable != active) {
  201. keymap_config.oneshot_enable = active;
  202. eeconfig_update_keymap(keymap_config.raw);
  203. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  204. dprintf("Oneshot: active: %d\n", active);
  205. }
  206. }
  207. /** \brief toggle oneshot
  208. *
  209. * FIXME: needs doc
  210. */
  211. void oneshot_toggle(void) {
  212. oneshot_set(!keymap_config.oneshot_enable);
  213. }
  214. /** \brief enable oneshot
  215. *
  216. * FIXME: needs doc
  217. */
  218. void oneshot_enable(void) {
  219. oneshot_set(true);
  220. }
  221. /** \brief disable oneshot
  222. *
  223. * FIXME: needs doc
  224. */
  225. void oneshot_disable(void) {
  226. oneshot_set(false);
  227. }
  228. bool is_oneshot_enabled(void) {
  229. return keymap_config.oneshot_enable;
  230. }
  231. #endif
  232. static uint8_t get_mods_for_report(void) {
  233. uint8_t mods = real_mods | weak_mods;
  234. #ifndef NO_ACTION_ONESHOT
  235. if (oneshot_mods) {
  236. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  237. if (has_oneshot_mods_timed_out()) {
  238. dprintf("Oneshot: timeout\n");
  239. clear_oneshot_mods();
  240. }
  241. # endif
  242. mods |= oneshot_mods;
  243. if (has_anykey()) {
  244. clear_oneshot_mods();
  245. }
  246. }
  247. #endif
  248. #ifdef KEY_OVERRIDE_ENABLE
  249. // These need to be last to be able to properly control key overrides
  250. mods &= ~suppressed_mods;
  251. mods |= weak_override_mods;
  252. #endif
  253. return mods;
  254. }
  255. void send_6kro_report(void) {
  256. keyboard_report->mods = get_mods_for_report();
  257. #ifdef PROTOCOL_VUSB
  258. host_keyboard_send(keyboard_report);
  259. #else
  260. static report_keyboard_t last_report;
  261. /* Only send the report if there are changes to propagate to the host. */
  262. if (memcmp(keyboard_report, &last_report, sizeof(report_keyboard_t)) != 0) {
  263. memcpy(&last_report, keyboard_report, sizeof(report_keyboard_t));
  264. host_keyboard_send(keyboard_report);
  265. }
  266. #endif
  267. }
  268. #ifdef NKRO_ENABLE
  269. void send_nkro_report(void) {
  270. nkro_report->mods = get_mods_for_report();
  271. static report_nkro_t last_report;
  272. /* Only send the report if there are changes to propagate to the host. */
  273. if (memcmp(nkro_report, &last_report, sizeof(report_nkro_t)) != 0) {
  274. memcpy(&last_report, nkro_report, sizeof(report_nkro_t));
  275. host_nkro_send(nkro_report);
  276. }
  277. }
  278. #endif
  279. /** \brief Send keyboard report
  280. *
  281. * FIXME: needs doc
  282. */
  283. void send_keyboard_report(void) {
  284. #ifdef NKRO_ENABLE
  285. if (keyboard_protocol && keymap_config.nkro) {
  286. send_nkro_report();
  287. } else {
  288. send_6kro_report();
  289. }
  290. #else
  291. send_6kro_report();
  292. #endif
  293. }
  294. /** \brief Get mods
  295. *
  296. * FIXME: needs doc
  297. */
  298. uint8_t get_mods(void) {
  299. return real_mods;
  300. }
  301. /** \brief add mods
  302. *
  303. * FIXME: needs doc
  304. */
  305. void add_mods(uint8_t mods) {
  306. real_mods |= mods;
  307. }
  308. /** \brief del mods
  309. *
  310. * FIXME: needs doc
  311. */
  312. void del_mods(uint8_t mods) {
  313. real_mods &= ~mods;
  314. }
  315. /** \brief set mods
  316. *
  317. * FIXME: needs doc
  318. */
  319. void set_mods(uint8_t mods) {
  320. real_mods = mods;
  321. }
  322. /** \brief clear mods
  323. *
  324. * FIXME: needs doc
  325. */
  326. void clear_mods(void) {
  327. real_mods = 0;
  328. }
  329. /** \brief get weak mods
  330. *
  331. * FIXME: needs doc
  332. */
  333. uint8_t get_weak_mods(void) {
  334. return weak_mods;
  335. }
  336. /** \brief add weak mods
  337. *
  338. * FIXME: needs doc
  339. */
  340. void add_weak_mods(uint8_t mods) {
  341. weak_mods |= mods;
  342. }
  343. /** \brief del weak mods
  344. *
  345. * FIXME: needs doc
  346. */
  347. void del_weak_mods(uint8_t mods) {
  348. weak_mods &= ~mods;
  349. }
  350. /** \brief set weak mods
  351. *
  352. * FIXME: needs doc
  353. */
  354. void set_weak_mods(uint8_t mods) {
  355. weak_mods = mods;
  356. }
  357. /** \brief clear weak mods
  358. *
  359. * FIXME: needs doc
  360. */
  361. void clear_weak_mods(void) {
  362. weak_mods = 0;
  363. }
  364. #ifdef KEY_OVERRIDE_ENABLE
  365. /** \brief set weak mods used by key overrides. DO not call this manually
  366. */
  367. void set_weak_override_mods(uint8_t mods) {
  368. weak_override_mods = mods;
  369. }
  370. /** \brief clear weak mods used by key overrides. DO not call this manually
  371. */
  372. void clear_weak_override_mods(void) {
  373. weak_override_mods = 0;
  374. }
  375. /** \brief set suppressed mods used by key overrides. DO not call this manually
  376. */
  377. void set_suppressed_override_mods(uint8_t mods) {
  378. suppressed_mods = mods;
  379. }
  380. /** \brief clear suppressed mods used by key overrides. DO not call this manually
  381. */
  382. void clear_suppressed_override_mods(void) {
  383. suppressed_mods = 0;
  384. }
  385. #endif
  386. #ifndef NO_ACTION_ONESHOT
  387. /** \brief get oneshot mods
  388. *
  389. * FIXME: needs doc
  390. */
  391. uint8_t get_oneshot_mods(void) {
  392. return oneshot_mods;
  393. }
  394. void add_oneshot_mods(uint8_t mods) {
  395. if ((oneshot_mods & mods) != mods) {
  396. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  397. oneshot_time = timer_read();
  398. # endif
  399. oneshot_mods |= mods;
  400. oneshot_mods_changed_kb(mods);
  401. }
  402. }
  403. void del_oneshot_mods(uint8_t mods) {
  404. if (oneshot_mods & mods) {
  405. oneshot_mods &= ~mods;
  406. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  407. oneshot_time = oneshot_mods ? timer_read() : 0;
  408. # endif
  409. oneshot_mods_changed_kb(oneshot_mods);
  410. }
  411. }
  412. /** \brief set oneshot mods
  413. *
  414. * FIXME: needs doc
  415. */
  416. void set_oneshot_mods(uint8_t mods) {
  417. if (keymap_config.oneshot_enable) {
  418. if (oneshot_mods != mods) {
  419. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  420. oneshot_time = timer_read();
  421. # endif
  422. oneshot_mods = mods;
  423. oneshot_mods_changed_kb(mods);
  424. }
  425. }
  426. }
  427. /** \brief clear oneshot mods
  428. *
  429. * FIXME: needs doc
  430. */
  431. void clear_oneshot_mods(void) {
  432. if (oneshot_mods) {
  433. oneshot_mods = 0;
  434. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  435. oneshot_time = 0;
  436. # endif
  437. oneshot_mods_changed_kb(oneshot_mods);
  438. }
  439. }
  440. #endif
  441. /** \brief Called when the one shot modifiers have been changed.
  442. *
  443. * \param mods Contains the active modifiers active after the change.
  444. */
  445. __attribute__((weak)) void oneshot_locked_mods_changed_user(uint8_t mods) {}
  446. /** \brief Called when the locked one shot modifiers have been changed.
  447. *
  448. * \param mods Contains the active modifiers active after the change.
  449. */
  450. __attribute__((weak)) void oneshot_locked_mods_changed_kb(uint8_t mods) {
  451. oneshot_locked_mods_changed_user(mods);
  452. }
  453. /** \brief Called when the one shot modifiers have been changed.
  454. *
  455. * \param mods Contains the active modifiers active after the change.
  456. */
  457. __attribute__((weak)) void oneshot_mods_changed_user(uint8_t mods) {}
  458. /** \brief Called when the one shot modifiers have been changed.
  459. *
  460. * \param mods Contains the active modifiers active after the change.
  461. */
  462. __attribute__((weak)) void oneshot_mods_changed_kb(uint8_t mods) {
  463. oneshot_mods_changed_user(mods);
  464. }
  465. /** \brief Called when the one shot layers have been changed.
  466. *
  467. * \param layer Contains the layer that is toggled on, or zero when toggled off.
  468. */
  469. __attribute__((weak)) void oneshot_layer_changed_user(uint8_t layer) {}
  470. /** \brief Called when the one shot layers have been changed.
  471. *
  472. * \param layer Contains the layer that is toggled on, or zero when toggled off.
  473. */
  474. __attribute__((weak)) void oneshot_layer_changed_kb(uint8_t layer) {
  475. oneshot_layer_changed_user(layer);
  476. }
  477. /** \brief inspect keyboard state
  478. *
  479. * FIXME: needs doc
  480. */
  481. uint8_t has_anymod(void) {
  482. return bitpop(real_mods);
  483. }
  484. #ifdef DUMMY_MOD_NEUTRALIZER_KEYCODE
  485. /** \brief Send a dummy keycode in between the register and unregister event of a modifier key, to neutralize the "flashing modifiers" phenomenon.
  486. *
  487. * \param active_mods 8-bit packed bit-array describing the currently active modifiers (in the format GASCGASC).
  488. *
  489. * Certain QMK features like key overrides or retro tap must unregister a previously
  490. * registered modifier before sending another keycode but this can trigger undesired
  491. * keyboard shortcuts if the clean tap of a single modifier key is bound to an action
  492. * on the host OS, as is for example the case for the left GUI key on Windows, which
  493. * opens the Start Menu when tapped.
  494. */
  495. void neutralize_flashing_modifiers(uint8_t active_mods) {
  496. // In most scenarios, the flashing modifiers phenomenon is a problem
  497. // only for a subset of modifier masks.
  498. const static uint8_t mods_to_neutralize[] = MODS_TO_NEUTRALIZE;
  499. const static uint8_t n_mods = ARRAY_SIZE(mods_to_neutralize);
  500. for (uint8_t i = 0; i < n_mods; ++i) {
  501. if (active_mods == mods_to_neutralize[i]) {
  502. tap_code(DUMMY_MOD_NEUTRALIZER_KEYCODE);
  503. break;
  504. }
  505. }
  506. }
  507. #endif