]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBKeyboard.h
1 /* Copyright (c) 2010-2011 mbed.org, MIT License
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without
5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 KEY_NEXT_TRACK
, /*!< next Track Button */
35 KEY_PREVIOUS_TRACK
, /*!< Previous track Button */
36 KEY_STOP
, /*!< Stop Button */
37 KEY_PLAY_PAUSE
, /*!< Play/Pause Button */
38 KEY_MUTE
, /*!< Mute Button */
39 KEY_VOLUME_UP
, /*!< Volume Up Button */
40 KEY_VOLUME_DOWN
, /*!< Volume Down Button */
44 KEY_F1
= 128, /* F1 key */
53 KEY_F10
, /* F10 key */
54 KEY_F11
, /* F11 key */
55 KEY_F12
, /* F12 key */
57 KEY_PRINT_SCREEN
, /* Print Screen key */
58 KEY_SCROLL_LOCK
, /* Scroll lock */
59 KEY_CAPS_LOCK
, /* caps lock */
60 KEY_NUM_LOCK
, /* num lock */
61 KEY_INSERT
, /* Insert key */
62 KEY_HOME
, /* Home key */
63 KEY_PAGE_UP
, /* Page Up key */
64 KEY_PAGE_DOWN
, /* Page Down key */
66 RIGHT_ARROW
, /* Right arrow */
67 LEFT_ARROW
, /* Left arrow */
68 DOWN_ARROW
, /* Down arrow */
69 UP_ARROW
, /* Up arrow */
77 * #include "USBKeyboard.h"
85 * key.printf("Hello World\r\n");
92 class USBKeyboard
: public USBHID
, public Stream
{
99 * @param leds Leds bus: first: NUM_LOCK, second: CAPS_LOCK, third: SCROLL_LOCK
100 * @param vendor_id Your vendor_id (default: 0x1235)
101 * @param product_id Your product_id (default: 0x0050)
102 * @param product_release Your preoduct_release (default: 0x0001)
105 USBKeyboard(uint16_t vendor_id
= 0x1235, uint16_t product_id
= 0x0050, uint16_t product_release
= 0x0001):
106 USBHID(0, 0, vendor_id
, product_id
, product_release
, false) {
112 * To send a character defined by a modifier(CTRL, SHIFT, ALT) and the key
115 * //To send CTRL + s (save)
116 * keyboard.keyCode('s', KEY_CTRL);
119 * @param modifier bit 0: KEY_CTRL, bit 1: KEY_SHIFT, bit 2: KEY_ALT (default: 0)
120 * @param key character to send
121 * @returns true if there is no error, false otherwise
123 bool keyCode(uint8_t key
, uint8_t modifier
= 0);
128 * @param c character to be sent
129 * @returns true if there is no error, false otherwise
131 virtual int _putc(int c
);
136 * @param key media key pressed (KEY_NEXT_TRACK, KEY_PREVIOUS_TRACK, KEY_STOP, KEY_PLAY_PAUSE, KEY_MUTE, KEY_VOLUME_UP, KEY_VOLUME_DOWN)
137 * @returns true if there is no error, false otherwise
139 bool mediaControl(MEDIA_KEY key
);
142 * To define the report descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
144 * @returns pointer to the report descriptor
146 virtual uint8_t * reportDesc();
149 * Called when a data is received on the OUT endpoint. Useful to switch on LED of LOCK keys
151 * @returns if handle by subclass, return true
153 virtual bool EPINT_OUT_callback();
156 * Read status of lock keys. Useful to switch-on/off leds according to key pressed. Only the first three bits of the result is important:
157 * - First bit: NUM_LOCK
158 * - Second bit: CAPS_LOCK
159 * - Third bit: SCROLL_LOCK
161 * @returns status of lock keys
163 uint8_t lockStatus();
167 * Get configuration descriptor
169 * @returns pointer to the configuration descriptor
171 virtual uint8_t * configurationDesc();
174 //dummy otherwise it doesn,t compile (we must define all methods of an abstract class)
175 virtual int _getc() {