2021-06-17 16:10:06 -07:00
|
|
|
/* Copyright 2021 QMK
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-01-17 10:08:14 -08:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-16 06:42:56 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#include "progmem.h"
|
|
|
|
#include "action_layer.h"
|
2021-02-07 15:16:15 -08:00
|
|
|
#include "matrix.h"
|
2019-01-17 10:08:14 -08:00
|
|
|
|
2021-06-17 16:10:06 -07:00
|
|
|
#ifndef RPC_M2S_BUFFER_SIZE
|
|
|
|
# define RPC_M2S_BUFFER_SIZE 32
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // RPC_M2S_BUFFER_SIZE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifndef RPC_S2M_BUFFER_SIZE
|
|
|
|
# define RPC_S2M_BUFFER_SIZE 32
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // RPC_S2M_BUFFER_SIZE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
2019-01-17 10:08:14 -08:00
|
|
|
void transport_master_init(void);
|
|
|
|
void transport_slave_init(void);
|
|
|
|
|
|
|
|
// returns false if valid data not received from slave
|
2021-02-15 16:30:33 -08:00
|
|
|
bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
|
|
|
|
void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length);
|
|
|
|
|
|
|
|
#ifdef ENCODER_ENABLE
|
|
|
|
# include "encoder.h"
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // ENCODER_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef BACKLIGHT_ENABLE
|
|
|
|
# include "backlight.h"
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // BACKLIGHT_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef RGBLIGHT_ENABLE
|
|
|
|
# include "rgblight.h"
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // RGBLIGHT_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
typedef struct _split_slave_matrix_sync_t {
|
|
|
|
uint8_t checksum;
|
|
|
|
matrix_row_t matrix[(MATRIX_ROWS) / 2];
|
|
|
|
} split_slave_matrix_sync_t;
|
|
|
|
|
|
|
|
#ifdef SPLIT_TRANSPORT_MIRROR
|
|
|
|
typedef struct _split_master_matrix_sync_t {
|
|
|
|
matrix_row_t matrix[(MATRIX_ROWS) / 2];
|
|
|
|
} split_master_matrix_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // SPLIT_TRANSPORT_MIRROR
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef ENCODER_ENABLE
|
|
|
|
typedef struct _split_slave_encoder_sync_t {
|
|
|
|
uint8_t checksum;
|
2022-03-07 21:58:05 -08:00
|
|
|
uint8_t state[NUM_ENCODERS_MAX_PER_SIDE];
|
2021-06-17 16:10:06 -07:00
|
|
|
} split_slave_encoder_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // ENCODER_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
|
|
|
|
typedef struct _split_layers_sync_t {
|
|
|
|
layer_state_t layer_state;
|
|
|
|
layer_state_t default_layer_state;
|
|
|
|
} split_layers_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
|
|
|
|
# include "led_matrix.h"
|
|
|
|
|
|
|
|
typedef struct _led_matrix_sync_t {
|
|
|
|
led_eeconfig_t led_matrix;
|
|
|
|
bool led_suspend_state;
|
|
|
|
} led_matrix_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
|
|
|
|
# include "rgb_matrix.h"
|
|
|
|
|
|
|
|
typedef struct _rgb_matrix_sync_t {
|
|
|
|
rgb_config_t rgb_matrix;
|
|
|
|
bool rgb_suspend_state;
|
|
|
|
} rgb_matrix_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef SPLIT_MODS_ENABLE
|
|
|
|
typedef struct _split_mods_sync_t {
|
|
|
|
uint8_t real_mods;
|
|
|
|
uint8_t weak_mods;
|
|
|
|
# ifndef NO_ACTION_ONESHOT
|
|
|
|
uint8_t oneshot_mods;
|
2022-02-12 10:29:31 -08:00
|
|
|
# endif // NO_ACTION_ONESHOT
|
2021-06-17 16:10:06 -07:00
|
|
|
} split_mods_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // SPLIT_MODS_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
2021-12-26 17:05:51 -08:00
|
|
|
#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
|
|
|
|
# include "pointing_device.h"
|
|
|
|
typedef struct _split_slave_pointing_sync_t {
|
|
|
|
uint8_t checksum;
|
|
|
|
report_mouse_t report;
|
|
|
|
uint16_t cpi;
|
|
|
|
} split_slave_pointing_sync_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
|
2021-12-26 17:05:51 -08:00
|
|
|
|
2022-12-31 16:56:32 -08:00
|
|
|
#if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
|
|
|
|
# include "haptic.h"
|
|
|
|
typedef struct _split_slave_haptic_sync_t {
|
|
|
|
haptic_config_t haptic_config;
|
|
|
|
uint8_t haptic_play;
|
|
|
|
} split_slave_haptic_sync_t;
|
|
|
|
#endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
|
|
|
|
|
2023-03-21 02:16:11 -07:00
|
|
|
#if defined(SPLIT_ACTIVITY_ENABLE)
|
|
|
|
# include "keyboard.h"
|
|
|
|
typedef struct _split_slave_activity_sync_t {
|
|
|
|
uint32_t matrix_timestamp;
|
|
|
|
uint32_t encoder_timestamp;
|
2023-03-30 18:27:39 -07:00
|
|
|
uint32_t pointing_device_timestamp;
|
2023-03-21 02:16:11 -07:00
|
|
|
} split_slave_activity_sync_t;
|
|
|
|
#endif // defined(SPLIT_ACTIVITY_ENABLE)
|
|
|
|
|
2021-06-17 16:10:06 -07:00
|
|
|
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
|
|
|
|
typedef struct _rpc_sync_info_t {
|
2022-08-06 01:46:59 -07:00
|
|
|
uint8_t checksum;
|
|
|
|
struct {
|
|
|
|
int8_t transaction_id;
|
|
|
|
uint8_t m2s_length;
|
|
|
|
uint8_t s2m_length;
|
|
|
|
} payload;
|
2021-06-17 16:10:06 -07:00
|
|
|
} rpc_sync_info_t;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
2023-04-03 15:48:51 -07:00
|
|
|
#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
|
|
|
|
# include "os_detection.h"
|
|
|
|
#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
|
|
|
|
|
2021-06-17 16:10:06 -07:00
|
|
|
typedef struct _split_shared_memory_t {
|
|
|
|
#ifdef USE_I2C
|
|
|
|
int8_t transaction_id;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // USE_I2C
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
split_slave_matrix_sync_t smatrix;
|
|
|
|
|
|
|
|
#ifdef SPLIT_TRANSPORT_MIRROR
|
|
|
|
split_master_matrix_sync_t mmatrix;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // SPLIT_TRANSPORT_MIRROR
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef ENCODER_ENABLE
|
|
|
|
split_slave_encoder_sync_t encoders;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // ENCODER_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifndef DISABLE_SYNC_TIMER
|
|
|
|
uint32_t sync_timer;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // DISABLE_SYNC_TIMER
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
|
|
|
|
split_layers_sync_t layers;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef SPLIT_LED_STATE_ENABLE
|
|
|
|
uint8_t led_state;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // SPLIT_LED_STATE_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef SPLIT_MODS_ENABLE
|
|
|
|
split_mods_sync_t mods;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // SPLIT_MODS_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#ifdef BACKLIGHT_ENABLE
|
|
|
|
uint8_t backlight_level;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // BACKLIGHT_ENABLE
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
|
|
|
|
rgblight_syncinfo_t rgblight_sync;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
|
|
|
|
led_matrix_sync_t led_matrix_sync;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
|
|
|
|
rgb_matrix_sync_t rgb_matrix_sync;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
|
|
|
#if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
|
|
|
|
uint8_t current_wpm;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
|
2021-06-17 16:10:06 -07:00
|
|
|
|
2021-08-23 23:28:26 -07:00
|
|
|
#if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
|
2021-08-14 22:39:08 -07:00
|
|
|
uint8_t current_oled_state;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
|
2021-08-14 22:39:08 -07:00
|
|
|
|
|
|
|
#if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
|
|
|
|
uint8_t current_st7565_state;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE)
|
2021-08-14 22:39:08 -07:00
|
|
|
|
2021-12-26 17:05:51 -08:00
|
|
|
#if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
|
|
|
|
split_slave_pointing_sync_t pointing;
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
|
2021-12-26 17:05:51 -08:00
|
|
|
|
2022-10-06 02:52:42 -07:00
|
|
|
#if defined(SPLIT_WATCHDOG_ENABLE)
|
|
|
|
bool watchdog_pinged;
|
|
|
|
#endif // defined(SPLIT_WATCHDOG_ENABLE)
|
|
|
|
|
2023-04-12 07:22:07 -07:00
|
|
|
#if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
|
2022-12-31 16:56:32 -08:00
|
|
|
split_slave_haptic_sync_t haptic_sync;
|
|
|
|
#endif // defined(HAPTIC_ENABLE)
|
|
|
|
|
2023-03-21 02:16:11 -07:00
|
|
|
#if defined(SPLIT_ACTIVITY_ENABLE)
|
|
|
|
split_slave_activity_sync_t activity_sync;
|
|
|
|
#endif // defined(SPLIT_ACTIVITY_ENABLE)
|
|
|
|
|
2021-06-17 16:10:06 -07:00
|
|
|
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
|
|
|
|
rpc_sync_info_t rpc_info;
|
|
|
|
uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
|
|
|
|
uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
|
2022-02-12 10:29:31 -08:00
|
|
|
#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
|
2023-04-03 15:48:51 -07:00
|
|
|
|
|
|
|
#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
|
|
|
|
os_variant_t detected_os;
|
|
|
|
#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
|
2021-06-17 16:10:06 -07:00
|
|
|
} split_shared_memory_t;
|
|
|
|
|
2021-08-14 22:39:08 -07:00
|
|
|
extern split_shared_memory_t *const split_shmem;
|