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.

144 lines
5.5 KiB

Simplify split_common Code significantly (#4772) * Eliminate separate slave loop Both master and slave run the standard keyboard_task main loop now. * Refactor i2c/serial specific code Simplify some of the preprocessor mess by using common function names. * Fix missing #endif * Move direct pin mapping support from miniaxe to split_common For boards with more pins than sense--sorry, switches. * Reordering and reformatting only * Don't run matrix_scan_quantum on slave side * Clean up the offset/slaveOffset calculations * Cut undebounced matrix size in half * Refactor debouncing * Minor fixups * Split split_common transport and debounce code into their own files Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes * Refactor debounce for non-split keyboards too * Update handwired/xealous to build using new split_common * Fix debounce breaking basic test * Dodgy method to allow a split kb to only include one of i2c/serial SPLIT_TRANSPORT = serial or SPLIT_TRANSPORT = i2c will include only that driver code in the binary. SPLIT_TRANSPORT = custom (or anything else) will include neither, the keyboard must supply it's own code if SPLIT_TRANSPORT is not defined then the original behaviour (include both avr i2c and serial code) is maintained. This could be better but it would require explicitly updating all the existing split keyboards. * Enable LTO to get lets_split/sockets under the line * Add docs for SPLIT_TRANSPORT, CUSTOM_MATRIX, CUSTOM_DEBOUNCE * Remove avr-specific sei() from split matrix_setup Not needed now that slave doesn't have a separate main loop. Both sides (on avr) call sei() in lufa's main() after exiting keyboard_setup(). * Fix QUANTUM_LIB_SRC references and simplify SPLIT_TRANSPORT. * Add comments and fix formatting.
5 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 2011,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. #pragma once
  15. #include <stdbool.h>
  16. #include <stdint.h>
  17. #include "timer.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /* key matrix position */
  22. typedef struct {
  23. uint8_t col;
  24. uint8_t row;
  25. } keypos_t;
  26. typedef enum keyevent_type_t { TICK_EVENT = 0, KEY_EVENT = 1, ENCODER_CW_EVENT = 2, ENCODER_CCW_EVENT = 3, COMBO_EVENT = 4, DIP_SWITCH_ON_EVENT = 5, DIP_SWITCH_OFF_EVENT = 6 } keyevent_type_t;
  27. /* key event */
  28. typedef struct {
  29. keypos_t key;
  30. uint16_t time;
  31. keyevent_type_t type;
  32. bool pressed;
  33. } keyevent_t;
  34. /* equivalent test of keypos_t */
  35. #define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col)
  36. /* special keypos_t entries */
  37. #define KEYLOC_ENCODER_CW 253
  38. #define KEYLOC_ENCODER_CCW 252
  39. #define KEYLOC_DIP_SWITCH_ON 251
  40. #define KEYLOC_DIP_SWITCH_OFF 250
  41. static inline bool IS_NOEVENT(const keyevent_t event) {
  42. return event.type == TICK_EVENT;
  43. }
  44. static inline bool IS_EVENT(const keyevent_t event) {
  45. return event.type != TICK_EVENT;
  46. }
  47. static inline bool IS_KEYEVENT(const keyevent_t event) {
  48. return event.type == KEY_EVENT;
  49. }
  50. static inline bool IS_COMBOEVENT(const keyevent_t event) {
  51. return event.type == COMBO_EVENT;
  52. }
  53. static inline bool IS_ENCODEREVENT(const keyevent_t event) {
  54. return event.type == ENCODER_CW_EVENT || event.type == ENCODER_CCW_EVENT;
  55. }
  56. static inline bool IS_DIPSWITCHEVENT(const keyevent_t event) {
  57. return event.type == DIP_SWITCH_ON_EVENT || event.type == DIP_SWITCH_OFF_EVENT;
  58. }
  59. /* Common keypos_t object factory */
  60. #define MAKE_KEYPOS(row_num, col_num) ((keypos_t){.row = (row_num), .col = (col_num)})
  61. /* Common keyevent_t object factory */
  62. #define MAKE_EVENT(row_num, col_num, press, event_type) ((keyevent_t){.key = MAKE_KEYPOS((row_num), (col_num)), .pressed = (press), .time = timer_read(), .type = (event_type)})
  63. /**
  64. * @brief Constructs a key event for a pressed or released key.
  65. */
  66. #define MAKE_KEYEVENT(row_num, col_num, press) MAKE_EVENT((row_num), (col_num), (press), KEY_EVENT)
  67. /**
  68. * @brief Constructs a combo event.
  69. */
  70. #define MAKE_COMBOEVENT(press) MAKE_EVENT(0, 0, (press), COMBO_EVENT)
  71. /**
  72. * @brief Constructs a internal tick event that is used to drive the internal QMK state machine.
  73. */
  74. #define MAKE_TICK_EVENT MAKE_EVENT(0, 0, false, TICK_EVENT)
  75. #ifdef ENCODER_MAP_ENABLE
  76. /* Encoder events */
  77. # define MAKE_ENCODER_CW_EVENT(enc_id, press) MAKE_EVENT(KEYLOC_ENCODER_CW, (enc_id), (press), ENCODER_CW_EVENT)
  78. # define MAKE_ENCODER_CCW_EVENT(enc_id, press) MAKE_EVENT(KEYLOC_ENCODER_CCW, (enc_id), (press), ENCODER_CCW_EVENT)
  79. #endif // ENCODER_MAP_ENABLE
  80. #ifdef DIP_SWITCH_MAP_ENABLE
  81. /* Dip Switch events */
  82. # define MAKE_DIPSWITCH_ON_EVENT(switch_id, press) MAKE_EVENT(KEYLOC_DIP_SWITCH_ON, (switch_id), (press), DIP_SWITCH_ON_EVENT)
  83. # define MAKE_DIPSWITCH_OFF_EVENT(switch_id, press) MAKE_EVENT(KEYLOC_DIP_SWITCH_OFF, (switch_id), (press), DIP_SWITCH_OFF_EVENT)
  84. #endif // DIP_SWITCH_MAP_ENABLE
  85. /* it runs once at early stage of startup before keyboard_init. */
  86. void keyboard_setup(void);
  87. /* it runs once after initializing host side protocol, debug and MCU peripherals. */
  88. void keyboard_init(void);
  89. /* it runs repeatedly in main loop */
  90. void keyboard_task(void);
  91. /* it runs whenever code has to behave differently on a slave */
  92. bool is_keyboard_master(void);
  93. /* it runs whenever code has to behave differently on left vs right split */
  94. bool is_keyboard_left(void);
  95. void keyboard_pre_init_kb(void);
  96. void keyboard_pre_init_user(void);
  97. void keyboard_post_init_kb(void);
  98. void keyboard_post_init_user(void);
  99. void housekeeping_task(void); // To be executed by the main loop in each backend TMK protocol
  100. void housekeeping_task_kb(void); // To be overridden by keyboard-level code
  101. void housekeeping_task_user(void); // To be overridden by user/keymap-level code
  102. uint32_t last_input_activity_time(void); // Timestamp of the last matrix or encoder or pointing device activity
  103. uint32_t last_input_activity_elapsed(void); // Number of milliseconds since the last matrix or encoder or pointing device activity
  104. uint32_t last_matrix_activity_time(void); // Timestamp of the last matrix activity
  105. uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the last matrix activity
  106. uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity
  107. uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity
  108. uint32_t last_pointing_device_activity_time(void); // Timestamp of the last pointing device activity
  109. uint32_t last_pointing_device_activity_elapsed(void); // Number of milliseconds since the last pointing device activity
  110. void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp, uint32_t pointing_device_timestamp); // Set the timestamps of the last matrix and encoder activity
  111. uint32_t get_matrix_scan_rate(void);
  112. #ifdef __cplusplus
  113. }
  114. #endif