Page 1 of 1

Joystick axis not updating properly.

Posted: Mon Feb 09, 2015 5:13 am
by jdwix
Okay, so I have and Atmega328p running on my own board with seven buttons and two axis set up.
Here is the report descriptor I am using.

Code: Select all

PROGMEM const char usbHidReportDescriptor[43]= {
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x04,                    // USAGE (Joystick)
    0xa1, 0x01,                    // COLLECTION (Application)
    0xa1, 0x00,                    //   COLLECTION (Physical)
    0x09, 0x32,                    //     USAGE (Z)
    0x09, 0x34,                    //     USAGE (Ry)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //     LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //     REPORT_SIZE (8)
    0x95, 0x02,                    //     REPORT_COUNT (2)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x29, 0x07,                    //     USAGE_MAXIMUM (Button 7)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x95, 0x08,                    //     REPORT_COUNT (8)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0xc0,                          //     END_COLLECTION
    0xc0,                           // END_COLLECTION

 };


While viewing the properties for the device in windows I can see all seven buttons and the two axis but only the buttons seem to respond to being pressed. If I move either axis it does not seem to update. However, using a usb sniffer I can see that all the necessary data is sent through. Also if I just send through either 0 or 255 to the axis (max and min) they adjust appropriately, but no other value seems to work.

What am I doing wrong?

Re: Joystick axis not updating properly.

Posted: Wed Feb 11, 2015 4:56 pm
by ulao
Try.

Code: Select all

PROGMEM const char usbHidReportDescriptor[43]= {
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x04,                    // USAGE (Joystick)
    0xa1, 0x01,                    // COLLECTION (Application)]
0x09, 0x01,                    //     usage pointer
    0xa1, 0x00,                    //   COLLECTION (Physical)
0x05, 0x01,                    // USAGE_PAGE (Generic desktop)
    0x09, 0x32,                    //     USAGE (Z)
    0x09, 0x34,                    //     USAGE (Ry)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //     LOGICAL_MAXIMUM (255)
0x35, 0x00,                    //     Physical Minimum (0)
0x46, 0xFF, 0x00,              //     Physical MAXIMUM (255)
    0x75, 0x08,                    //     REPORT_SIZE (8)
    0x95, 0x02,                    //     REPORT_COUNT (2)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0x05, 0x09,                    //     USAGE_PAGE (Button)
    0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
    0x29, 0x07,                    //     USAGE_MAXIMUM (Button 7)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    //     REPORT_SIZE (1)
    0x95, 0x08,                    //     REPORT_COUNT (8)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0xc0,                          //     END_COLLECTION
    0xc0,                           // END_COLLECTION

 };

You may not need all of those but I bet its because you are missing some of them, my guess is the Physical parts.

Re: Joystick axis not updating properly.

Posted: Thu Feb 12, 2015 9:53 am
by blargg
Maybe unrelated, but why are you having the two axes be Z and Ry, rather than X and Y?