From 8c5cc5d1aa9fba56986cc1e806f0f6d9659c66a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 20 Sep 2004 09:08:58 +0000 Subject: [PATCH] Extracted USB HID specific data to USB_hid.h git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9005 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/drivers/usb/USB_hid.h | 45 ++++++++++++++++++++++ src/add-ons/kernel/drivers/input/hid/hid.c | 9 +++-- src/add-ons/kernel/drivers/input/hid/hid.h | 24 +----------- 3 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 headers/os/drivers/usb/USB_hid.h diff --git a/headers/os/drivers/usb/USB_hid.h b/headers/os/drivers/usb/USB_hid.h new file mode 100644 index 0000000000..727ea65845 --- /dev/null +++ b/headers/os/drivers/usb/USB_hid.h @@ -0,0 +1,45 @@ +#ifndef USB_HID_H +#define USB_HID_H + +// (Partial) USB Class Definitions for HID Devices, version 1.11 +// Reference: http://www.usb.org/developers/devclass_docs/hid1_11.pdf + +#define USB_HID_DEVICE_CLASS 0x03 +#define USB_HID_CLASS_VERSION 0x0100 + +enum { // HID Interface Subclasses + USB_HID_INTERFACE_NO_SUBCLASS = 0x00, // No Subclass + USB_HID_INTERFACE_BOOT_SUBCLASS // Boot Interface Subclass +}; + +enum { // HID Class-Specific descriptor subtypes + USB_HID_DESCRIPTOR_HID = 0x21, + USB_HID_DESCRIPTOR_REPORT, + USB_HID_DESCRIPTOR_PHYSICAL +}; + +enum { // HID Class-specific requests + USB_REQUEST_HID_GET_REPORT = 0x01, + USB_REQUEST_HID_GET_IDLE, + USB_REQUEST_HID_GET_PROTOCOL, + + USB_REQUEST_HID_SET_REPORT = 0x09, + USB_REQUEST_HID_SET_IDLE, + USB_REQUEST_HID_SET_PROTOCOL +}; + +typedef struct +{ + uint8 length; + uint8 descriptor_type; + uint16 hid_version; + uint8 country_code; + uint8 num_descriptors; + struct + { + uint8 descriptor_type; + uint16 descriptor_length; + } _PACKED descriptor_info [1]; +} _PACKED usb_hid_descriptor; + +#endif // USB_HID_H diff --git a/src/add-ons/kernel/drivers/input/hid/hid.c b/src/add-ons/kernel/drivers/input/hid/hid.c index 8fc37178e3..d32dc65b01 100644 --- a/src/add-ons/kernel/drivers/input/hid/hid.c +++ b/src/add-ons/kernel/drivers/input/hid/hid.c @@ -572,7 +572,8 @@ kb_device_added(const usb_device *dev, void **cookie) protocol = intf->descr->interface_protocol; DPRINTF_INFO ((MY_ID "interface %d: class %d, subclass %d, protocol %d\n", ifno, class, subclass, protocol)); - if (class == USB_CLASS_HID && subclass == 1) + if (class == USB_HID_DEVICE_CLASS + && subclass == USB_HID_INTERFACE_BOOT_SUBCLASS) break; } @@ -588,7 +589,7 @@ kb_device_added(const usb_device *dev, void **cookie) st = usb->send_request (dev, USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_STANDARD, USB_REQUEST_GET_DESCRIPTOR, - USB_DESCRIPTOR_HID << 8, ifno, desc_len, + USB_HID_DESCRIPTOR_HID << 8, ifno, desc_len, hid_desc, desc_len, &desc_len); DPRINTF_INFO ((MY_ID "get_hid_desc: st=%d, len=%d\n", (int) st, (int)desc_len)); @@ -604,7 +605,7 @@ kb_device_added(const usb_device *dev, void **cookie) st = usb->send_request (dev, USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_STANDARD, USB_REQUEST_GET_DESCRIPTOR, - USB_DESCRIPTOR_HID_REPORT << 8, ifno, desc_len, + USB_HID_DESCRIPTOR_REPORT << 8, ifno, desc_len, rep_desc, desc_len, &desc_len); DPRINTF_INFO ((MY_ID "get_hid_rep_desc: st=%d, len=%d\n", (int) st, (int)desc_len)); @@ -736,7 +737,7 @@ static usb_notify_hooks my_notify_hooks = #define SUPPORTED_DEVICES 1 usb_support_descriptor my_supported_devices [SUPPORTED_DEVICES] = { - { USB_CLASS_HID, 0, 0, 0, 0 }, + { USB_HID_DEVICE_CLASS, 0, 0, 0, 0 }, }; diff --git a/src/add-ons/kernel/drivers/input/hid/hid.h b/src/add-ons/kernel/drivers/input/hid/hid.h index 7cde0d8de6..11069444e7 100644 --- a/src/add-ons/kernel/drivers/input/hid/hid.h +++ b/src/add-ons/kernel/drivers/input/hid/hid.h @@ -32,6 +32,7 @@ #include #include +#include #include "hidparse.h" #if DEBUG @@ -65,29 +66,6 @@ size_t cbuf_getn(cbuffer *, void *, size_t num_bytes); cpu_status cbuf_lock(cbuffer *); void cbuf_unlock(cbuffer *, cpu_status); -/* HID class-specific definitions */ - -#define USB_CLASS_HID 3 - -#define USB_DESCRIPTOR_HID 0x21 -#define USB_DESCRIPTOR_HID_REPORT 0x22 - -#define USB_REQUEST_HID_GET_REPORT 0x01 - -typedef struct -{ - uint8 length; - uint8 descriptor_type; - uint16 hid_version; - uint8 country_code; - uint8 num_descriptors; - struct - { - uint8 descriptor_type; - uint16 descriptor_length; - } _PACKED descriptor_info [1]; -} _PACKED usb_hid_descriptor; - /* driver specific definitions */ #define DRIVER_NAME "hid"