mirror of
https://github.com/speedypotato/Pocket-SDVX.git
synced 2026-09-22 22:38:11 +03:00
HID Strings and Konami spoof
This commit is contained in:
+62
-10
@@ -24,6 +24,48 @@ volatile uint16_t iivx_led = 0;
|
||||
|
||||
unsigned long extern reactiveTimeoutCount;
|
||||
|
||||
#if KONAMI_SPOOF == 1
|
||||
const DeviceDescriptor PROGMEM USB_DeviceDescriptorIAD =
|
||||
D_DEVICE(0xEF,0x02,0x01,64,0x1ccf,0x101c,0x100,IMANUFACTURER,IPRODUCT,ISERIAL,1);
|
||||
const char* const PROGMEM String_Manufacturer = "Konami Amusement";
|
||||
const char* const PROGMEM String_Product = "SOUND VOLTEX controller";
|
||||
#else
|
||||
/* HID descriptor strings */
|
||||
const char* const PROGMEM String_Manufacturer = "SpeedyPotato";
|
||||
const char* const PROGMEM String_Product = "Pocket SDVX";
|
||||
#endif
|
||||
const char* const PROGMEM String_Serial = "SDVX";
|
||||
|
||||
const char* const PROGMEM LEDString_00 = "Button A";
|
||||
const char* const PROGMEM LEDString_01 = "Button B";
|
||||
const char* const PROGMEM LEDString_02 = "Button C";
|
||||
const char* const PROGMEM LEDString_03 = "Button D";
|
||||
const char* const PROGMEM LEDString_04 = "Button FX-L";
|
||||
const char* const PROGMEM LEDString_05 = "Button FX-R";
|
||||
const char* const PROGMEM LEDString_06 = "Button Start";
|
||||
|
||||
const char* String_indiv[] = {LEDString_00,LEDString_01,LEDString_02,LEDString_03,LEDString_04,LEDString_05,LEDString_06};
|
||||
uint8_t STRING_ID_Count = 7;
|
||||
|
||||
static bool SendControl(uint8_t d)
|
||||
{
|
||||
return USB_SendControl(0, &d, 1) == 1;
|
||||
}
|
||||
|
||||
static bool USB_SendStringDescriptor(const char *string_P, uint8_t string_len, uint8_t flags) {
|
||||
SendControl(2 + string_len * 2);
|
||||
SendControl(3);
|
||||
bool pgm = flags & TRANSFER_PGM;
|
||||
for(uint8_t i = 0; i < string_len; i++) {
|
||||
bool r = SendControl(pgm ? pgm_read_byte(&string_P[i]) : string_P[i]);
|
||||
r &= SendControl(0); // high byte
|
||||
if(!r) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HID_& HID()
|
||||
{
|
||||
static HID_ obj;
|
||||
@@ -43,6 +85,26 @@ int HID_::getInterface(uint8_t* interfaceCount)
|
||||
|
||||
int HID_::getDescriptor(USBSetup& setup)
|
||||
{
|
||||
#if KONAMI_SPOOF == 1
|
||||
if(setup.wValueH == USB_DEVICE_DESCRIPTOR_TYPE) {
|
||||
return USB_SendControl(TRANSFER_PGM, (const uint8_t*)&USB_DeviceDescriptorIAD, sizeof(USB_DeviceDescriptorIAD));
|
||||
}
|
||||
#endif
|
||||
if (setup.wValueH == USB_STRING_DESCRIPTOR_TYPE) {
|
||||
if (setup.wValueL == IPRODUCT) {
|
||||
return USB_SendStringDescriptor(String_Product, strlen(String_Product), 0);
|
||||
}
|
||||
else if (setup.wValueL == IMANUFACTURER) {
|
||||
return USB_SendStringDescriptor(String_Manufacturer, strlen(String_Manufacturer), 0);
|
||||
}
|
||||
else if (setup.wValueL == ISERIAL) {
|
||||
return USB_SendStringDescriptor(String_Serial, strlen(String_Serial), 0);
|
||||
}
|
||||
else if(setup.wValueL >= STRING_ID_Base && setup.wValueL < (STRING_ID_Base + STRING_ID_Count)) {
|
||||
return USB_SendStringDescriptor(String_indiv[setup.wValueL - STRING_ID_Base], strlen(String_indiv[setup.wValueL - STRING_ID_Base]), 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this is a HID Class Descriptor request
|
||||
if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
|
||||
if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; }
|
||||
@@ -66,16 +128,6 @@ int HID_::getDescriptor(USBSetup& setup)
|
||||
return total;
|
||||
}
|
||||
|
||||
uint8_t HID_::getShortName(char *name)
|
||||
{
|
||||
name[0] = 'H';
|
||||
name[1] = 'I';
|
||||
name[2] = 'D';
|
||||
name[3] = 'A' + (descriptorSize & 0x0F);
|
||||
name[4] = 'A' + ((descriptorSize >> 4) & 0x0F);
|
||||
return 5;
|
||||
}
|
||||
|
||||
void HID_::AppendDescriptor(HIDSubDescriptor *node)
|
||||
{
|
||||
if (!rootNode) {
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
#if defined(USBCON)
|
||||
|
||||
#define KONAMI_SPOOF 1
|
||||
#define STRING_ID_Base 4
|
||||
|
||||
#define _USING_HID
|
||||
|
||||
// HID 'Driver'
|
||||
@@ -100,7 +103,6 @@ protected:
|
||||
int getInterface(uint8_t* interfaceCount);
|
||||
int getDescriptor(USBSetup& setup);
|
||||
bool setup(USBSetup& setup);
|
||||
uint8_t getShortName(char* name);
|
||||
|
||||
private:
|
||||
uint8_t epType[1];
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
|
||||
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
|
||||
0x09, 0x05, /* USAGE (Game Pad) */
|
||||
0x09, 0x04, /* USAGE (Joystick) */
|
||||
0xa1, 0x01, /* COLLECTION (Application) */
|
||||
0x85, 0x04, /* REPORT_ID set to 4 */
|
||||
/*Buttons */
|
||||
@@ -51,7 +51,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0x09, 0x30, /* USAGE (X) */
|
||||
0x09, 0x31, /* USAGE (Y) */
|
||||
0x15, 0x81, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x7f, /* LOGICAL_MAXIMUM (255) */
|
||||
0x25, 0x7f, /* LOGICAL_MAXIMUM (127) */
|
||||
0x95, 0x02, /* REPORT_COUNT (2) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x81, 0x02, /* INPUT (Data,Var,Abs) */
|
||||
@@ -68,6 +68,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x04, /* STRING_INDEX (04) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
@@ -78,6 +79,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x05, /* STRING_INDEX (05) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
@@ -88,6 +90,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x06, /* STRING_INDEX (06) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
@@ -98,6 +101,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x07, /* STRING_INDEX (07) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
@@ -108,6 +112,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x08, /* STRING_INDEX (08) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
@@ -118,6 +123,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x09, /* STRING_INDEX (09) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
@@ -128,6 +134,7 @@ static const uint8_t _hidReportDescriptor[] PROGMEM = {
|
||||
0xa1, 0x02, /* COLLECTION (Logical) */
|
||||
0x05, 0x08, /* USAGE_PAGE (LEDs) */
|
||||
0x09, 0x4b, /* USAGE (Generic Indicator 1) */
|
||||
0x79, 0x0a, /* STRING_INDEX (10) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
|
||||
|
||||
Reference in New Issue
Block a user