From 1fcfe8b594fc6c44760b1f9aaaa429bcda13dfc5 Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Mon, 22 Aug 2016 23:18:47 -0400 Subject: [PATCH] Implement personalities ./wait_then_flash.sh atmega32u2 $HEXFILE --- changelog.txt | 4 ++++ main.c | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 09df626..52ede5c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +- August 22, 2016 : Version 3.2.1 + - Implement N64-only and GC-only personalities (Different product ID and + device name) + - May 22, 2016 : Version 3.2.0 - Fix reconnecting loop in MacOS X - Change gamecube trigger HID usage (Slider became Z). Now it works fine in openEMU. diff --git a/main.c b/main.c index 5f4435a..44f2b3b 100644 --- a/main.c +++ b/main.c @@ -36,6 +36,11 @@ #include "hiddata.h" #include "usbstrings.h" #include "intervaltimer.h" +#include "requests.h" + +#define GCN64_USB_PID 0x001D +#define N64_USB_PID 0x0020 +#define GC_USB_PID 0x0021 /* Those .c files are included rather than linked for we * want the sizeof() operator to work on the arrays */ @@ -126,7 +131,7 @@ static const struct cfg0 cfg0 PROGMEM = { }; -const struct usb_device_descriptor device_descriptor = { +struct usb_device_descriptor device_descriptor = { .bLength = sizeof(struct usb_device_descriptor), .bDescriptorType = DEVICE_DESCRIPTOR, .bcdUSB = 0x0101, @@ -135,7 +140,7 @@ const struct usb_device_descriptor device_descriptor = { .bDeviceProtocol = 0, .bMaxPacketSize = 64, .idVendor = 0x289B, - .idProduct = 0x001D, + .idProduct = GCN64_USB_PID, .bcdDevice = 0x0300, // 1.0.0 .bNumConfigurations = 1, .iManufacturer = 1, @@ -294,6 +299,23 @@ int main(void) usbpad_init(); + switch (g_eeprom_data.cfg.mode) + { + default: + case CFG_MODE_STANDARD: + break; + + case CFG_MODE_N64_ONLY: + usbstrings_changeProductString(L"N64 to USB v"VERSIONSTR_SHORT); + device_descriptor.idProduct = N64_USB_PID; + break; + + case CFG_MODE_GC_ONLY: + usbstrings_changeProductString(L"Gamecube to USB v"VERSIONSTR_SHORT); + device_descriptor.idProduct = GC_USB_PID; + break; + } + sei(); usb_init(&usb_params);