Skip to content

Commit

Permalink
fix: attempt 3
Browse files Browse the repository at this point in the history
  • Loading branch information
headblockhead committed Nov 3, 2024
1 parent 4d6131e commit 3e6e3d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/squirrel_split.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <stdbool.h>
#include <stdint.h>

// get_packet takes a pointer to a 9-byte array and fills it with the data for
Expand All @@ -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;
9 changes: 7 additions & 2 deletions src/squirrel_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 3e6e3d7

Please sign in to comment.