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_KBDDEV_H_ 00037 #define USB_HID_KBDDEV_H_ 00038 00039 #include <stdint.h> 00040 00041 #include <fibril_synch.h> 00042 00043 #include <usb/hid/hid.h> 00044 #include <usb/hid/hidparser.h> 00045 #include <ddf/driver.h> 00046 #include <usb/dev/pipes.h> 00047 #include <usb/dev/driver.h> 00048 00049 #include "kbdrepeat.h" 00050 00051 struct usb_hid_dev; 00052 00053 /*----------------------------------------------------------------------------*/ 00066 typedef struct usb_kbd_t { 00068 int32_t *keys_old; 00070 int32_t *keys; 00072 size_t key_count; 00074 uint8_t modifiers; 00075 00077 unsigned mods; 00078 00080 unsigned lock_keys; 00081 00083 int console_phone; 00084 00086 ddf_dev_ops_t ops; 00087 00089 usb_kbd_repeat_t repeat; 00090 00092 fibril_mutex_t *repeat_mtx; 00093 00094 uint8_t *output_buffer; 00095 00096 size_t output_size; 00097 00098 size_t led_output_size; 00099 00100 usb_hid_report_path_t *led_path; 00101 00102 int32_t *led_data; 00103 00110 int initialized; 00111 } usb_kbd_t; 00112 00113 /*----------------------------------------------------------------------------*/ 00114 00115 usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description; 00116 00117 const char *HID_KBD_FUN_NAME; 00118 const char *HID_KBD_CLASS_NAME; 00119 00120 /*----------------------------------------------------------------------------*/ 00121 00122 int usb_kbd_init(struct usb_hid_dev *hid_dev, void **data); 00123 00124 bool usb_kbd_polling_callback(struct usb_hid_dev *hid_dev, void *data/*, 00125 uint8_t *buffer, size_t buffer_size*/); 00126 00127 int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev); 00128 00129 int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev); 00130 00131 void usb_kbd_free(usb_kbd_t **kbd_dev); 00132 00133 void usb_kbd_push_ev(struct usb_hid_dev *hid_dev, usb_kbd_t *kbd_dev, 00134 int type, unsigned int key); 00135 00136 void usb_kbd_deinit(struct usb_hid_dev *hid_dev, void *data); 00137 00138 int usb_kbd_set_boot_protocol(struct usb_hid_dev *hid_dev); 00139 00140 #endif /* USB_HID_KBDDEV_H_ */ 00141