reorg
This commit is contained in:
33
firmware/modularkbd/Core/Inc/hid_queue.h
Normal file
33
firmware/modularkbd/Core/Inc/hid_queue.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef HID_QUEUE_H
|
||||||
|
#define HID_QUEUE_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t MODIFIER; // Modifier keys (Ctrl, Shift, Alt, Win)
|
||||||
|
uint8_t RESERVED; // Always 0
|
||||||
|
uint8_t KEYPRESS[12]; // Up to 12 keycodes
|
||||||
|
} __attribute__((packed)) HIDReport;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
HIDReport *buffer;
|
||||||
|
uint16_t capacity;
|
||||||
|
uint16_t head;
|
||||||
|
uint16_t tail;
|
||||||
|
uint16_t count;
|
||||||
|
} HIDQueue;
|
||||||
|
|
||||||
|
// Init + reset
|
||||||
|
bool hid_queue_init(HIDQueue *q, HIDReport *buffer, uint16_t capacity);
|
||||||
|
void hid_queue_reset(HIDQueue *q);
|
||||||
|
|
||||||
|
// FIFO Ops
|
||||||
|
bool hid_queue_push(HIDQueue *q, HIDReport item);
|
||||||
|
bool hid_queue_pop(HIDQueue *q, HIDReport *out);
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
bool hid_queue_is_empty(HIDQueue *q);
|
||||||
|
bool hid_queue_is_full(HIDQueue *q);
|
||||||
|
|
||||||
|
#endif
|
||||||
55
firmware/modularkbd/Core/Src/hid_queue.c
Normal file
55
firmware/modularkbd/Core/Src/hid_queue.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include "hid_queue.h"
|
||||||
|
|
||||||
|
bool hid_queue_init(HIDQueue *q, HIDReport *buffer, uint16_t capacity) {
|
||||||
|
if (!q || !buffer || capacity == 0) return false;
|
||||||
|
|
||||||
|
q->buffer = buffer;
|
||||||
|
q->capacity = capacity;
|
||||||
|
q->head = 0;
|
||||||
|
q->tail = 0;
|
||||||
|
q->count = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hid_queue_reset(HIDQueue *q) {
|
||||||
|
if (!q) return;
|
||||||
|
q->head = 0;
|
||||||
|
q->tail = 0;
|
||||||
|
q->count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hid_queue_is_empty(HIDQueue *q) {
|
||||||
|
return q->count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hid_queue_is_full(HIDQueue *q) {
|
||||||
|
return q->count == q->capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hid_queue_push(HIDQueue *q, HIDReport item) {
|
||||||
|
if (hid_queue_is_full(q)) {
|
||||||
|
return false; // Queue full (no more shelves for potions!) (;ω;)
|
||||||
|
}
|
||||||
|
|
||||||
|
q->buffer[q->tail] = item;
|
||||||
|
q->tail = (q->tail + 1) % q->capacity;
|
||||||
|
q->count++;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hid_queue_pop(HIDQueue *q, HIDReport *out) {
|
||||||
|
if (hid_queue_is_empty(q)) {
|
||||||
|
return false; // Nothing to dequeue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out) {
|
||||||
|
*out = q->buffer[q->head];
|
||||||
|
}
|
||||||
|
|
||||||
|
q->head = (q->head + 1) % q->capacity;
|
||||||
|
q->count--;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
6
firmware/modularkbd/Debug/Core/Src/hid_queue.cyclo
Normal file
6
firmware/modularkbd/Debug/Core/Src/hid_queue.cyclo
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
../Core/Src/hid_queue.c:3:6:hid_queue_init 4
|
||||||
|
../Core/Src/hid_queue.c:15:6:hid_queue_reset 2
|
||||||
|
../Core/Src/hid_queue.c:22:6:hid_queue_is_empty 1
|
||||||
|
../Core/Src/hid_queue.c:26:6:hid_queue_is_full 1
|
||||||
|
../Core/Src/hid_queue.c:30:6:hid_queue_push 2
|
||||||
|
../Core/Src/hid_queue.c:42:6:hid_queue_pop 3
|
||||||
2
firmware/modularkbd/Debug/Core/Src/hid_queue.d
Normal file
2
firmware/modularkbd/Debug/Core/Src/hid_queue.d
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Core/Src/hid_queue.o: ../Core/Src/hid_queue.c ../Core/Inc/hid_queue.h
|
||||||
|
../Core/Inc/hid_queue.h:
|
||||||
BIN
firmware/modularkbd/Debug/Core/Src/hid_queue.o
Normal file
BIN
firmware/modularkbd/Debug/Core/Src/hid_queue.o
Normal file
Binary file not shown.
6
firmware/modularkbd/Debug/Core/Src/hid_queue.su
Normal file
6
firmware/modularkbd/Debug/Core/Src/hid_queue.su
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
../Core/Src/hid_queue.c:3:6:hid_queue_init 24 static
|
||||||
|
../Core/Src/hid_queue.c:15:6:hid_queue_reset 16 static
|
||||||
|
../Core/Src/hid_queue.c:22:6:hid_queue_is_empty 16 static
|
||||||
|
../Core/Src/hid_queue.c:26:6:hid_queue_is_full 16 static
|
||||||
|
../Core/Src/hid_queue.c:30:6:hid_queue_push 24 static
|
||||||
|
../Core/Src/hid_queue.c:42:6:hid_queue_pop 24 static
|
||||||
BIN
hardware/3d models/67 percent/67PhoBottomCase.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/67PhoBottomCase.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/67PhoCaseBottom.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/67PhoCaseBottom.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/67PhoCaseBottomRIght.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/67PhoCaseBottomRIght.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/67PhoPlate.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/67PhoPlate.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/67plate.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/67plate.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/AssPho_PlateNLeftNRight.SLDASM
Normal file
BIN
hardware/3d models/67 percent/AssPho_PlateNLeftNRight.SLDASM
Normal file
Binary file not shown.
Binary file not shown.
BIN
hardware/3d models/67 percent/numpadBottom.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/numpadBottom.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/numpadBottom.STL
Normal file
BIN
hardware/3d models/67 percent/numpadBottom.STL
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/numpadTop.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/numpadTop.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/numpadTop.STL
Normal file
BIN
hardware/3d models/67 percent/numpadTop.STL
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/~$numpadBottom.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/~$numpadBottom.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/67 percent/~$numpadTop.SLDPRT
Normal file
BIN
hardware/3d models/67 percent/~$numpadTop.SLDPRT
Normal file
Binary file not shown.
BIN
hardware/3d models/old numpad/bottomnumpad.stl
Normal file
BIN
hardware/3d models/old numpad/bottomnumpad.stl
Normal file
Binary file not shown.
BIN
hardware/3d models/old numpad/test.FCStd
Normal file
BIN
hardware/3d models/old numpad/test.FCStd
Normal file
Binary file not shown.
BIN
hardware/3d models/old numpad/topnumpad.stl
Normal file
BIN
hardware/3d models/old numpad/topnumpad.stl
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user