From 0cdb97c71d13b18298eac548a68a552c93c3ad56 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 22 Nov 2023 17:39:45 +0700 Subject: [PATCH] fix: prevents outbound pairing sequences --- quantum/oryx.c | 10 +++++----- quantum/oryx.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/quantum/oryx.c b/quantum/oryx.c index a56ba39bf4a1..7e5f4b883b2f 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -18,10 +18,10 @@ void oryx_error(uint8_t code) { void get_pairing_code(keypos_t positions[], int size) { const char *version = FIRMWARE_VERSION; - // Initialize all positions to {0, 0} + // Initialize all positions to {1, 1} for (int i = 0; i < size; ++i) { - positions[i].col = 0; - positions[i].row = 0; + positions[i].col = 1; + positions[i].row = 1; } // Find the position of '/' @@ -30,8 +30,8 @@ void get_pairing_code(keypos_t positions[], int size) { max_index = (max_index / 2 < size) ? max_index / 2 : size; for (int i = 0; i < max_index; ++i) { - positions[i].col = version[i * 2] % 4; - positions[i].row = version[i * 2 + 1] % 4; + positions[i].col = version[i * 2] % ORYX_PAIRING_MAX_INDEX + 1; + positions[i].row = version[i * 2 + 1] % ORYX_PAIRING_MAX_INDEX + 1; } } diff --git a/quantum/oryx.h b/quantum/oryx.h index 1785d3579070..61fa15ab238f 100644 --- a/quantum/oryx.h +++ b/quantum/oryx.h @@ -23,6 +23,7 @@ Once the host has paired, it can freely use the commands define in the Oryx_Comm #define ORYX_PROTOCOL_VERSION = 0x01 #define ORYX_STOP_BIT -2 +#define ORYX_PAIRING_MAX_INDEX 3 #define PAIRING_BLINK_STEPS 512 #define PAIRING_BLINK_END PAIRING_BLINK_STEPS * 60 #define PAIRING_SEQUENCE_SIZE 3