Code:
{
sbus_data_t* c = &controllerState;
for(int i = 0; i < 8; i++)
Joystick.slider(i+1,millis());
Joystick.X(mapAnalog(c->analog[0]));
Joystick.Y(mapAnalog(c->analog[1]));
Joystick.Z(mapAnalog(c->analog[2]));
Joystick.Xrotate(mapAnalog(c->analog[3]));
Joystick.Yrotate(mapAnalog(c->analog[4]));
Joystick.Zrotate(mapAnalog(c->analog[5]));
Joystick.sliderLeft(mapAnalog(c->analog[6]));
Joystick.sliderRight(mapAnalog(c->analog[7]));
Joystick.button(1, c->analog[8] < 0);
Joystick.button(2, c->analog[9] < 0);
Joystick.button(3, c->analog[10] < 0);
Joystick.button(4, c->analog[11] < 0);
Joystick.button(5, c->analog[12] < 0);
Joystick.button(6, c->analog[13] < 0);
Joystick.button(7, c->analog[14] < 0);
Joystick.button(8, c->analog[15] < 0);
Joystick.send_now();
}
usb_joystick.h:
Code:
void X(unsigned int position) { analog16(0, position); }
void Y(unsigned int position) { analog16(1, position); }
void Z(unsigned int position) { analog16(2, position); }
void Xrotate(unsigned int position) { analog16(3, position); }
void Yrotate(unsigned int position) { analog16(4, position); }
void Zrotate(unsigned int position) { analog16(5, position); }
void sliderLeft(unsigned int position) { analog16(6, position); }
void sliderRight(unsigned int position) { analog16(7, position); }
void slider(unsigned int num, unsigned int position) {
if (--num >= 17) return;
analog16(num + 8, position);
usb_desc.c:
Code:
#elif JOYSTICK_SIZE == 64
// extreme joystick (to use this, edit JOYSTICK_SIZE to 64 in usb_desc.h)
// 128 buttons 16
// 6 axes 12
// 17 sliders 34
// 4 pov 2
static uint8_t joystick_report_desc[] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x80, // Report Count (128)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (Button #1)
0x29, 0x20, // Usage Maximum (Button #32)
0x81, 0x02, // Input (variable,absolute)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection ()
0x15, 0x00, // Logical Minimum (0)
0x27, 0xFF, 0xFF, 0, 0, // Logical Maximum (65535)
0x75, 0x10, // Report Size (16)
0x95, 23, // Report Count (23)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x09, 0x33, // Usage (Rx)
0x09, 0x34, // Usage (Ry)
0x09, 0x35, // Usage (Rz)
0x09, 0x36, // Usage (Slider)
0x09, 0x36, // Usage (Slider)
0x81, 0x02, // Input (variable,absolute)
0xC0, // End Collection
0x15, 0x00, // Logical Minimum (0)
0x25, 0x07, // Logical Maximum (7)
0x35, 0x00, // Physical Minimum (0)
0x46, 0x3B, 0x01, // Physical Maximum (315)
0x75, 0x04, // Report Size (4)
0x95, 0x04, // Report Count (4)
0x65, 0x14, // Unit (20)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x39, // Usage (Hat switch)
0x81, 0x42, // Input (variable,absolute,null_state)
0xC0 // End Collection
Where am I doing wrong?