switch-pico/switch2_descriptors.cpp
Joey Yakimowich-Payne 3251e49191 Implement Switch2 descriptors
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-08-11 12:23:07 +09:00

64 lines
2.9 KiB
C++

#include "switch2_descriptors.h"
// Captured Pro Controller 2 descriptors:
// https://github.com/ndeadly/switch2_controller_research/blob/d1c5a7f7ba298f83017fae84952a4e6d2ef8fc92/descriptors.md
const uint8_t switch2_device_descriptor[] = {
0x12, 0x01, 0x00, 0x02, 0xEF, 0x02, 0x01, 0x40, 0x7E,
0x05, 0x69, 0x20, 0x00, 0x02, 0x01, 0x02, 0x03, 0x01,
};
const size_t switch2_device_descriptor_length = sizeof(switch2_device_descriptor);
// The capture has five interfaces and a 268-byte configuration. This explicit
// experimental subset keeps captured HID/vendor interfaces 0-1 only, changes
// wTotalLength to 80 and bNumInterfaces to 2, and zeros uncaptured string
// indices iConfiguration and iInterface. Audio interfaces 2-4 are omitted.
const uint8_t switch2_configuration_descriptor[] = {
0x09, 0x02, 0x50, 0x00, 0x02, 0x01, 0x00, 0xC0, 0xFA,
0x08, 0x0B, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
0x09, 0x04, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00,
0x09, 0x21, 0x11, 0x01, 0x00, 0x01, 0x22, 0x61, 0x00,
0x07, 0x05, 0x81, 0x03, 0x40, 0x00, 0x04,
0x07, 0x05, 0x01, 0x03, 0x40, 0x00, 0x04,
0x08, 0x0B, 0x01, 0x01, 0xFF, 0x00, 0x00, 0x00,
0x09, 0x04, 0x01, 0x00, 0x02, 0xFF, 0x00, 0x00, 0x00,
0x07, 0x05, 0x02, 0x02, 0x40, 0x00, 0x00,
0x07, 0x05, 0x82, 0x02, 0x40, 0x00, 0x00,
};
const size_t switch2_configuration_descriptor_length =
sizeof(switch2_configuration_descriptor);
const uint8_t switch2_hid_report_descriptor[] = {
0x05, 0x01, 0x09, 0x05, 0xA1, 0x01, 0x85, 0x05,
0x05, 0xFF, 0x09, 0x01, 0x15, 0x00, 0x26, 0xFF, 0x00,
0x95, 0x3F, 0x75, 0x08, 0x81, 0x02,
0x85, 0x09, 0x09, 0x01, 0x95, 0x02, 0x81, 0x02,
0x05, 0x09, 0x19, 0x01, 0x29, 0x15, 0x25, 0x01,
0x95, 0x15, 0x75, 0x01, 0x81, 0x02,
0x95, 0x01, 0x75, 0x03, 0x81, 0x03,
0x05, 0x01, 0x09, 0x01, 0xA1, 0x00,
0x09, 0x30, 0x09, 0x31, 0x09, 0x33, 0x09, 0x35,
0x26, 0xFF, 0x0F, 0x95, 0x04, 0x75, 0x0C, 0x81, 0x02, 0xC0,
0x05, 0xFF, 0x09, 0x02, 0x26, 0xFF, 0x00,
0x95, 0x34, 0x75, 0x08, 0x81, 0x02,
0x85, 0x02, 0x09, 0x01, 0x95, 0x3F, 0x91, 0x02, 0xC0,
};
const size_t switch2_hid_report_descriptor_length =
sizeof(switch2_hid_report_descriptor);
const uint8_t switch2_string_language[] = {0x09, 0x04};
const size_t switch2_string_language_length = sizeof(switch2_string_language);
const uint8_t switch2_string_manufacturer[] = "Nintendo";
const size_t switch2_string_manufacturer_length =
sizeof(switch2_string_manufacturer) - 1;
const uint8_t switch2_string_product[] = "Switch 2 Pro Controller";
const size_t switch2_string_product_length = sizeof(switch2_string_product) - 1;
const uint8_t switch2_string_serial[] = "00";
const size_t switch2_string_serial_length = sizeof(switch2_string_serial) - 1;
static_assert(sizeof(switch2_device_descriptor) == 18);
static_assert(sizeof(switch2_configuration_descriptor) == 80);
static_assert(sizeof(switch2_hid_report_descriptor) == 97);