source: mainline/uspace/lib/usb/hidutkbd.h@ 34586183

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 34586183 was cbc00a4d, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Bugfix from previous commit

By mistake, forgot to insert one number. Shall be compilable now.

  • Property mode set to 100644
File size: 6.0 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
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 libusb usb
30 * @{
31 */
32/** @file
33 * @brief USB HID key codes.
34 * @details
35 * This is not a typical header as by default it is equal to empty file.
36 * However, by cleverly defining the USB_HIDUT_KBD_KEY you can use it
37 * to generate conversion tables etc.
38 *
39 * For example, this creates enum for known keys:
40 * @code
41#define USB_HIDUT_KBD_KEY(name, usage_id, l, lc, l1, l2) \
42 USB_KBD_KEY_##name = usage_id,
43typedef enum {
44 #include <usb/hidutkbd.h>
45} usb_key_code_t;
46 @endcode
47 *
48 * Maybe, it might be better that you would place such enums into separate
49 * files and create them as separate step before compiling to allow tools
50 * such as Doxygen get the definitions right.
51 *
52 * @warning This file does not include guard to prevent multiple inclusions
53 * into a single file.
54 */
55
56
57#ifndef USB_HIDUT_KBD_KEY
58/** Declare keyboard key.
59 * @param name Key name (identifier).
60 * @param usage_id Key code (see Keyboard/Keypad Page (0x07) in HUT1.12.
61 * @param letter Corresponding character (0 if not applicable).
62 * @param letter_caps Corresponding character with Caps on.
63 * @param letter_mod1 Corresponding character with modifier #1 on.
64 * @param letter_mod2 Corresponding character with modifier #2 on.
65 */
66#define USB_HIDUT_KBD_KEY(name, usage_id, letter, letter_caps, letter_mod1, letter_mod2)
67
68#endif
69
70#define __NONPRINT(name, usage_id) \
71 USB_HIDUT_KBD_KEY(name, usage_id, 0, 0, 0, 0)
72
73/* US alphabet letters */
74USB_HIDUT_KBD_KEY(A, 0x04, 'a', 'A', 0, 0)
75USB_HIDUT_KBD_KEY(B, 0x05, 'b', 'B', 0, 0)
76USB_HIDUT_KBD_KEY(C, 0x06, 'c', 'C', 0, 0)
77USB_HIDUT_KBD_KEY(D, 0x07, 'd', 'D', 0, 0)
78USB_HIDUT_KBD_KEY(E, 0x08, 'e', 'E', 0, 0)
79USB_HIDUT_KBD_KEY(F, 0x09, 'f', 'F', 0, 0)
80USB_HIDUT_KBD_KEY(G, 0x0A, 'g', 'G', 0, 0)
81USB_HIDUT_KBD_KEY(H, 0x0B, 'h', 'H', 0, 0)
82USB_HIDUT_KBD_KEY(I, 0x0C, 'i', 'I', 0, 0)
83USB_HIDUT_KBD_KEY(J, 0x0D, 'j', 'J', 0, 0)
84USB_HIDUT_KBD_KEY(K, 0x0E, 'k', 'K', 0, 0)
85USB_HIDUT_KBD_KEY(L, 0x0F, 'l', 'L', 0, 0)
86USB_HIDUT_KBD_KEY(M, 0x10, 'm', 'M', 0, 0)
87USB_HIDUT_KBD_KEY(N, 0x11, 'n', 'N', 0, 0)
88USB_HIDUT_KBD_KEY(O, 0x12, 'o', 'O', 0, 0)
89USB_HIDUT_KBD_KEY(P, 0x13, 'p', 'P', 0, 0)
90USB_HIDUT_KBD_KEY(Q, 0x14, 'q', 'Q', 0, 0)
91USB_HIDUT_KBD_KEY(R, 0x15, 'r', 'R', 0, 0)
92USB_HIDUT_KBD_KEY(S, 0x16, 's', 'S', 0, 0)
93USB_HIDUT_KBD_KEY(T, 0x17, 't', 'T', 0, 0)
94USB_HIDUT_KBD_KEY(U, 0x18, 'u', 'U', 0, 0)
95USB_HIDUT_KBD_KEY(V, 0x19, 'v', 'V', 0, 0)
96USB_HIDUT_KBD_KEY(W, 0x1A, 'w', 'W', 0, 0)
97USB_HIDUT_KBD_KEY(X, 0x1B, 'x', 'X', 0, 0)
98USB_HIDUT_KBD_KEY(Y, 0x1C, 'y', 'Y', 0, 0)
99USB_HIDUT_KBD_KEY(Z, 0x1D, 'z', 'Z', 0, 0)
100
101/* Keyboard digits */
102USB_HIDUT_KBD_KEY(1, 0x1E, '1', '!', 0, 0)
103USB_HIDUT_KBD_KEY(2, 0x1F, '2', '@', 0, 0)
104USB_HIDUT_KBD_KEY(3, 0x20, '3', '#', 0, 0)
105USB_HIDUT_KBD_KEY(4, 0x21, '4', '$', 0, 0)
106USB_HIDUT_KBD_KEY(5, 0x22, '5', '%', 0, 0)
107USB_HIDUT_KBD_KEY(6, 0x23, '6', '^', 0, 0)
108USB_HIDUT_KBD_KEY(7, 0x24, '7', '&', 0, 0)
109USB_HIDUT_KBD_KEY(8, 0x25, '8', '*', 0, 0)
110USB_HIDUT_KBD_KEY(9, 0x26, '9', '(', 0, 0)
111USB_HIDUT_KBD_KEY(0, 0x27, '0', ')', 0, 0)
112
113/* More-or-less typewriter command keys */
114USB_HIDUT_KBD_KEY(ENTER, 0x28, '\n', 0, 0, 0)
115USB_HIDUT_KBD_KEY(ESCAPE, 0x29, 0, 0, 0, 0)
116USB_HIDUT_KBD_KEY(BACKSPACE, 0x2A, '\b', 0, 0, 0)
117USB_HIDUT_KBD_KEY(TAB, 0x2B, '\t', 0, 0, 0)
118USB_HIDUT_KBD_KEY(SPACE, 0x2C, ' ', 0, 0, 0)
119
120/* Special (printable) characters */
121USB_HIDUT_KBD_KEY(DASH, 0x2D, '-', '_', 0, 0)
122USB_HIDUT_KBD_KEY(EQUALS, 0x2E, '=', '+', 0, 0)
123USB_HIDUT_KBD_KEY(LEFT_BRACKET, 0x2F, '[', '{', 0, 0)
124USB_HIDUT_KBD_KEY(RIGHT_BRACKET, 0x30, ']', '}', 0, 0)
125USB_HIDUT_KBD_KEY(BACKSLASH, 0x31, '\\', '|', 0, 0)
126USB_HIDUT_KBD_KEY(HASH, 0x32, '#', '~', 0, 0)
127USB_HIDUT_KBD_KEY(SEMICOLON, 0x33, ';', ':', 0, 0)
128USB_HIDUT_KBD_KEY(APOSTROPHE, 0x34, '\'', '"', 0, 0)
129USB_HIDUT_KBD_KEY(GRAVE_ACCENT, 0x35, '`', '~', 0, 0)
130USB_HIDUT_KBD_KEY(COMMA, 0x36, ',', '<', 0, 0)
131USB_HIDUT_KBD_KEY(PERIOD, 0x37, '.', '>', 0, 0)
132USB_HIDUT_KBD_KEY(SLASH, 0x38, '/', '?', 0, 0)
133
134USB_HIDUT_KBD_KEY(CAPS_LOCK, 0x39, 0, 0, 0, 0)
135
136/* Function keys */
137__NONPRINT( F1, 0x3A)
138__NONPRINT( F2, 0x3B)
139__NONPRINT( F3, 0x3C)
140__NONPRINT( F4, 0x3D)
141__NONPRINT( F5, 0x3E)
142__NONPRINT( F6, 0x3F)
143__NONPRINT( F7, 0x40)
144__NONPRINT( F8, 0x41)
145__NONPRINT( F9, 0x42)
146__NONPRINT(F10, 0x43)
147__NONPRINT(F11, 0x44)
148__NONPRINT(F12, 0x45)
149
150/* Cursor movement keys & co. */
151__NONPRINT(PRINT_SCREEN, 0x46)
152__NONPRINT(SCROLL_LOCK, 0x47)
153__NONPRINT(PAUSE, 0x48)
154__NONPRINT(INSERT, 0x49)
155__NONPRINT(HOME, 0x4A)
156__NONPRINT(PAGE_UP, 0x4B)
157__NONPRINT(DELETE, 0x4C)
158__NONPRINT(END, 0x4D)
159__NONPRINT(PAGE_DOWN, 0x4E)
160__NONPRINT(RIGHT_ARROW, 0x4F)
161__NONPRINT(LEFT_ARROW, 0x50)
162__NONPRINT(DOWN_ARROW, 0x51)
163__NONPRINT(UP_ARROW, 0x52)
164
165
166
167
168/* USB_HIDUT_KBD_KEY(, 0x, '', '', 0, 0) */
169
170#undef __NONPRINT
171
172/**
173 * @}
174 */
175
Note: See TracBrowser for help on using the repository browser.