I am using this project to use my controller.
Now the computer sees the Arduino as 2 devices. One device has 128 buttons and 8 axes. The second one has 128 buttons and no axes. I would like to add an additional 8 axes to the second device.
In descriptors.c I added:
0x09, 0x01, /* Usage (Pointer) */
/* 8 axes, signed 16 bit resolution, the actualy resolution is still 10 bit range 0~65535 */
0xa1, 0x00, /* Collection (Physical) */
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x30, /* Usage (X) */
0x09, 0x31, /* Usage (Y) */
0x09, 0x32, /* Usage (Analog1) */
0x09, 0x33, /* Usage (Analog2) */
0x09, 0x34, /* Usage (Analog3) */
0x09, 0x35, /* Usage (Analog4) */
0x09, 0x36, /* Usage (Analog5) */
0x09, 0x37, /* Usage (Analog6) */
0x27, 0xff, 0xff, 0x00, 0x00, /* Logical Maximum (65535) */
0x47, 0xff, 0xff, 0x00, 0x00, /* Physical Maximum (65535) */
0x75, 16, /* Report Size (16) */
0x95, 8, /* Report Count (8) */
0x81, 0x82, /* Input (Data, Variable, Absolute, Volatile) */
0xc0, /* End Collection */
In Arduino-joystick.h in typedef struct Joystick2 int16_t axis[8];
typedef struct {
int16_t axis[8];
uint8_t button[16]; // each byte represent 8 button state
} USB_Joystick2Report_Data_t;
In the library I changed it define NUM_AXES 8 to define NUM_AXES 16
and
for (uint8_t ind=0; ind< NUM_AXES; ind++) {
joyReport.axis[ind] = analogRead(54+ind) << 6;
I tried manually running additional axes
joyReport.axis[0] = analogRead(A0) << 6;
joyReport.axis[1] = analogRead(A1) << 6;
but when I want to add 9 axes
joyReport.axis[8] = analogRead(A8) << 6;
They still do not respond to changes in the potentiometer. The only thing that changes is that the buttons turn on themselves. I've been looking for a solution to my problem for a long time, but I haven't found anything. Maybe someone could help me or tell me what else to do.
I hope I added this in the right section. Thank you in advance.