Re: Joystick demo endpoint and report size.

345 views
Skip to first unread message

Dean Camera

unread,
Sep 2, 2012, 10:24:34 AM9/2/12
to lufa-s...@googlegroups.com
Hi Lech,

I'm very late replying, but I'm hoping you haven't given up on this.

What you are after should be possible - and should work without further changes as long as you have updated the HID descriptor appropriately. While a report should be able to span multiple USB packets in theory, you may also need to change JOYSTICK_EPSIZE to 16 to ensure that each report is transmitted to the host in a single packet just in case. I see you have tried this - but you may also need to uninstall the device driver fully and reinstall it (or change the product ID in the Device Descriptor) to ensure that Windows re-fetches the device configuration descriptor correctly rather than using a cached copy with the old endpoint bank size.

Can you show what your modified HID report descriptor looks like?

- Dean

On Sunday, August 12, 2012 8:52:27 PM UTC+2, Lech P. wrote:
Hello,

recently I expanded the Joystick class driver demo to support for 6 axes, 12 buttons and POV switch, to the report size total of 8 bytes. All of data acquisition works well already, along with custom HID descriptor. The next thing I'd like to do - is to squeeze some more precision out of the ADC and use 16-bit axis values, but this leads to report size of 14 bytes.

I tried to expand JOYSTICK_EPSIZE to 16 bytes to accomodate report that big, but with no luck. Increasing report size over 8 bytes causes enumeration problem.

Of course data types and report sizes were changed too, based on Dean's joystick descriptor macro.

AFAIK, in the full-speed mode I should be able, in theory, to push 64-byte reports at a time. Maybe I'm missing some part?
What should be done to accomodate for longer reports?

The report struct is:
typedef struct {
        int8_t Axis[6]; // Area for 6 axes: X,Y,Z,U,RX,RY
        uint16_t Buttons :12; // Bit mask of the currently pressed joystick buttons
        uint8_t POV :4; // Current value of hat switch angle
} USB_JoystickReport_Data_t;
Problems arise when int18_t Axis[6] gets changed to int16_t Axis[6], along with the HID descriptor.

Thanks in advance :)

Lech P.

unread,
Sep 20, 2012, 5:06:59 PM9/20/12
to lufa-s...@googlegroups.com
Hello Dean,
In the meantime I managed to find the problem. It was related to field sizes in report structure. In fact, it was a very stupid error Never ever define multiple bitfields in the same line of structure. The joystick now works, and I'm planning to beef it up quite a bit with autocalibration, configuration, programming and built-in keyboard/mouse emulation. When I finish, I'm gonna publish all the sources, together with some PCB layouts. Right now I'm etching replacement specificfor Saitek Cyborg 3D Pad, as the small PCB didn't fit in the back. Unfortunately, I have to finish my master thesis before ;)

Lech P.

unread,
Jan 22, 2013, 10:38:00 AM1/22/13
to lufa-s...@googlegroups.com

I've got a while to get back to the project for a while.
After adding on-board calibration and dead zone features, I've opened up DXTweak2 - and the readouts from axes were very noisy, in state when more than two axes were out of dead zone, i.e. nonzero. When at most 1 axis is tilted, readouts are stable - so I suspect self-sustaining interference from USB bus. I had no room on the board to squeeze in the proper filter for AVCC supply, but filtering potentiometers by capacitors helped a lot. Still, there is something picked up by the wires.

Right now I'm doing readouts during report creation, to minimize latency, using ADC noise reduction mode. Maybe there is better time for that - for example when USB bus is quiet just after device sends a report. Could you suggest a function to put the readouts inside?

I've attached my project source code.
When I add other features, like dual rates, expo curves and button/axis remapping, I'll publish the whole thing as open source.
usb-gamepad.zip

Nevada Smith

unread,
Jun 2, 2014, 5:01:09 PM6/2/14
to lufa-s...@googlegroups.com
Can you please tell my why the endpoints need to be 8,16,32 and 64? I think they must be like this because 17 as endpoint doesnt work for me. If my report is 17 bytes at maximum, should i use 32 then?
I had some really weird problems with that over the time.

Lech P.

unread,
Jun 3, 2014, 3:05:36 PM6/3/14
to lufa-s...@googlegroups.com
According to USB full-speed specification, endpoint sizes must be a power-of-two bytes, just as you stated, probably for simplicity of implementation. If your report is 17 bytes long, you should indeed use 32-byte endpoint size.
Reply all
Reply to author
Forward
0 new messages