summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Didron <0x6664@hey.com>2022-06-22 10:32:32 +0900
committerFlorian Didron <0x6664@hey.com>2022-06-22 10:32:32 +0900
commitd54c6c6b149dbd133669557ee2c5b110e2ee8df9 (patch)
tree1d76586f7eba721065f17ef39ad9c7f20a48d260
parent939bcc54225c54d6f698e2d8d4a395163a837a1d (diff)
fix: pairing crash on Ergodox
-rw-r--r--quantum/oryx.c19
-rw-r--r--quantum/oryx.h3
2 files changed, 16 insertions, 6 deletions
diff --git a/quantum/oryx.c b/quantum/oryx.c
index 080846b38f..58b5d5c626 100644
--- a/quantum/oryx.c
+++ b/quantum/oryx.c
@@ -105,19 +105,26 @@ void pairing_init_handler(void) {
raw_hid_send(event, RAW_EPSIZE);
}
-void pairing_validate_handler() {
- bool valid = true;
- uint8_t event[RAW_EPSIZE];
+bool compare_sequences(keypos_t a[PAIRING_SEQUENCE_SIZE], keypos_t b[PAIRING_SEQUENCE_SIZE]) {
+ bool valid = true;
for (uint8_t i = 0; i < PAIRING_SEQUENCE_SIZE; i++) {
- if (keyboard_pairing_sequence[i].row != host_pairing_sequence[i].row) {
+ if (a[i].row != b[i].row) {
valid = false;
break;
}
- if (keyboard_pairing_sequence[i].col != host_pairing_sequence[i].col) {
+ if (a[i].col != b[i].col) {
valid = false;
break;
}
}
+ return valid;
+}
+
+void pairing_validate_handler() {
+
+ uint8_t event[RAW_EPSIZE];
+ bool valid = compare_sequences(keyboard_pairing_sequence, host_pairing_sequence);
+
if (valid == true) {
event[0] = ORYX_EVT_PAIRING_SUCCESS;
rawhid_state.paired = true;
@@ -126,6 +133,7 @@ void pairing_validate_handler() {
event[0] = ORYX_EVT_PAIRING_FAILED;
rawhid_state.paired = false;
}
+
event[1] = ORYX_STOP_BIT;
rawhid_state.pairing = false;
raw_hid_send(event, sizeof(event));
@@ -177,6 +185,7 @@ bool process_record_oryx(uint16_t keycode, keyrecord_t *record) {
host_pairing_sequence[pairing_input_index++] = record->event.key;
pairing_key_input_event();
}
+ wait_ms(1000);
if (pairing_input_index == PAIRING_SEQUENCE_SIZE) {
rawhid_state.pairing = false;
pairing_input_index = 0;
diff --git a/quantum/oryx.h b/quantum/oryx.h
index 1deae0765d..526299b4aa 100644
--- a/quantum/oryx.h
+++ b/quantum/oryx.h
@@ -14,7 +14,7 @@
#define PAIRING_BLINK_STEPS 512
#define PAIRING_BLINK_END PAIRING_BLINK_STEPS * 60
#define PAIRING_SEQUENCE_SIZE 3
-#define PAIRING_SEQUENCE_NUM_STORED 5
+#define PAIRING_SEQUENCE_NUM_STORED 3
#define PAIRING_STORAGE_SIZE PAIRING_SEQUENCE_SIZE* PAIRING_SEQUENCE_NUM_STORED * sizeof(uint16_t)
enum Oryx_Command_Code {
@@ -52,6 +52,7 @@ void pairing_init_handler(void);
void pairing_validate_handler(void);
void pairing_validate_eeprom_handler(void);
void pairing_init_event(void);
+bool compare_sequences(keypos_t a[PAIRING_SEQUENCE_SIZE], keypos_t b[PAIRING_SEQUENCE_SIZE]);
void pairing_key_input_event(void);
void pairing_failed_event(void);
void pairing_succesful_event(void);