2

I'm trying to understand how HID and Composite devices are defined.

How can one know (from the OS side) that a recently-attached USB device can only input data (and cannot attach like a hard drive, run an executable or whatever)?

The follow-on is this: if the answer is that the attached USB device must be a HID, then can that HID consist of a keyboard/mouse combo such as a keyboard with integrated trackpad?

2
  • 2
    Are you asking about how the device is identified in the OS, or the actual nature of the device? By definition, any USB device that consists of more than one logical sub-device is always a composite USB device. Dec 13, 2017 at 0:40
  • I'm asking about how it is identified in the OS - essentially, I care about how to know (from the OS side) that a recently-attached USB device can only input data and cannot do anything else (such as attaching like a hard drive, running an executable or whatever).
    – sscirrus
    Dec 13, 2017 at 19:06

1 Answer 1

2

The question isn't so "Cut 'n' Shut" as that. There is alot more to usb identification than "one mouse, one cable = HID VS one mouse, one keyboard, one cable = Composite."

For example a lone Keyboard can be either a HID and/or a Composite USB device, if you've ever had a "Gamer" keyboard with built in macros and lighting and it's own storage to save those macros for travel, that is a composite device because it incorporates multiple device's in the one bus.

In counter point a Logitech wireless mouse keyboard combo can be just a HID device, because that is the only class present, though there may be two devices, they are both HID only.

An USB Composite Device is a peripheral device that supports more than one device class. Many different devices are implemented as composite devices. For example they consist of a certain device class, but also an USB disk that has all the necessary drivers stored so that the device can be installed automatically, without the need to have access to a certain driver software.

Source: USB Composite Device

And then there is the point about how Windows see's a device.

When a new USB device is connected to a host machine, the USB bus driver creates a physical device object (PDO) for the device and generates a PnP event to report the new PDO. The operating system then queries the bus driver for the hardware IDs associated with the PDO.

The bus driver also checks the device class (bDeviceClass), subclass (bDeviceSubClass), and protocol (bDeviceProtocol) fields of the device descriptor. If these fields are zero, the device is a composite device, and the bus driver reports an extra compatible identifier (ID) of USB\COMPOSITE for the PDO.

Source: Enumeration of USB Composite Devices

I hope this has helped you understand a little more on the topic.

2
  • This is a great post but it misses the specific question I asked. If I have a keyboard/mouse combo in a single USB device, can that device classify itself such that the computer's OS recognizes it as a HID?
    – sscirrus
    Dec 13, 2017 at 19:09
  • At the recommendation of @TwistyImpersonator, I've broadened the question to focus on the problem rather than the attempted solution.
    – sscirrus
    Dec 13, 2017 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .