Hello,
I am pulling my hair trying to get multimedia button functionality to the VUSB-for-arduino library.
There are easy ways to add this functionality to the built in keyboard functionality of the Leonardo, but when I try a similar approach with an UNO and VUSB I just cant get it to work. So hoping someone here has done this (I have searched here and on google but havent found anyone who managed to do it yet)...
So, one of the tricks is to change the USB-descriptor, another is to actually make a descriptor that WORKS! Anyways, I have a descriptor that compiles correctly and shows up in my computer as a USB input device.
In USBKeyboard.h I replaced this:
PROGMEM char usbHidReportDescriptor[35] = { /* USB report descriptor */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
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)
0x95, BUFFER_SIZE-1, // REPORT_COUNT (simultaneous keystrokes)
0x75, 0x08, // REPORT_SIZE (8)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0 // END_COLLECTION
};
with this:
PROGMEM char usbHidReportDescriptor[37] = { /* USB report descriptor */
0x05, 0x0C, /* Usage Page (Consumer Devices) */
0x09, 0x01, /* Usage (Consumer Control) */
0xA1, 0x01, /* Collection (Application) */
0x05, 0x0C, /* Usage Page (Consumer Devices) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x01, /* Logical Maximum (1) */
0x75, 0x01, /* Report Size (1) */
0x95, 0x07, /* Report Count (7) */
0x09, 0xB5, /* Usage (Scan Next Track) */
0x09, 0xB6, /* Usage (Scan Previous Track) */
0x09, 0xB7, /* Usage (Stop) */
0x09, 0xCD, /* Usage (Play / Pause) */
0x09, 0xE2, /* Usage (Mute) */
0x09, 0xE9, /* Usage (Volume Up) */
0x09, 0xEA, /* Usage (Volume Down) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x95, 0x01, /* Report Count (1) */
0x81, 0x01, /* Input (Constant) */
0xC0 /* End Collection */
};
Also some defines after that:
#define KEY_PLAYPAUSE 205 //205 0xcd
#define KEY_MUTE 0xE2 //226 0xe2
#define KEY_PLAY 176 //176 0xb0
#define KEY_PAUSE 177 //177 0xb1
Ofcourse also changed this line in usbconfig.h to correlate to the length of the Descriptor:
#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 37
When compiling the device is found as a USB input device.
Then I use the example file that came with V-usb for Arduino and change the keys sent to this:
UsbKeyboard.sendKeyStroke(KEY_PLAYPAUSE);
Above should send a code of 205 to the computer (which is play/pause, and looking in BUS-DOG I get this when pressing the button:
Id Type Time Length Hex Ascii
26 In (USB URB Function: 9) 0.000000 1 00 .
So, just a 00 value. My guess is that the length of the data is truncated somewhere in the code, but I dont know where. Or also quite probable, there is something in the USB-descriptor that I have written wrongly (also quite probable). OR, there is something else that I missed (well thats obvious)...
Adding USAGE_MINIMUM and USAGE_MAXIMUM does not change anything... Adding REPORT_ID=1 changes nothing. I have tried a lot of different descriptors and combinations. This is the one that has gotten me the furthest, but alas now I feel Im stuck...
So anyone feel they are VUSB-whiz and can come with some pointers :)?
Thanks in advance,
/Kristian
