HID Composite Device.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to create an HID Gadget joystick/mouse using the g_hid module
on an OMAP3530. It's kind of a monstrosity of an input device. I've
added this to my platform code:


static struct hidg_func_descriptor my_joystick_data = {
        .subclass = 0,
        .protocol = 0,
        .report_length = 10,
	.report_desc_length= 50,
	.report_desc= {
          0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    
	  0x09, 0x04,                    // USAGE (Joystick)
	  0xa1, 0x01,                    // COLLECTION (Application)
	  0x09, 0x01,                    //   USAGE (Pointer)
	  0xa1, 0x00,                    //   COLLECTION (Physical)
	  0x15, 0x81,                    //     LOGICAL_MINIMUM (-127)
	  0x25, 0x7f,                    //     LOGICAL_MAXIMUM (127)
	  0x75, 0x08,                    //     REPORT_SIZE (8)
	  0x95, 0x06,                    //     REPORT_COUNT (6)
	  0x09, 0x30,                    //     USAGE (X)
	  0x09, 0x31,                    //     USAGE (Y)
	  0x09, 0x32,                    //     USAGE (Z)
	  0x09, 0x33,                    //     USAGE (Rx)
	  0x09, 0x34,                    //     USAGE (Ry)
	  0x09, 0x35,                    //     USAGE (Rz)
	  0x81, 0x02,                    //     INPUT (Data,Var,Abs)
	  0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
	  0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
	  0x75, 0x01,                    //     REPORT_SIZE (1)
	  0x95, 0x20,                    //     REPORT_COUNT (32)
	  0x05, 0x09,                    //     USAGE_PAGE (Button)
	  0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
	  0x29, 0x20,                    //     USAGE_MAXIMUM (Button
32)
	  0x81, 0x02,                    //     INPUT (Data,Var,Abs)
	  0xc0,                          //   END_COLLECTION
	  0xc0                           // END_COLLECTION
        }
};

static struct platform_device my_joystick_hid = {
        .name = "hidg",
        .id = 0,
        .num_resources = 0,
        .resource = 0,
        .dev = {
                .platform_data = &my_joystick_data,
        }
};

static struct hidg_func_descriptor my_mouse_data = {
        .subclass = 0,
        .protocol = 0,
        .report_length = 3,
	.report_desc_length= 50,
	.report_desc= {
    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
        }
};

static struct platform_device my_mouse_hid = {
        .name = "hidg",
        .id = 1,
        .num_resources = 0,
        .resource = 0,
        .dev = {
                .platform_data = &my_mouse_data,
        }
};

I've called platform_device_register for each platform device. If I plug
this thing into a machine running ubuntu, it seems to be recognized as a
mouse and a joystick, and everything seems to behave as expected, with
/dev/hidg0 and /dev/hidg1 transmitting messages over usb. On a windows
machine, however, it doesn't seem to be recognized. If I comment the
'mouse' portion out, windows sees it as a gamepad just fine.

Am I missing something? How do I properly implement a composite USB HID
device like this?

Thanks a lot!
-Woody
 


Confidentiality Note: The information contained in this message, and any attachments, may contain proprietary and/or privileged material. It is intended solely for the person or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux