Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Noppoo HID descriptors, original and modified with MacOS support.
#include <stdio.h>
#include <stdint.h>
#include "HIDReportData.h"
const uint8_t standard_descriptor_primary[] = {
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x06),
HID_RI_COLLECTION(8, 0x01),
HID_RI_USAGE_PAGE(8, 0x08),
HID_RI_USAGE_MINIMUM(8, 0x01),
HID_RI_USAGE_MAXIMUM(8, 0x03),
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_OUTPUT(8, HID_IOF_VARIABLE),
HID_RI_REPORT_COUNT(8, 0x05),
HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
HID_RI_USAGE_PAGE(8, 0x07),
HID_RI_USAGE_MINIMUM(8, 224),
HID_RI_USAGE_MAXIMUM(8, 231),
HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 4),
HID_RI_USAGE_MAXIMUM(8, 40),
HID_RI_USAGE(8, 0x4f),
HID_RI_USAGE(8, 0x50),
HID_RI_USAGE(8, 0x2b),
HID_RI_USAGE(8, 0x2c),
HID_RI_USAGE(8, 0x51),
HID_RI_USAGE(8, 0x52),
HID_RI_REPORT_COUNT(8, 43),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE(8, 0x53),
HID_RI_REPORT_COUNT(8, 1),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 89),
HID_RI_USAGE_MAXIMUM(8, 100),
HID_RI_REPORT_COUNT(8, 12),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_END_COLLECTION(0),
};
const uint8_t new_descriptor_primary[] = {
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x06),
HID_RI_COLLECTION(8, 0x01),
HID_RI_USAGE_PAGE(8, 0x08),
HID_RI_USAGE_MINIMUM(8, 0x01),
HID_RI_USAGE_MAXIMUM(8, 0x03),
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_OUTPUT(8, HID_IOF_VARIABLE),
HID_RI_REPORT_COUNT(8, 0x05),
HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
HID_RI_USAGE_PAGE(8, 0x07),
HID_RI_USAGE_MINIMUM(8, 224),
HID_RI_USAGE_MAXIMUM(8, 231),
HID_RI_REPORT_COUNT(8, 0x08),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 4),
HID_RI_USAGE_MAXIMUM(8, 40),
HID_RI_REPORT_COUNT(8, 43 - 6),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE(8, 0x4f),
HID_RI_USAGE(8, 0x50),
HID_RI_USAGE(8, 0x2b),
HID_RI_USAGE(8, 0x2c),
HID_RI_USAGE(8, 0x51),
HID_RI_USAGE(8, 0x52),
HID_RI_USAGE(8, 0x53),
HID_RI_REPORT_COUNT(8, 1 + 6),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 89),
HID_RI_USAGE_MAXIMUM(8, 100),
HID_RI_REPORT_COUNT(8, 12),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_END_COLLECTION(0),
};
const uint8_t standard_descriptor_secondary[] = {
HID_RI_USAGE_PAGE(8, 0x0C),
HID_RI_USAGE(8, 0x01),
HID_RI_COLLECTION(8, 0x01),
HID_RI_REPORT_ID(8, 0x01),
HID_RI_USAGE_MINIMUM(8, 0),
HID_RI_USAGE_MAXIMUM(16, 572),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(16, 572),
HID_RI_REPORT_COUNT(8, 1),
HID_RI_REPORT_SIZE(8, 16),
HID_RI_INPUT(8, 0),
HID_RI_END_COLLECTION(0, 0),
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x80),
HID_RI_COLLECTION(8, 0x01),
HID_RI_REPORT_ID(8, 2),
HID_RI_USAGE_MINIMUM(8, 129),
HID_RI_USAGE_MAXIMUM(8, 131),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_REPORT_SIZE(8, 1),
HID_RI_REPORT_COUNT(8, 3),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_REPORT_COUNT(8, 5),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
HID_RI_END_COLLECTION(0, 0),
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x06),
HID_RI_COLLECTION(8, 0x01),
HID_RI_REPORT_ID(8, 0x03),
HID_RI_USAGE_PAGE(8, 0x07),
HID_RI_USAGE_MINIMUM(8, 60),
HID_RI_USAGE_MAXIMUM(8, 78),
HID_RI_USAGE(8, 0x29),
HID_RI_USAGE(8, 0x2a),
HID_RI_USAGE(8, 0x2d),
HID_RI_USAGE(8, 0x2e),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 23),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 83),
HID_RI_USAGE_MAXIMUM(8, 88),
HID_RI_REPORT_COUNT(8, 6),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 48),
HID_RI_USAGE_MAXIMUM(8, 59),
HID_RI_REPORT_COUNT(8, 12),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 133),
HID_RI_USAGE_MAXIMUM(8, 139),
HID_RI_REPORT_COUNT(8, 7),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 144),
HID_RI_USAGE_MAXIMUM(8, 150),
HID_RI_REPORT_COUNT(8, 6),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE(8, 0x65),
HID_RI_USAGE(8, 0x2f),
HID_RI_REPORT_COUNT(8, 2),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_END_COLLECTION(0),
};
const uint8_t new_descriptor_secondary[] = {
HID_RI_USAGE_PAGE(8, 0x0C),
HID_RI_USAGE(8, 0x01),
HID_RI_COLLECTION(8, 0x01),
HID_RI_REPORT_ID(8, 0x01),
HID_RI_USAGE_MINIMUM(8, 0),
HID_RI_USAGE_MAXIMUM(16, 572),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(16, 572),
HID_RI_REPORT_COUNT(8, 1),
HID_RI_REPORT_SIZE(8, 16),
HID_RI_INPUT(8, 0),
HID_RI_END_COLLECTION(0, 0),
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x80),
HID_RI_COLLECTION(8, 0x01),
HID_RI_REPORT_ID(8, 2),
HID_RI_USAGE_MINIMUM(8, 129),
HID_RI_USAGE_MAXIMUM(8, 131),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_REPORT_SIZE(8, 1),
HID_RI_REPORT_COUNT(8, 3),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_REPORT_COUNT(8, 5),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
HID_RI_END_COLLECTION(0, 0),
HID_RI_USAGE_PAGE(8, 0x01),
HID_RI_USAGE(8, 0x06),
HID_RI_COLLECTION(8, 0x01),
HID_RI_REPORT_ID(8, 0x03),
HID_RI_USAGE_PAGE(8, 0x07),
HID_RI_USAGE_MINIMUM(8, 60),
HID_RI_USAGE_MAXIMUM(8, 78),
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_REPORT_COUNT(8, 23 - 4),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE(8, 0x29),
HID_RI_USAGE(8, 0x2a),
HID_RI_USAGE(8, 0x2d),
HID_RI_USAGE(8, 0x2e),
HID_RI_REPORT_COUNT(8, 4),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 83),
HID_RI_USAGE_MAXIMUM(8, 88),
HID_RI_REPORT_COUNT(8, 6),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 48),
HID_RI_USAGE_MAXIMUM(8, 59),
HID_RI_REPORT_COUNT(8, 12),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 133),
HID_RI_USAGE_MAXIMUM(8, 139),
HID_RI_REPORT_COUNT(8, 7),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE_MINIMUM(8, 144),
HID_RI_USAGE_MAXIMUM(8, 150),
HID_RI_REPORT_COUNT(8, 6),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_USAGE(8, 0x65),
HID_RI_USAGE(8, 0x2f),
HID_RI_REPORT_COUNT(8, 2),
HID_RI_INPUT(8, HID_IOF_VARIABLE),
HID_RI_END_COLLECTION(0),
};
static void pp_descriptor(const uint8_t *descriptor, size_t len) {
const uint8_t *end = descriptor + len;
const uint8_t *p = descriptor;
int i;
printf("<\n");
while (p < end) {
for (i = 0; i < 8 && p < end; i++) {
printf("%.2x ", *p++);
}
for (i = 0; i < 8 && p < end; i++) {
printf(" %.2x", *p++);
}
printf("\n");
}
printf(">\n");
}
int main() {
printf("standard descriptor (primary):\n");
pp_descriptor(standard_descriptor_primary, sizeof(standard_descriptor_primary));
printf("\n");
printf("modified descriptor (primary):\n");
pp_descriptor(new_descriptor_primary, sizeof(new_descriptor_primary));
printf("\n");
printf("standard descriptor (secondary):\n");
pp_descriptor(standard_descriptor_secondary, sizeof(standard_descriptor_secondary));
printf("\n");
printf("new descriptor (secondary):\n");
pp_descriptor(new_descriptor_secondary, sizeof(new_descriptor_secondary));
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment