Skip to content

Commit 7088146

Browse files
committed
added static_assert for new consumer key enum
1 parent a39565a commit 7088146

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

klib/usb/device/keyboard.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ namespace klib::usb::device {
206206
key_media_eject = 0xb8,
207207
};
208208

209+
static_assert(sizeof(consumer_key_t) == sizeof(uint16_t), "invalid consumer keys size");
210+
209211
protected:
210212
/**
211213
* @brief Enum with the string descriptor indexes
@@ -272,7 +274,8 @@ namespace klib::usb::device {
272274
.bNumConfigurations = 0x1
273275
};
274276

275-
// report descriptor for the hid keyboard
277+
// report descriptor for the hid keyboard. We need 2 report ids
278+
// so windows recognizes both the keyboard and consumer control
276279
const __attribute__((aligned(4))) static inline uint8_t report_desc[] = {
277280
// Keyboard report (Report ID 1)
278281
0x05, 0x01, // Usage Page (Generic Desktop)
@@ -397,6 +400,7 @@ namespace klib::usb::device {
397400
// fixed report id for the consumer control
398401
const report_id id = report_id::consumer;
399402

403+
// key data
400404
consumer_key_t key;
401405
};
402406

0 commit comments

Comments
 (0)