Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AMC_GET_REALTIME_TRAVEL_ALL #301

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions keyboards/keychron/common/analog_matrix/analog_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -786,6 +787,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();
Expand Down Expand Up @@ -899,6 +918,10 @@ void analog_matrix_rx(uint8_t *data, uint8_t length) {
success = get_realtime_travel(&data[2]);
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#define CURVE_POINTS_COUNT 4

#define KC_ANALOG_MATRIX_VERSION 0x34340002
#define KC_ANALOG_MATRIX_VERSION 0x34340003
#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
Expand Down
Loading