usbhid.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011 Lubos Slovak
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 /* USB_HID_USBHID_H_ */
00135 

Generated on Thu Jun 2 07:45:44 2011 for HelenOS/USB by  doxygen 1.4.7