source: mainline/uspace/drv/usbkbd/kbddev.h@ 5857be2

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 5857be2 was 85fa1e1, checked in by Lubos Slovak <lubos.slovak@…>, 14 years ago

HID parser output report API used to create output reports.

+ Added constants for LED Page of HID Usage Tables

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[54b5625]1/*
2 * Copyright (c) 2011 Lubos Slovak
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbhid
30 * @{
31 */
32/** @file
[2391aaf]33 * USB HID keyboard device structure and API.
[54b5625]34 */
35
[252e30c]36#ifndef USB_KBDDEV_H_
37#define USB_KBDDEV_H_
[54b5625]38
[8c3c756]39#include <stdint.h>
40
[dfe53af]41#include <fibril_synch.h>
42
[54b5625]43#include <usb/classes/hid.h>
[5050d9e]44#include <usb/classes/hidparser.h>
[eb1a2f4]45#include <ddf/driver.h>
[707ffcf]46#include <usb/pipes.h>
[f8e4cb6]47#include <usb/devdrv.h>
48
[81da2e7f]49#include "kbdrepeat.h"
[2391aaf]50
51/*----------------------------------------------------------------------------*/
[54b5625]52/**
[48d2765]53 * USB/HID keyboard device type.
54 *
55 * Holds a reference to generic USB/HID device structure and keyboard-specific
56 * data, such as currently pressed keys, modifiers and lock keys.
57 *
58 * Also holds a IPC phone to the console (since there is now no other way to
59 * communicate with it).
60 *
61 * @note Storing active lock keys in this structure results in their setting
62 * being device-specific.
[54b5625]63 */
[252e30c]64typedef struct usb_kbd_t {
[f8e4cb6]65 /** Structure holding generic USB device information. */
66 //usbhid_dev_t *hid_dev;
67 usb_device_t *usb_dev;
[882f8b1]68
[48d2765]69 /** Currently pressed keys (not translated to key codes). */
70 uint8_t *keys;
71 /** Count of stored keys (i.e. number of keys in the report). */
72 size_t key_count;
73 /** Currently pressed modifiers (bitmap). */
[4837092]74 uint8_t modifiers;
[882f8b1]75
[48d2765]76 /** Currently active modifiers including locks. Sent to the console. */
[882f8b1]77 unsigned mods;
[48d2765]78
79 /** Currently active lock keys. */
[882f8b1]80 unsigned lock_keys;
[2391aaf]81
[48d2765]82 /** IPC phone to the console device (for sending key events). */
[2391aaf]83 int console_phone;
84
[dfe53af]85 /** Information for auto-repeat of keys. */
[252e30c]86 usb_kbd_repeat_t repeat;
[dfe53af]87
88 /** Mutex for accessing the information about auto-repeat. */
89 fibril_mutex_t *repeat_mtx;
[5050d9e]90
[f8e4cb6]91 /** Report descriptor. */
92 uint8_t *report_desc;
93
94 /** Report descriptor size. */
95 size_t report_desc_size;
[85fa1e1]96
97 uint8_t *output_buffer;
98
99 size_t output_size;
100
101 size_t led_output_size;
102
103 usb_hid_report_path_t *led_path;
104
105 int32_t *led_data;
[f8e4cb6]106
107 /** HID Report parser. */
108 usb_hid_report_parser_t *parser;
109
[00b13408]110 /** State of the structure (for checking before use).
111 *
112 * 0 - not initialized
113 * 1 - initialized
114 * -1 - ready for destroying
115 */
[2391aaf]116 int initialized;
[252e30c]117} usb_kbd_t;
[2391aaf]118
119/*----------------------------------------------------------------------------*/
120
[f8e4cb6]121enum {
[252e30c]122 USB_KBD_POLL_EP_NO = 0,
123 USB_KBD_POLL_EP_COUNT = 1
[f8e4cb6]124};
125
[252e30c]126usb_endpoint_description_t *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1];
[f8e4cb6]127
128ddf_dev_ops_t keyboard_ops;
129
130/*----------------------------------------------------------------------------*/
131
[252e30c]132usb_kbd_t *usb_kbd_new(void);
[f8e4cb6]133
[252e30c]134int usb_kbd_init(usb_kbd_t *kbd_dev, usb_device_t *dev);
[f8e4cb6]135
[252e30c]136bool usb_kbd_polling_callback(usb_device_t *dev, uint8_t *buffer,
[f8e4cb6]137 size_t buffer_size, void *arg);
138
[252e30c]139void usb_kbd_polling_ended_callback(usb_device_t *dev, bool reason,
[f8e4cb6]140 void *arg);
[54b5625]141
[252e30c]142int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev);
[18b3cfd]143
[252e30c]144int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev);
[00b13408]145
[252e30c]146void usb_kbd_free(usb_kbd_t **kbd_dev);
[00b13408]147
[252e30c]148void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned int key);
[dfe53af]149
[252e30c]150#endif /* USB_KBDDEV_H_ */
[2391aaf]151
152/**
153 * @}
154 */
Note: See TracBrowser for help on using the repository browser.