source: mainline/uspace/drv/bus/usb/usbhid/kbd/kbddev.h@ 9c5fd7a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 9c5fd7a was cddd151, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

usbhid: kbd store pointer to created function.

Make repeat mutex part of the kbd structure.

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[61257f4]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
33 * USB HID keyboard device structure and API.
34 */
35
[ba358ed]36#ifndef USB_HID_KBDDEV_H_
37#define USB_HID_KBDDEV_H_
[61257f4]38
39#include <stdint.h>
[5da7199]40#include <async.h>
[61257f4]41#include <fibril_synch.h>
[faa44e58]42#include <usb/hid/hid.h>
43#include <usb/hid/hidparser.h>
[61257f4]44#include <ddf/driver.h>
[7d521e24]45#include <usb/dev/pipes.h>
46#include <usb/dev/driver.h>
[61257f4]47
48#include "kbdrepeat.h"
49
[60c0573]50struct usb_hid_dev;
[61257f4]51
52/*----------------------------------------------------------------------------*/
53/**
54 * USB/HID keyboard device type.
55 *
56 * Holds a reference to generic USB/HID device structure and keyboard-specific
57 * data, such as currently pressed keys, modifiers and lock keys.
58 *
[5da7199]59 * Also holds a IPC session to the console (since there is now no other way to
[61257f4]60 * communicate with it).
61 *
62 * @note Storing active lock keys in this structure results in their setting
63 * being device-specific.
64 */
65typedef struct usb_kbd_t {
[60e5a856]66 /** Link to HID device structure */
67 struct usb_hid_dev *hid_dev;
68
[e60436b]69 /** Previously pressed keys (not translated to key codes). */
70 int32_t *keys_old;
[61257f4]71 /** Currently pressed keys (not translated to key codes). */
[e60436b]72 int32_t *keys;
[61257f4]73 /** Count of stored keys (i.e. number of keys in the report). */
74 size_t key_count;
75 /** Currently pressed modifiers (bitmap). */
76 uint8_t modifiers;
[cc29622]77
[61257f4]78 /** Currently active modifiers including locks. Sent to the console. */
79 unsigned mods;
[cc29622]80
[61257f4]81 /** Currently active lock keys. */
82 unsigned lock_keys;
[cc29622]83
[5da7199]84 /** IPC session to the console device (for sending key events). */
85 async_sess_t *console_sess;
[cc29622]86
[65b458c4]87 /** @todo What is this actually? */
88 ddf_dev_ops_t ops;
[cc29622]89
[61257f4]90 /** Information for auto-repeat of keys. */
91 usb_kbd_repeat_t repeat;
[cc29622]92
[61257f4]93 /** Mutex for accessing the information about auto-repeat. */
[cddd151]94 fibril_mutex_t repeat_mtx;
[cc29622]95
[61257f4]96 uint8_t *output_buffer;
[cc29622]97
[61257f4]98 size_t output_size;
[cc29622]99
[61257f4]100 size_t led_output_size;
[cc29622]101
[61257f4]102 usb_hid_report_path_t *led_path;
[cc29622]103
[61257f4]104 int32_t *led_data;
[cc29622]105
[61257f4]106 /** State of the structure (for checking before use).
107 *
108 * 0 - not initialized
109 * 1 - initialized
110 * -1 - ready for destroying
111 */
112 int initialized;
[cddd151]113
114 /** DDF function */
115 ddf_fun_t *fun;
[61257f4]116} usb_kbd_t;
117
118/*----------------------------------------------------------------------------*/
119
[73ae3373]120usb_endpoint_description_t usb_hid_kbd_poll_endpoint_description;
[61257f4]121
122const char *HID_KBD_FUN_NAME;
123const char *HID_KBD_CLASS_NAME;
124
125/*----------------------------------------------------------------------------*/
126
[65b458c4]127int usb_kbd_init(struct usb_hid_dev *hid_dev, void **data);
[61257f4]128
[4d3c13e]129bool usb_kbd_polling_callback(struct usb_hid_dev *hid_dev, void *data);
[61257f4]130
131int usb_kbd_is_initialized(const usb_kbd_t *kbd_dev);
132
133int usb_kbd_is_ready_to_destroy(const usb_kbd_t *kbd_dev);
134
[5f6e25e]135void usb_kbd_destroy(usb_kbd_t *kbd_dev);
[61257f4]136
[60c0573]137void usb_kbd_push_ev(struct usb_hid_dev *hid_dev, usb_kbd_t *kbd_dev,
[61257f4]138 int type, unsigned int key);
139
[65b458c4]140void usb_kbd_deinit(struct usb_hid_dev *hid_dev, void *data);
[61257f4]141
[60c0573]142int usb_kbd_set_boot_protocol(struct usb_hid_dev *hid_dev);
[61257f4]143
[ba358ed]144#endif /* USB_HID_KBDDEV_H_ */
[61257f4]145
146/**
147 * @}
148 */
Note: See TracBrowser for help on using the repository browser.