diff options
Diffstat (limited to 'quantum/split_common')
-rw-r--r-- | quantum/split_common/transaction_id_define.h | 8 | ||||
-rw-r--r-- | quantum/split_common/transactions.c | 63 | ||||
-rw-r--r-- | quantum/split_common/transport.h | 23 |
3 files changed, 93 insertions, 1 deletions
diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index 18d3826b83..4d4d2b9570 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h @@ -92,6 +92,10 @@ enum serial_transaction_id { PUT_HAPTIC, #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) + PUT_ACTIVITY, +#endif // SPLIT_ACTIVITY_ENABLE + #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) PUT_RPC_INFO, PUT_RPC_REQ_DATA, @@ -109,6 +113,10 @@ enum serial_transaction_id { SPLIT_TRANSACTION_IDS_USER, #endif // SPLIT_TRANSACTION_IDS_USER +#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) + PUT_DETECTED_OS, +#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) + NUM_TOTAL_TRANSACTIONS }; diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 8e1961b586..b3c80f1194 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -790,6 +790,63 @@ static void haptic_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sla #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) + +static bool activity_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + static uint32_t last_update = 0; + split_slave_activity_sync_t activity_sync; + activity_sync.matrix_timestamp = last_matrix_activity_time(); + activity_sync.encoder_timestamp = last_encoder_activity_time(); + activity_sync.pointing_device_timestamp = last_pointing_device_activity_time(); + return send_if_data_mismatch(PUT_ACTIVITY, &last_update, &activity_sync, &split_shmem->activity_sync, sizeof(activity_sync)); +} + +static void activity_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + set_activity_timestamps(split_shmem->activity_sync.matrix_timestamp, split_shmem->activity_sync.encoder_timestamp, split_shmem->activity_sync.pointing_device_timestamp); +} + +// clang-format off +# define TRANSACTIONS_ACTIVITY_MASTER() TRANSACTION_HANDLER_MASTER(activity) +# define TRANSACTIONS_ACTIVITY_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(activity) +# define TRANSACTIONS_ACTIVITY_REGISTRATIONS [PUT_ACTIVITY] = trans_initiator2target_initializer(activity_sync), +// clang-format on + +#else // defined(SPLIT_ACTIVITY_ENABLE) + +# define TRANSACTIONS_ACTIVITY_MASTER() +# define TRANSACTIONS_ACTIVITY_SLAVE() +# define TRANSACTIONS_ACTIVITY_REGISTRATIONS + +#endif // defined(SPLIT_ACTIVITY_ENABLE) + +//////////////////////////////////////////////////// +// Detected OS + +#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) + +static bool detected_os_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + static uint32_t last_detected_os_update = 0; + os_variant_t detected_os = detected_host_os(); + bool okay = send_if_condition(PUT_DETECTED_OS, &last_detected_os_update, (detected_os != split_shmem->detected_os), &detected_os, sizeof(os_variant_t)); + return okay; +} + +static void detected_os_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { + slave_update_detected_host_os(split_shmem->detected_os); +} + +# define TRANSACTIONS_DETECTED_OS_MASTER() TRANSACTION_HANDLER_MASTER(detected_os) +# define TRANSACTIONS_DETECTED_OS_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(detected_os) +# define TRANSACTIONS_DETECTED_OS_REGISTRATIONS [PUT_DETECTED_OS] = trans_initiator2target_initializer(detected_os), + +#else // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) + +# define TRANSACTIONS_DETECTED_OS_MASTER() +# define TRANSACTIONS_DETECTED_OS_SLAVE() +# define TRANSACTIONS_DETECTED_OS_REGISTRATIONS + +#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) + //////////////////////////////////////////////////// split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { @@ -818,6 +875,8 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { TRANSACTIONS_POINTING_REGISTRATIONS TRANSACTIONS_WATCHDOG_REGISTRATIONS TRANSACTIONS_HAPTIC_REGISTRATIONS + TRANSACTIONS_ACTIVITY_REGISTRATIONS + TRANSACTIONS_DETECTED_OS_REGISTRATIONS // clang-format on #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) @@ -846,6 +905,8 @@ bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix TRANSACTIONS_POINTING_MASTER(); TRANSACTIONS_WATCHDOG_MASTER(); TRANSACTIONS_HAPTIC_MASTER(); + TRANSACTIONS_ACTIVITY_MASTER(); + TRANSACTIONS_DETECTED_OS_MASTER(); return true; } @@ -867,6 +928,8 @@ void transactions_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[ TRANSACTIONS_POINTING_SLAVE(); TRANSACTIONS_WATCHDOG_SLAVE(); TRANSACTIONS_HAPTIC_SLAVE(); + TRANSACTIONS_ACTIVITY_SLAVE(); + TRANSACTIONS_DETECTED_OS_SLAVE(); } #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h index adee4470d2..a3d6f1dfe9 100644 --- a/quantum/split_common/transport.h +++ b/quantum/split_common/transport.h @@ -122,6 +122,15 @@ typedef struct _split_slave_haptic_sync_t { } split_slave_haptic_sync_t; #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) +# include "keyboard.h" +typedef struct _split_slave_activity_sync_t { + uint32_t matrix_timestamp; + uint32_t encoder_timestamp; + uint32_t pointing_device_timestamp; +} split_slave_activity_sync_t; +#endif // defined(SPLIT_ACTIVITY_ENABLE) + #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) typedef struct _rpc_sync_info_t { uint8_t checksum; @@ -133,6 +142,10 @@ typedef struct _rpc_sync_info_t { } rpc_sync_info_t; #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) +#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) +# include "os_detection.h" +#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE) + typedef struct _split_shared_memory_t { #ifdef USE_I2C int8_t transaction_id; @@ -200,15 +213,23 @@ typedef struct _split_shared_memory_t { bool watchdog_pinged; #endif // defined(SPLIT_WATCHDOG_ENABLE) -#if defined(HAPTIC_ENABLE) +#if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE) split_slave_haptic_sync_t haptic_sync; #endif // defined(HAPTIC_ENABLE) +#if defined(SPLIT_ACTIVITY_ENABLE) + split_slave_activity_sync_t activity_sync; +#endif // defined(SPLIT_ACTIVITY_ENABLE) + #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]; #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) + +#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) } split_shared_memory_t; extern split_shared_memory_t *const split_shmem; |