From 2fc69dee27df0fe911c238d7d3bbb918a038e15d Mon Sep 17 00:00:00 2001 From: Sainan Date: Mon, 26 Aug 2024 13:33:14 +0200 Subject: [PATCH] Add AMC_GET_REALTIME_TRAVEL_ALL --- .../common/analog_matrix/analog_matrix.c | 23 +++++++++++++++++++ .../analog_matrix/analog_matrix_eeconfig.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/keyboards/keychron/common/analog_matrix/analog_matrix.c b/keyboards/keychron/common/analog_matrix/analog_matrix.c index d4e64c0ec3..1b53ce1d4d 100644 --- a/keyboards/keychron/common/analog_matrix/analog_matrix.c +++ b/keyboards/keychron/common/analog_matrix/analog_matrix.c @@ -94,6 +94,7 @@ enum { AMC_SET_GAME_CONTROLLER_MODE, AMC_GET_REALTIME_TRAVEL = 0x30, + AMC_GET_REALTIME_TRAVEL_ALL, AMC_CALIBRATE = 0x40, AMC_GET_CALIBRATE_STATE, @@ -811,6 +812,24 @@ bool get_realtime_travel(uint8_t *data) { return true; } +bool get_realtime_travel_all(uint8_t *data) { + uint8_t i = 2; + + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + for (uint8_t c = 0; c < MATRIX_COLS; c++) { + data[i++] = analog_key_matrix[r][c].travel; + if (i == RAW_EPSIZE) { + // Ran out of space for this chunk. + raw_hid_send(data, RAW_EPSIZE); + i = 2; + memset(&data[2], 0, RAW_EPSIZE - 2); + } + } + } + + return true; +} + void analog_matrix_task(void) { calibrate(); profile_indication_timer_check(); @@ -940,6 +959,10 @@ void analog_matrix_rx(uint8_t *data, uint8_t length) { data[2] = success ? 0 : 1; break; + case AMC_GET_REALTIME_TRAVEL_ALL: + success = get_realtime_travel_all(data); + break; + case AMC_SAVE_PROFILE: success = profile_save(data[2]); data[2] = success ? 0 : 1; diff --git a/keyboards/keychron/common/analog_matrix/analog_matrix_eeconfig.h b/keyboards/keychron/common/analog_matrix/analog_matrix_eeconfig.h index a8fa4c823a..331ad60268 100644 --- a/keyboards/keychron/common/analog_matrix/analog_matrix_eeconfig.h +++ b/keyboards/keychron/common/analog_matrix/analog_matrix_eeconfig.h @@ -30,7 +30,7 @@ #define CURVE_POINTS_COUNT 4 -#define KC_ANALOG_MATRIX_VERSION 0x34340004 +#define KC_ANALOG_MATRIX_VERSION 0x34340005 #define SIZE_OF_CALIB_VALUE_T 3 // Size of calibrated_value_t #define SIZE_OF_ANALOG_KEY_CONFIG_T 4 // Size of analog_key_config_t #define SIZE_OF_OKMC_CONFIG_T 19 // Size of okmc_config_t