2018-06-10 06:54 AM
Hello,
i want to use an accelerometer as an joystick over USB. My problem is, that all Tutorials on Youtube are not in english. So i can´t understand the important explanations. Alle tutorials not on Youtube are almost not complete, old or use Arduino stuff with ready to use Hard an Software.
As accelerometer i am using the ST LSM6DS33 with STM32F072 Discovery. As software the CubeMX-SW4STM32(Eclipse) toolchain.
With the (Non Custom) HID USB the accelerometer is working fine....but as an mouse. I need it as joystick. I used that tutorial until step 3.
For building the dicriptor i used that (i want to make small steps, thats why it is an mouse discriptor)
http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/
And add this under usbd_custom_hid_if.c, showed in that video:
https://www.youtube.com/watch?v=xufZyQf4O7Y
Now it looks like that:
__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{ /* USER CODE BEGIN 0 */ 0x05, 0x01,// USAGE_PAGE (Generic Desktop) 0x09, 0x02,//USAGE (Mouse) 0xa1, 0x01,// COLLECTION (Application) 0x09, 0x01,// USAGE (Pointer) 0xa1, 0x00,// COLLECTION (Physical) 0x05, 0x09,// USAGE_PAGE (Button) 0x19, 0x01,// USAGE_MINIMUM (Button 1) 0x29, 0x03,// USAGE_MAXIMUM (Button 3) 0x15, 0x00,// LOGICAL_MINIMUM (0) 0x25, 0x01,// LOGICAL_MAXIMUM (1) 0x95, 0x03,// REPORT_COUNT (3) 0x75, 0x01,// REPORT_SIZE (1) 0x81, 0x02,// INPUT (Data,Var,Abs) 0x95, 0x01,// REPORT_COUNT (1) 0x75, 0x05,// REPORT_SIZE (5) 0x81, 0x03,// INPUT (Cnst,Var,Abs) 0x05, 0x01,// USAGE_PAGE (Generic Desktop) 0x09, 0x30,// USAGE (X) 0x09, 0x31,// USAGE (Y) 0x15, 0x81,// LOGICAL_MINIMUM (-127) 0x25, 0x7f,// LOGICAL_MAXIMUM (127) 0x75, 0x08,// REPORT_SIZE (8) 0x95, 0x02,// REPORT_COUNT (2) 0x81, 0x06,// INPUT (Data,Var,Rel) 0xc0,// END_COLLECTION //0xc0 // END_COLLECTION /* USER CODE END 0 */ 0xC0 /* END_COLLECTION */ };Eclipse says: 'excess elements in array initializer' for each line. With some Google i found out, that the package size isn´t right. I think it is the CubeMX 'middlewares' -> 'paramter settings' -> 'class parameter'
- USBD_Custom_HID_Report_DESC_SIZE
-USBD_Custom_HID_Outreport_BUF_SIZE
But i haven´t found anything, how i get the that. size. Is it bit, bytes, lines, instructions, bananas? In all tutorials i have found, the size is simple typed in with no explanation or there isn´t said anything about it.
Or is there an other way? Can i use the (non custom) HID? I only need a Standard joystick konfiguration.
2018-08-09 07:55 PM
Problem is the people with real talent in these areas hold down jobs, and don't spend their time making videos or writing tutorials.
USB Descriptors are surely documented, both the form, construction and expectations.
Copying, changing and hammering until they work is not the optimal strategy, step back and start with books or tutorials that deal the the basic USB mechanics.