4#include <usb-hid/keyboard.hpp>
18 USBInterruptPipe* pipe = (USBInterruptPipe*)
dev_->pipe;
20 auto desc = (
struct USBInterruptPipeDesc){
21 .dev_addr = dev_->addr,
22 .endpoint = (
uint8_t)(dev_->endpoints[0].address & 0xF),
24 .interval_ms = dev_->endpoints[0].interval,
30#pragma clang diagnostic push
31#pragma clang diagnostic ignored "-Wc99-designator"
94#pragma clang diagnostic pop
101 static uint8_t last_modifier = 0;
107 for (
int i = 0; i < 8; i++) {
108 bool current = (modifier >> i) & 1;
109 bool last = (last_modifier >> i) & 1;
112 mod_keys[i], current ? 1 : 0);
114 last_modifier = modifier;
116 static uint8_t prev_keys[6] = {0};
120 for (
int i = 0; i < 6; i++)
121 current_keys[i] =
data[i + 2];
124 for (
int i = 0; i < 6; i++) {
126 if (key == 0)
continue;
128 bool still_held =
false;
129 for (
int j = 0; j < 6; j++) {
130 if (key == current_keys[j]) { still_held =
true;
break; }
140 bool any_new =
false;
141 bool any_held =
false;
142 for (
int i = 0; i < 6; i++) {
144 if (key == 0)
continue;
147 for (
int j = 0; j < 6; j++) {
148 if (key == prev_keys[j]) { is_new =
false;
break; }
163 if (!any_new && any_held) {
166 static constexpr uint32_t REPEAT_DELAY = 5;
167 static constexpr uint32_t REPEAT_PERIOD = 3;
169 bool do_repeat =
false;
170 if (held_count == REPEAT_DELAY)
172 else if (held_count > REPEAT_DELAY &&
173 (held_count - REPEAT_DELAY) % REPEAT_PERIOD == 0)
177 for (
int i = 0; i < 6; i++) {
179 if (key == 0)
continue;
186 }
else if (any_new) {
188 }
else if (!any_held) {
192 for (
int i = 0; i < 6; i++)
193 prev_keys[i] = current_keys[i];
static AHCIModule instance
struct ioforge_pci_device * dev_
ioforge_usb_device * dev_
void load(ioforge_usb_device *dev)
void parse_report(const uint8_t *data, size_t len)
static void fireHandler(const uint8_t *data, size_t len)
static const uint16_t hid_keymap[256]