Re: USB gadget: configfs hid mouse device
Krzysztof Opasiakwrote: > You may also try to use your own C program instead of echo to check if > hex value is correctly written. This was the crucial hint. Seem like echo is doing something fishy here. "mouse" Works fine with my Linux host now, but unfortunately does not using Windows 10 as a host! Here is the HID I'm using: 0x05, 0x01, //Usage Page(Generic Desktop Controls) 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(1) 0x29, 0x05, //Usage Maximum(5) 0x15, 0x00, //Logical Minimum(1) 0x25, 0x01, //Logical Maximum(1) 0x95, 0x05, //Report Count(5) 0x75, 0x01, //Report Size(1) 0x81, 0x02, //Input(Data,Variable,Absolute,BitField) 0x95, 0x01, //Report Count(1) 0x75, 0x03, //Report Size(3) 0x81, 0x01, //Input(Constant,Array,Absolute,BitField) 0x05, 0x01, //Usage Page(Generic Desktop Controls) 0x09, 0x30, //Usage(x) 0x09, 0x31, //Usage(y) 0x09, 0x38, //Usage(Wheel) 0x15, 0x81, //Logical Minimum(-127) 0x25, 0x7F, //Logical Maximum(127) 0x75, 0x08, //Report Size(8) 0x95, 0x03, //Report Count(3) 0x81, 0x06, //Input(Data,Variable,Relative,BitField) 0xc0, //End Collection 0xc0 //End Collection Windows properly detects a HID mouse pointer, but I'm unable to make the Windows mouse actually move when sending movement events. Sven -- -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: USB gadget: configfs hid mouse device
On 12/01/2016 02:35 PM, Sven Geggus wrote: > Hello, > > I'm trying to setup a custom mouse-like device on a pi zero. > > As I have never been using the USB gadget stack before, the following > problem might likely be a configuration failure on my side as well as a > driver issue. > > Using the documentation from kernel source > (Documentation/usb/gadget_hid.txt, Documentation/usb/gadget_configfs.txt and > Documentation/ABI/testing/configfs-usb-gadget-hid) it was more or less > straight forward to set up a keyboard emulating device using the provided > example code (hid_gadget_test). > > Unfortunately this is not the case with the mouse emulation. > > I build the following shell-script to generate a mouse device. Due to the > lack of an example "report_desc" has been stolen from a logitech mouse: > > --cut-- > #!/bin/bash > > CONFIGFS_HOME=/sys/kernel/config > C=1 > N="usb0" > > cd $CONFIGFS_HOME/usb_gadget/ > mkdir g1 > cd g1 > echo 0x1d6b > idVendor # Linux Foundation > echo 0x0104 > idProduct # Multifunction Composite Gadget > echo 0x0100 > bcdDevice # v1.0.0 > echo 0x0200 > bcdUSB # USB2 > mkdir -p strings/0x409 > echo "fedcba9876543210" > strings/0x409/serialnumber > echo "Sirius Cybernetics Corp." > strings/0x409/manufacturer > echo "dummymouse" > strings/0x409/product > mkdir -p functions/hid.$N > # protocol 2 seems to be mouse > echo 2 > functions/hid.$N/protocol > echo 1 > functions/hid.$N/subclass > echo 8 > functions/hid.$N/report_length > # HID Mouse e.g. copy from logitech mouse as follows: > # for i in $(usbhid-dump -a XXX:YYY |tail -n +2); do echo -n x$i; done > |tr '[:upper:]' '[:lower:]' > echo -ne > \\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x05\\x09\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x05\\x01\\x16\\x01\\xf8\\x26\\xff\\x07\\x75\\x0c\\x95\\x02\\x09\\x30\\x09\\x31\\x81\\x06\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x01\\x09\\x38\\x81\\x06\\x05\\x0c\\x0a\\x38\\x02\\x95\\x01\\x81\\x06\\xc0\\xc0 > > functions/hid.$N/report_desc > hexdump -C functions/hid.$N/report_desc > mkdir -p configs/c.$C/strings/0x409 > echo "Config $C: dummymouse" > configs/c.$C/strings/0x409/configuration > echo 250 > configs/c.$C/MaxPower > ln -s functions/hid.$N configs/c.$C/ > ls /sys/class/udc > UDC > --cut-- > > However, this does not work. First of all, the report_desc is not written > to functions/hid.$N/report_desc as expected. > > Instead I get the following truncated stuff which also shows up on the usb > host > using usbhid-dump: > 38 02 95 01 81 06 c0 c0 |8...| > 0008 > > Thus I enabled debugging on USB hid gadget driver and get the following: > [12381.564157] configfs-gadget gadget: high-speed config #1: c > [12381.577963] configfs-gadget gadget: hidg_set_alt intf:0 alt:0 > [12381.593012] configfs-gadget gadget: non-core control req21.0a v > i l0 > [12381.608761] configfs-gadget gadget: hidg_setup crtl_request : > bRequestType:0x21 bRequest:0xa Value:0x0 > [12381.626650] configfs-gadget gadget: Unknown request 0xa > [12381.640731] configfs-gadget gadget: non-core control req81.06 v2200 > i l8 > [12381.656464] configfs-gadget gadget: hidg_setup crtl_request : > bRequestType:0x81 bRequest:0x6 Value:0x2200 > [12381.674655] configfs-gadget gadget: USB_REQ_GET_DESCRIPTOR: REPORT > > As a result, the device in not detected correctly on the host side as well: > usb 2-1: Product: dummymouse > usb 2-1: Manufacturer: Sirius Cybernetics Corp. > usb 2-1: SerialNumber: fedcba9876543210 > hid-generic 0003:1D6B:0104.004F: unknown main item tag 0x0 > hid-generic 0003:1D6B:0104.004F: collection stack underflow > hid-generic 0003:1D6B:0104.004F: item 0 0 0 12 parsing failed > hid-generic: probe of 0003:1D6B:0104.004F failed with error -22 > > Kernel Version is 4.4.35+ from Raspberr Pi repo, but looking at the current > version of drivers/usb/gadget/function/f_hid.c did not seem to have changes > related to thsi topic: > > https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/usb/gadget/function/f_hid.c > > Any hint? Try to setup everything as described in [1]. You may also try to use your own C program instead of echo to check if hex value is correctly written. Footnotes: 1 - http://marc.info/?l=linux-usb=141526874831676=2 Best regards, -- Krzysztof Opasiak Samsung R Institute Poland Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
USB gadget: configfs hid mouse device
Hello, I'm trying to setup a custom mouse-like device on a pi zero. As I have never been using the USB gadget stack before, the following problem might likely be a configuration failure on my side as well as a driver issue. Using the documentation from kernel source (Documentation/usb/gadget_hid.txt, Documentation/usb/gadget_configfs.txt and Documentation/ABI/testing/configfs-usb-gadget-hid) it was more or less straight forward to set up a keyboard emulating device using the provided example code (hid_gadget_test). Unfortunately this is not the case with the mouse emulation. I build the following shell-script to generate a mouse device. Due to the lack of an example "report_desc" has been stolen from a logitech mouse: --cut-- #!/bin/bash CONFIGFS_HOME=/sys/kernel/config C=1 N="usb0" cd $CONFIGFS_HOME/usb_gadget/ mkdir g1 cd g1 echo 0x1d6b > idVendor # Linux Foundation echo 0x0104 > idProduct # Multifunction Composite Gadget echo 0x0100 > bcdDevice # v1.0.0 echo 0x0200 > bcdUSB # USB2 mkdir -p strings/0x409 echo "fedcba9876543210" > strings/0x409/serialnumber echo "Sirius Cybernetics Corp." > strings/0x409/manufacturer echo "dummymouse" > strings/0x409/product mkdir -p functions/hid.$N # protocol 2 seems to be mouse echo 2 > functions/hid.$N/protocol echo 1 > functions/hid.$N/subclass echo 8 > functions/hid.$N/report_length # HID Mouse e.g. copy from logitech mouse as follows: # for i in $(usbhid-dump -a XXX:YYY |tail -n +2); do echo -n x$i; done |tr '[:upper:]' '[:lower:]' echo -ne \\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x05\\x09\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x05\\x01\\x16\\x01\\xf8\\x26\\xff\\x07\\x75\\x0c\\x95\\x02\\x09\\x30\\x09\\x31\\x81\\x06\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x01\\x09\\x38\\x81\\x06\\x05\\x0c\\x0a\\x38\\x02\\x95\\x01\\x81\\x06\\xc0\\xc0 > functions/hid.$N/report_desc hexdump -C functions/hid.$N/report_desc mkdir -p configs/c.$C/strings/0x409 echo "Config $C: dummymouse" > configs/c.$C/strings/0x409/configuration echo 250 > configs/c.$C/MaxPower ln -s functions/hid.$N configs/c.$C/ ls /sys/class/udc > UDC --cut-- However, this does not work. First of all, the report_desc is not written to functions/hid.$N/report_desc as expected. Instead I get the following truncated stuff which also shows up on the usb host using usbhid-dump: 38 02 95 01 81 06 c0 c0 |8...| 0008 Thus I enabled debugging on USB hid gadget driver and get the following: [12381.564157] configfs-gadget gadget: high-speed config #1: c [12381.577963] configfs-gadget gadget: hidg_set_alt intf:0 alt:0 [12381.593012] configfs-gadget gadget: non-core control req21.0a v i l0 [12381.608761] configfs-gadget gadget: hidg_setup crtl_request : bRequestType:0x21 bRequest:0xa Value:0x0 [12381.626650] configfs-gadget gadget: Unknown request 0xa [12381.640731] configfs-gadget gadget: non-core control req81.06 v2200 i l8 [12381.656464] configfs-gadget gadget: hidg_setup crtl_request : bRequestType:0x81 bRequest:0x6 Value:0x2200 [12381.674655] configfs-gadget gadget: USB_REQ_GET_DESCRIPTOR: REPORT As a result, the device in not detected correctly on the host side as well: usb 2-1: Product: dummymouse usb 2-1: Manufacturer: Sirius Cybernetics Corp. usb 2-1: SerialNumber: fedcba9876543210 hid-generic 0003:1D6B:0104.004F: unknown main item tag 0x0 hid-generic 0003:1D6B:0104.004F: collection stack underflow hid-generic 0003:1D6B:0104.004F: item 0 0 0 12 parsing failed hid-generic: probe of 0003:1D6B:0104.004F failed with error -22 Kernel Version is 4.4.35+ from Raspberr Pi repo, but looking at the current version of drivers/usb/gadget/function/f_hid.c did not seem to have changes related to thsi topic: https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/usb/gadget/function/f_hid.c Any hint? Regards Sven -- "Remember, democracy never lasts long. It soon wastes itself, exhausts and murders itself. There never was a democracy yet that did not commit suicide." (John Quincy Adams) /me is giggls@ircnet, http://sven.gegg.us/ on the Web -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html