logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

transport.h (7628B)


  1. /* Copyright 2021 QMK
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include "progmem.h"
  20. #include "action_layer.h"
  21. #include "matrix.h"
  22. #ifndef RPC_M2S_BUFFER_SIZE
  23. # define RPC_M2S_BUFFER_SIZE 32
  24. #endif // RPC_M2S_BUFFER_SIZE
  25. #ifndef RPC_S2M_BUFFER_SIZE
  26. # define RPC_S2M_BUFFER_SIZE 32
  27. #endif // RPC_S2M_BUFFER_SIZE
  28. void transport_master_init(void);
  29. void transport_slave_init(void);
  30. // returns false if valid data not received from slave
  31. bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
  32. void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
  33. bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length);
  34. #ifdef ENCODER_ENABLE
  35. # include "encoder.h"
  36. #endif // ENCODER_ENABLE
  37. #ifdef BACKLIGHT_ENABLE
  38. # include "backlight.h"
  39. #endif // BACKLIGHT_ENABLE
  40. #ifdef RGBLIGHT_ENABLE
  41. # include "rgblight.h"
  42. #endif // RGBLIGHT_ENABLE
  43. typedef struct _split_slave_matrix_sync_t {
  44. uint8_t checksum;
  45. matrix_row_t matrix[(MATRIX_ROWS) / 2];
  46. } split_slave_matrix_sync_t;
  47. #ifdef SPLIT_TRANSPORT_MIRROR
  48. typedef struct _split_master_matrix_sync_t {
  49. matrix_row_t matrix[(MATRIX_ROWS) / 2];
  50. } split_master_matrix_sync_t;
  51. #endif // SPLIT_TRANSPORT_MIRROR
  52. #ifdef ENCODER_ENABLE
  53. typedef struct _split_slave_encoder_sync_t {
  54. uint8_t checksum;
  55. encoder_events_t events;
  56. } split_slave_encoder_sync_t;
  57. #endif // ENCODER_ENABLE
  58. #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  59. typedef struct _split_layers_sync_t {
  60. layer_state_t layer_state;
  61. layer_state_t default_layer_state;
  62. } split_layers_sync_t;
  63. #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  64. #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  65. # include "led_matrix.h"
  66. typedef struct _led_matrix_sync_t {
  67. led_eeconfig_t led_matrix;
  68. bool led_suspend_state;
  69. } led_matrix_sync_t;
  70. #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  71. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  72. # include "rgb_matrix.h"
  73. typedef struct _rgb_matrix_sync_t {
  74. rgb_config_t rgb_matrix;
  75. bool rgb_suspend_state;
  76. } rgb_matrix_sync_t;
  77. #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  78. #ifdef SPLIT_MODS_ENABLE
  79. typedef struct _split_mods_sync_t {
  80. uint8_t real_mods;
  81. uint8_t weak_mods;
  82. # ifndef NO_ACTION_ONESHOT
  83. uint8_t oneshot_mods;
  84. uint8_t oneshot_locked_mods;
  85. # endif // NO_ACTION_ONESHOT
  86. } split_mods_sync_t;
  87. #endif // SPLIT_MODS_ENABLE
  88. #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  89. # include "pointing_device.h"
  90. typedef struct _split_slave_pointing_sync_t {
  91. uint8_t checksum;
  92. report_mouse_t report;
  93. uint16_t cpi;
  94. } split_slave_pointing_sync_t;
  95. #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  96. #if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
  97. # include "haptic.h"
  98. typedef struct _split_slave_haptic_sync_t {
  99. haptic_config_t haptic_config;
  100. uint8_t haptic_play;
  101. } split_slave_haptic_sync_t;
  102. #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
  103. #if defined(SPLIT_ACTIVITY_ENABLE)
  104. # include "keyboard.h"
  105. typedef struct _split_slave_activity_sync_t {
  106. uint32_t matrix_timestamp;
  107. uint32_t encoder_timestamp;
  108. uint32_t pointing_device_timestamp;
  109. } split_slave_activity_sync_t;
  110. #endif // defined(SPLIT_ACTIVITY_ENABLE)
  111. #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  112. typedef struct _rpc_sync_info_t {
  113. uint8_t checksum;
  114. struct {
  115. int8_t transaction_id;
  116. uint8_t m2s_length;
  117. uint8_t s2m_length;
  118. } payload;
  119. } rpc_sync_info_t;
  120. #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  121. #if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  122. # include "os_detection.h"
  123. #endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  124. typedef struct _split_shared_memory_t {
  125. #ifdef USE_I2C
  126. int8_t transaction_id;
  127. #endif // USE_I2C
  128. split_slave_matrix_sync_t smatrix;
  129. #ifdef SPLIT_TRANSPORT_MIRROR
  130. split_master_matrix_sync_t mmatrix;
  131. #endif // SPLIT_TRANSPORT_MIRROR
  132. #ifdef ENCODER_ENABLE
  133. split_slave_encoder_sync_t encoders;
  134. #endif // ENCODER_ENABLE
  135. #ifndef DISABLE_SYNC_TIMER
  136. uint32_t sync_timer;
  137. #endif // DISABLE_SYNC_TIMER
  138. #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  139. split_layers_sync_t layers;
  140. #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  141. #ifdef SPLIT_LED_STATE_ENABLE
  142. uint8_t led_state;
  143. #endif // SPLIT_LED_STATE_ENABLE
  144. #ifdef SPLIT_MODS_ENABLE
  145. split_mods_sync_t mods;
  146. #endif // SPLIT_MODS_ENABLE
  147. #ifdef BACKLIGHT_ENABLE
  148. uint8_t backlight_level;
  149. #endif // BACKLIGHT_ENABLE
  150. #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  151. rgblight_syncinfo_t rgblight_sync;
  152. #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  153. #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  154. led_matrix_sync_t led_matrix_sync;
  155. #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  156. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  157. rgb_matrix_sync_t rgb_matrix_sync;
  158. #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  159. #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
  160. uint8_t current_wpm;
  161. #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
  162. #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
  163. uint8_t current_oled_state;
  164. #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
  165. #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
  166. uint8_t current_st7565_state;
  167. #endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE)
  168. #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  169. split_slave_pointing_sync_t pointing;
  170. #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  171. #if defined(SPLIT_WATCHDOG_ENABLE)
  172. bool watchdog_pinged;
  173. #endif // defined(SPLIT_WATCHDOG_ENABLE)
  174. #if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
  175. split_slave_haptic_sync_t haptic_sync;
  176. #endif // defined(HAPTIC_ENABLE)
  177. #if defined(SPLIT_ACTIVITY_ENABLE)
  178. split_slave_activity_sync_t activity_sync;
  179. #endif // defined(SPLIT_ACTIVITY_ENABLE)
  180. #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  181. rpc_sync_info_t rpc_info;
  182. uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
  183. uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
  184. #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  185. #if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  186. os_variant_t detected_os;
  187. #endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  188. } split_shared_memory_t;
  189. extern split_shared_memory_t *const split_shmem;