11 years, 5 months ago.

16 bit values for a joystick?

hello Wim,

I hope this is the right place to ask you a question about your joystick class... Is it also possible to send 16bit values instead of 8bit positional values? If so, what modifications are required to the joystick class (or where can I find these specifications..) to modify the code to allow for this?

Regards, rvt

Question relating to:

1 Answer

11 years, 5 months ago.

Hi Ries, I assume you are referring to the USB Joystick library that I posted awhile back. Please comment on this page: http://mbed.org/users/wim/notebook/usb-joystick-device/#

Back to your question: It should be possible to modify the library for 16bit values. You will need to change the update methods and the report descriptor. There is a commented example for 16bit x- and y values in the code published here:

http://mbed.org/users/wim/code/USBJoystick_HelloWorld/file/5037d4be5b6d/USBJoystick.cpp

uint8_t * USBJoystick::reportDesc() {    
         static uint8_t reportDescriptor[] = {

....

               COLLECTION(1), 0x00,            // Physical
                 USAGE(1), 0x30,                 // X
                 USAGE(1), 0x31,                 // Y
//  8 bit values
                 LOGICAL_MINIMUM(1), 0x81,       // -127
                 LOGICAL_MAXIMUM(1), 0x7f,       // 127
                 REPORT_SIZE(1), 0x08,
                 REPORT_COUNT(1), 0x02,
                 INPUT(1), 0x02,                 // Data, Variable, Absolute                  
// 16 bit values example
//                 LOGICAL_MINIMUM(1), 0x00,       // 0
//                 LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767
//                 REPORT_SIZE(1), 0x10,
//                 REPORT_COUNT(1), 0x02,
//                 INPUT(1), 0x02,                 // Data, Variable, Absolute                

....

The reference articles on the joystick page provide more background info on the meaning of the descriptor fields.

Accepted Answer