summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keyboard.c16
-rw-r--r--quantum/keyboard.h2
-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.h12
5 files changed, 60 insertions, 5 deletions
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index ec2f2e4496..6e7d40ddc7 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -114,7 +114,7 @@ uint32_t last_input_activity_time(void) {
return last_input_modification_time;
}
uint32_t last_input_activity_elapsed(void) {
- return timer_elapsed32(last_input_modification_time);
+ return sync_timer_elapsed32(last_input_modification_time);
}
static uint32_t last_matrix_modification_time = 0;
@@ -122,10 +122,10 @@ uint32_t last_matrix_activity_time(void) {
return last_matrix_modification_time;
}
uint32_t last_matrix_activity_elapsed(void) {
- return timer_elapsed32(last_matrix_modification_time);
+ return sync_timer_elapsed32(last_matrix_modification_time);
}
void last_matrix_activity_trigger(void) {
- last_matrix_modification_time = last_input_modification_time = timer_read32();
+ last_matrix_modification_time = last_input_modification_time = sync_timer_read32();
}
static uint32_t last_encoder_modification_time = 0;
@@ -133,10 +133,16 @@ uint32_t last_encoder_activity_time(void) {
return last_encoder_modification_time;
}
uint32_t last_encoder_activity_elapsed(void) {
- return timer_elapsed32(last_encoder_modification_time);
+ return sync_timer_elapsed32(last_encoder_modification_time);
}
void last_encoder_activity_trigger(void) {
- last_encoder_modification_time = last_input_modification_time = timer_read32();
+ last_encoder_modification_time = last_input_modification_time = sync_timer_read32();
+}
+
+void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp) {
+ last_matrix_modification_time = matrix_timestamp;
+ last_encoder_modification_time = encoder_timestamp;
+ last_input_modification_time = MAX(matrix_timestamp, encoder_timestamp);
}
// Only enable this if console is enabled to print to
diff --git a/quantum/keyboard.h b/quantum/keyboard.h
index d0b52dd13a..caf0fbd466 100644
--- a/quantum/keyboard.h
+++ b/quantum/keyboard.h
@@ -120,6 +120,8 @@ uint32_t last_matrix_activity_elapsed(void); // Number of milliseconds since the
uint32_t last_encoder_activity_time(void); // Timestamp of the last encoder activity
uint32_t last_encoder_activity_elapsed(void); // Number of milliseconds since the last encoder activity
+void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp); // Set the timestamps of the last matrix and encoder activity
+
uint32_t get_matrix_scan_rate(void);
#ifdef __cplusplus
diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h
index 18d3826b83..4932530aa3 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,
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
index 8e1961b586..ec34bbba60 100644
--- a/quantum/split_common/transactions.c
+++ b/quantum/split_common/transactions.c
@@ -790,6 +790,34 @@ 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();
+ 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);
+}
+
+// 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)
+
////////////////////////////////////////////////////
split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
@@ -818,6 +846,7 @@ split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS] = {
TRANSACTIONS_POINTING_REGISTRATIONS
TRANSACTIONS_WATCHDOG_REGISTRATIONS
TRANSACTIONS_HAPTIC_REGISTRATIONS
+ TRANSACTIONS_ACTIVITY_REGISTRATIONS
// clang-format on
#if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
@@ -846,6 +875,7 @@ 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();
return true;
}
@@ -867,6 +897,7 @@ 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();
}
#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..8f8c38461e 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -122,6 +122,14 @@ 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;
+} 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;
@@ -204,6 +212,10 @@ typedef struct _split_shared_memory_t {
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];