-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add split keyboard functionality
TODO: add tests, fix bugs, etc.
- Loading branch information
1 parent
b225f99
commit 55f3092
Showing
8 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#ifndef SQUIRREL_INIT_H | ||
#define SQUIRREL_INIT_H | ||
#pragma once | ||
|
||
enum squirrel_error | ||
squirrel_init(void); // Initialize the keyboard with the total number of keys. | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
// get_packet takes a pointer to a 9-byte array and fills it with the data for | ||
// the packet to be sent. | ||
void get_packet(uint8_t (*packet)[9]); | ||
|
||
extern uint8_t remote_keycodes[6]; | ||
extern uint8_t remote_modifiers; | ||
extern uint16_t remote_consumer_code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "squirrel_split.h" | ||
#include "squirrel.h" | ||
#include "squirrel_consumer.h" | ||
#include "squirrel_keyboard.h" | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
void get_packet(uint8_t (*packet)[9]) { | ||
memset(*packet, 0, 9); | ||
uint8_t local_keycodes[6] = {0}; | ||
keyboard_get_local_keycodes(&local_keycodes); | ||
memcpy(packet, local_keycodes, 6); // 0th to 5th byte | ||
(*packet)[6] = keyboard_get_local_modifiers(); // 6th byte | ||
uint16_t consumer = consumer_get_local_consumer_code(); | ||
(*packet)[7] = consumer & 0xFF; // 7th byte | ||
(*packet)[8] = consumer >> 8; // 8th byte | ||
} | ||
|
||
uint8_t remote_keycodes[6] = {0}; | ||
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 | ||
remote_modifiers = (*packet)[6]; // 6th byte | ||
remote_consumer_code = (*packet)[7] | ((*packet)[8] << 8); // 7th and 8th byte | ||
} |