From 3e6e3d7993b2f2bc6c8349fa90b380f110ae9ac2 Mon Sep 17 00:00:00 2001 From: Edward Hesketh Date: Sun, 3 Nov 2024 17:43:20 +0000 Subject: [PATCH] fix: attempt 3 --- include/squirrel_split.h | 3 ++- src/squirrel_split.c | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/squirrel_split.h b/include/squirrel_split.h index 25433e3..ebd3188 100644 --- a/include/squirrel_split.h +++ b/include/squirrel_split.h @@ -1,5 +1,6 @@ #pragma once +#include #include // get_packet takes a pointer to a 9-byte array and fills it with the data for @@ -10,6 +11,6 @@ void get_packet(uint8_t (*packet)[9]); // it into the remote_keycodes, remote_modifiers, and remote_consumer_code. void process_packet(uint8_t (*packet)[9]); -extern uint8_t remote_keycodes[6]; +extern bool remote_keycodes[256]; extern uint8_t remote_modifiers; extern uint16_t remote_consumer_code; diff --git a/src/squirrel_split.c b/src/squirrel_split.c index 4b75a69..73b3e3e 100644 --- a/src/squirrel_split.c +++ b/src/squirrel_split.c @@ -16,12 +16,17 @@ void get_packet(uint8_t (*packet)[9]) { (*packet)[8] = consumer >> 8; // 8th byte } -uint8_t remote_keycodes[6] = {0}; +bool remote_keycodes[256] = {false}; uint8_t remote_modifiers = 0; uint16_t remote_consumer_code = 0; void process_packet(uint8_t (*packet)[9]) { - memcpy(remote_keycodes, *packet, 6); // 0th to 5th byte + for (int i = 0; i < 6; i++) { + if ((*packet)[i] == 0) { + break; + } + remote_keycodes[(*packet)[i]] = true; + } remote_modifiers = (*packet)[6]; // 6th byte remote_consumer_code = (*packet)[7] | ((*packet)[8] << 8); // 7th and 8th byte }