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
This commit is contained in:
@@ -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
|
||||||
@@ -572,7 +572,8 @@ kb_device_added(const usb_device *dev, void **cookie)
|
|||||||
protocol = intf->descr->interface_protocol;
|
protocol = intf->descr->interface_protocol;
|
||||||
DPRINTF_INFO ((MY_ID "interface %d: class %d, subclass %d, protocol %d\n",
|
DPRINTF_INFO ((MY_ID "interface %d: class %d, subclass %d, protocol %d\n",
|
||||||
ifno, class, subclass, protocol));
|
ifno, class, subclass, protocol));
|
||||||
if (class == USB_CLASS_HID && subclass == 1)
|
if (class == USB_HID_DEVICE_CLASS
|
||||||
|
&& subclass == USB_HID_INTERFACE_BOOT_SUBCLASS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +589,7 @@ kb_device_added(const usb_device *dev, void **cookie)
|
|||||||
st = usb->send_request (dev,
|
st = usb->send_request (dev,
|
||||||
USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_STANDARD,
|
USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_STANDARD,
|
||||||
USB_REQUEST_GET_DESCRIPTOR,
|
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);
|
hid_desc, desc_len, &desc_len);
|
||||||
DPRINTF_INFO ((MY_ID "get_hid_desc: st=%d, len=%d\n",
|
DPRINTF_INFO ((MY_ID "get_hid_desc: st=%d, len=%d\n",
|
||||||
(int) st, (int)desc_len));
|
(int) st, (int)desc_len));
|
||||||
@@ -604,7 +605,7 @@ kb_device_added(const usb_device *dev, void **cookie)
|
|||||||
st = usb->send_request (dev,
|
st = usb->send_request (dev,
|
||||||
USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_STANDARD,
|
USB_REQTYPE_INTERFACE_IN | USB_REQTYPE_STANDARD,
|
||||||
USB_REQUEST_GET_DESCRIPTOR,
|
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);
|
rep_desc, desc_len, &desc_len);
|
||||||
DPRINTF_INFO ((MY_ID "get_hid_rep_desc: st=%d, len=%d\n",
|
DPRINTF_INFO ((MY_ID "get_hid_rep_desc: st=%d, len=%d\n",
|
||||||
(int) st, (int)desc_len));
|
(int) st, (int)desc_len));
|
||||||
@@ -736,7 +737,7 @@ static usb_notify_hooks my_notify_hooks =
|
|||||||
#define SUPPORTED_DEVICES 1
|
#define SUPPORTED_DEVICES 1
|
||||||
usb_support_descriptor my_supported_devices [SUPPORTED_DEVICES] =
|
usb_support_descriptor my_supported_devices [SUPPORTED_DEVICES] =
|
||||||
{
|
{
|
||||||
{ USB_CLASS_HID, 0, 0, 0, 0 },
|
{ USB_HID_DEVICE_CLASS, 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <drivers/Drivers.h>
|
#include <drivers/Drivers.h>
|
||||||
#include <drivers/USB.h>
|
#include <drivers/USB.h>
|
||||||
|
#include <drivers/usb/USB_hid.h>
|
||||||
#include "hidparse.h"
|
#include "hidparse.h"
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -65,29 +66,6 @@ size_t cbuf_getn(cbuffer *, void *, size_t num_bytes);
|
|||||||
cpu_status cbuf_lock(cbuffer *);
|
cpu_status cbuf_lock(cbuffer *);
|
||||||
void cbuf_unlock(cbuffer *, cpu_status);
|
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 */
|
/* driver specific definitions */
|
||||||
|
|
||||||
#define DRIVER_NAME "hid"
|
#define DRIVER_NAME "hid"
|
||||||
|
|||||||
Reference in New Issue
Block a user