I am new to HID devices and creating USB peripherals. As a study project, I created one that uses two joysticks on a single device.
#include <Arduino.h>
#include <USBComposite.h>
const uint8_t reportDescription[] = {
HID_MOUSE_REPORT_DESCRIPTOR(),
HID_KEYBOARD_REPORT_DESCRIPTOR(),
HID_JOYSTICK_REPORT_DESCRIPTOR(),
HID_JOYSTICK_REPORT_DESCRIPTOR(HID_JOYSTICK_REPORT_ID+1),
};
USBCompositeSerial CompositeSerial;
USBHID HID;
HIDJoystick Joystick(HID);
HIDJoystick Joystick2(HID, HID_JOYSTICK_REPORT_ID+1);
void setup(){
// Setup device
HID.begin(CompositeSerial, reportDescription, sizeof(reportDescription));
while (!USBComposite);
Joystick.setManualReportMode(true);
Joystick2.setManualReportMode(true);
}
void loop(){
Joystick.send();
Joystick2.send();
}
This code snippet uses: https://github.com/arpruss/USBComposite_stm32f1 (library)
https://github.com/arpruss/USBComposite_stm32f1/blob/master/examples/twojoysticks/twojoysticks.ino
The problem is that when I try to calibrate them, both joysticks have the same name. Thus many programs in which I want to use this device on lose their settings for each run.
Unfortunately, the solution to manipulate the instance of USBComposite changing it's VendorID and ProductString or manually changing their name in regEdit as is proposed here:
and https://www.stm32duino.com/viewtopic.php?t=624
doesn't work for me, because it again changes the name so that both joysticks have the same one.
