Joystick axis not updating properly.

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
jdwix
Posts: 1
Joined: Mon Feb 09, 2015 5:07 am

Joystick axis not updating properly.

Post by jdwix » Mon Feb 09, 2015 5:13 am

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?

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: Joystick axis not updating properly.

Post by ulao » Wed Feb 11, 2015 4:56 pm

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.

blargg
Rank 3
Rank 3
Posts: 102
Joined: Thu Nov 14, 2013 10:01 pm

Re: Joystick axis not updating properly.

Post by blargg » Thu Feb 12, 2015 9:53 am

Maybe unrelated, but why are you having the two axes be Z and Ry, rather than X and Y?

Post Reply