summaryrefslogtreecommitdiff
path: root/quantum/split_common
diff options
context:
space:
mode:
authorngs-ch <125195794+ngs-ch@users.noreply.github.com>2023-04-04 07:48:51 +0900
committerGitHub <noreply@github.com>2023-04-04 08:48:51 +1000
commitccda5d2d2f0b2e71e16d72636622743a68757b50 (patch)
tree955ad43e25268dbe452514a92904be6af32fc33f /quantum/split_common
parentd82c6648f50d72820effce6077084c8a2dce1b18 (diff)
Make "detected_host_os()" available on the SLAVE side of the split keyboard (#19854)
Co-authored-by: ngs.ch <ngs.ch> Co-authored-by: Drashna Jaelre <drashna@drashna.net>
Diffstat (limited to 'quantum/split_common')
-rw-r--r--quantum/split_common/transaction_id_define.h4
-rw-r--r--quantum/split_common/transactions.c31
-rw-r--r--quantum/split_common/transport.h8
3 files changed, 43 insertions, 0 deletions
diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h
index 4932530aa3..4d4d2b9570 100644
--- a/quantum/split_common/transaction_id_define.h
+++ b/quantum/split_common/transaction_id_define.h
@@ -113,6 +113,10 @@ enum serial_transaction_id {
113 SPLIT_TRANSACTION_IDS_USER, 113 SPLIT_TRANSACTION_IDS_USER,
114#endif // SPLIT_TRANSACTION_IDS_USER 114#endif // SPLIT_TRANSACTION_IDS_USER
115 115
116#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
117 PUT_DETECTED_OS,
118#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
119
116 NUM_TOTAL_TRANSACTIONS 120 NUM_TOTAL_TRANSACTIONS
117}; 121};
118 122
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index 0ae91ba363..b3c80f1194 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -820,6 +820,34 @@ static void activity_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s
820#endif // defined(SPLIT_ACTIVITY_ENABLE) 820#endif // defined(SPLIT_ACTIVITY_ENABLE)
821 821
822//////////////////////////////////////////////////// 822////////////////////////////////////////////////////
823// Detected OS
824
825#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
826
827static bool detected_os_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
828 static uint32_t last_detected_os_update = 0;
829 os_variant_t detected_os = detected_host_os();
830 bool okay = send_if_condition(PUT_DETECTED_OS, &last_detected_os_update, (detected_os != split_shmem->detected_os), &detected_os, sizeof(os_variant_t));
831 return okay;
832}
833
834static void detected_os_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
835 slave_update_detected_host_os(split_shmem->detected_os);
836}
837
838# define TRANSACTIONS_DETECTED_OS_MASTER() TRANSACTION_HANDLER_MASTER(detected_os)
839# define TRANSACTIONS_DETECTED_OS_SLAVE() TRANSACTION_HANDLER_SLAVE_AUTOLOCK(detected_os)
840# define TRANSACTIONS_DETECTED_OS_REGISTRATIONS [PUT_DETECTED_OS] = trans_initiator2target_initializer(detected_os),
841
842#else // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
843
844# define TRANSACTIONS_DETECTED_OS_MASTER()
845# define TRANSACTIONS_DETECTED_OS_SLAVE()
846# define TRANSACTIONS_DETECTED_OS_REGISTRATIONS
847
848#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
849
850////////////////////////////////////////////////////
823 851
824split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = { 852split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
825 // Set defaults 853 // Set defaults
@@ -848,6 +876,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
848 TRANSACTIONS_WATCHDOG_REGISTRATIONS 876 TRANSACTIONS_WATCHDOG_REGISTRATIONS
849 TRANSACTIONS_HAPTIC_REGISTRATIONS 877 TRANSACTIONS_HAPTIC_REGISTRATIONS
850 TRANSACTIONS_ACTIVITY_REGISTRATIONS 878 TRANSACTIONS_ACTIVITY_REGISTRATIONS
879 TRANSACTIONS_DETECTED_OS_REGISTRATIONS
851// clang-format on 880// clang-format on
852 881
853#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 882#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
@@ -877,6 +906,7 @@ bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix
877 TRANSACTIONS_WATCHDOG_MASTER(); 906 TRANSACTIONS_WATCHDOG_MASTER();
878 TRANSACTIONS_HAPTIC_MASTER(); 907 TRANSACTIONS_HAPTIC_MASTER();
879 TRANSACTIONS_ACTIVITY_MASTER(); 908 TRANSACTIONS_ACTIVITY_MASTER();
909 TRANSACTIONS_DETECTED_OS_MASTER();
880 return true; 910 return true;
881} 911}
882 912
@@ -899,6 +929,7 @@ void transactions_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[
899 TRANSACTIONS_WATCHDOG_SLAVE(); 929 TRANSACTIONS_WATCHDOG_SLAVE();
900 TRANSACTIONS_HAPTIC_SLAVE(); 930 TRANSACTIONS_HAPTIC_SLAVE();
901 TRANSACTIONS_ACTIVITY_SLAVE(); 931 TRANSACTIONS_ACTIVITY_SLAVE();
932 TRANSACTIONS_DETECTED_OS_SLAVE();
902} 933}
903 934
904#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 935#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 13b1e56814..6f8985cb07 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -142,6 +142,10 @@ typedef struct _rpc_sync_info_t {
142} rpc_sync_info_t; 142} rpc_sync_info_t;
143#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 143#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
144 144
145#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
146# include "os_detection.h"
147#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
148
145typedef struct _split_shared_memory_t { 149typedef struct _split_shared_memory_t {
146#ifdef USE_I2C 150#ifdef USE_I2C
147 int8_t transaction_id; 151 int8_t transaction_id;
@@ -222,6 +226,10 @@ typedef struct _split_shared_memory_t {
222 uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE]; 226 uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
223 uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE]; 227 uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
224#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) 228#endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
229
230#if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
231 os_variant_t detected_os;
232#endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
225} split_shared_memory_t; 233} split_shared_memory_t;
226 234
227extern split_shared_memory_t *const split_shmem; 235extern split_shared_memory_t *const split_shmem;