00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00036 #ifndef USB_HID_USBHID_H_
00037 #define USB_HID_USBHID_H_
00038
00039 #include <stdint.h>
00040
00041 #include <usb/hid/hidparser.h>
00042 #include <ddf/driver.h>
00043 #include <usb/dev/pipes.h>
00044 #include <usb/dev/driver.h>
00045 #include <usb/hid/hid.h>
00046 #include <bool.h>
00047
00048 struct usb_hid_dev;
00049
00050 typedef int (*usb_hid_driver_init_t)(struct usb_hid_dev *, void **data);
00051 typedef void (*usb_hid_driver_deinit_t)(struct usb_hid_dev *, void *data);
00052 typedef bool (*usb_hid_driver_poll_t)(struct usb_hid_dev *, void *data);
00053 typedef int (*usb_hid_driver_poll_ended_t)(struct usb_hid_dev *, void *data,
00054 bool reason);
00055
00056 typedef struct usb_hid_subdriver {
00058 usb_hid_driver_init_t init;
00060 usb_hid_driver_deinit_t deinit;
00062 usb_hid_driver_poll_t poll;
00064 usb_hid_driver_poll_ended_t poll_end;
00066 void *data;
00067 } usb_hid_subdriver_t;
00068
00069
00073 typedef struct usb_hid_dev {
00075 usb_device_t *usb_dev;
00076
00078 int poll_pipe_index;
00079
00081 usb_hid_subdriver_t *subdrivers;
00082
00084 int subdriver_count;
00085
00087 uint8_t *report_desc;
00088
00090 size_t report_desc_size;
00091
00093 usb_hid_report_t *report;
00094
00095 uint8_t report_id;
00096
00097 uint8_t *input_report;
00098
00099 size_t input_report_size;
00100 size_t max_input_report_size;
00101
00102 int report_nr;
00103 } usb_hid_dev_t;
00104
00105
00106
00107 enum {
00108 USB_HID_KBD_POLL_EP_NO = 0,
00109 USB_HID_MOUSE_POLL_EP_NO = 1,
00110 USB_HID_GENERIC_POLL_EP_NO = 2,
00111 USB_HID_POLL_EP_COUNT = 3
00112 };
00113
00114 usb_endpoint_description_t *usb_hid_endpoints[USB_HID_POLL_EP_COUNT + 1];
00115
00116
00117
00118 usb_hid_dev_t *usb_hid_new(void);
00119
00120 int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
00121
00122 bool usb_hid_polling_callback(usb_device_t *dev, uint8_t *buffer,
00123 size_t buffer_size, void *arg);
00124
00125 void usb_hid_polling_ended_callback(usb_device_t *dev, bool reason,
00126 void *arg);
00127
00128 void usb_hid_new_report(usb_hid_dev_t *hid_dev);
00129
00130 int usb_hid_report_number(usb_hid_dev_t *hid_dev);
00131
00132 void usb_hid_free(usb_hid_dev_t **hid_dev);
00133
00134 #endif
00135