2#include "hid_usage_desktop.h"
3#include "hid_usage_button.h"
4#include "hid_usage_keyboard.h"
5#include "hid_usage_consumer.h"
6#include "hid_usage_led.h"
13#define HID_KB_MAX_KEYS 6
15#define HID_CONSUMER_MAX_KEYS 2
18#define HID_CONSUMER_BRIGHTNESS_INCREMENT 0x006F
19#define HID_CONSUMER_BRIGHTNESS_DECREMENT 0x0070
20#define HID_CONSUMER_FN_GLOBE 0x029D
22#define HID_KEYBOARD_NONE 0x00
26 KEY_MOD_LEFT_CTRL = (1 << 8),
27 KEY_MOD_LEFT_SHIFT = (1 << 9),
28 KEY_MOD_LEFT_ALT = (1 << 10),
29 KEY_MOD_LEFT_GUI = (1 << 11),
30 KEY_MOD_RIGHT_CTRL = (1 << 12),
31 KEY_MOD_RIGHT_SHIFT = (1 << 13),
32 KEY_MOD_RIGHT_ALT = (1 << 14),
33 KEY_MOD_RIGHT_GUI = (1 << 15),
37static const uint16_t hid_asciimap[] = {
70 HID_KEYBOARD_SPACEBAR,
71 HID_KEYBOARD_1 | KEY_MOD_LEFT_SHIFT,
72 HID_KEYBOARD_APOSTROPHE | KEY_MOD_LEFT_SHIFT,
73 HID_KEYBOARD_3 | KEY_MOD_LEFT_SHIFT,
74 HID_KEYBOARD_4 | KEY_MOD_LEFT_SHIFT,
75 HID_KEYBOARD_5 | KEY_MOD_LEFT_SHIFT,
76 HID_KEYBOARD_7 | KEY_MOD_LEFT_SHIFT,
77 HID_KEYBOARD_APOSTROPHE,
78 HID_KEYBOARD_9 | KEY_MOD_LEFT_SHIFT,
79 HID_KEYBOARD_0 | KEY_MOD_LEFT_SHIFT,
80 HID_KEYBOARD_8 | KEY_MOD_LEFT_SHIFT,
81 HID_KEYBOARD_EQUAL_SIGN | KEY_MOD_LEFT_SHIFT,
96 HID_KEYBOARD_SEMICOLON | KEY_MOD_LEFT_SHIFT,
97 HID_KEYBOARD_SEMICOLON,
98 HID_KEYBOARD_COMMA | KEY_MOD_LEFT_SHIFT,
99 HID_KEYBOARD_EQUAL_SIGN,
100 HID_KEYBOARD_DOT | KEY_MOD_LEFT_SHIFT,
101 HID_KEYBOARD_SLASH | KEY_MOD_LEFT_SHIFT,
102 HID_KEYBOARD_2 | KEY_MOD_LEFT_SHIFT,
103 HID_KEYBOARD_A | KEY_MOD_LEFT_SHIFT,
104 HID_KEYBOARD_B | KEY_MOD_LEFT_SHIFT,
105 HID_KEYBOARD_C | KEY_MOD_LEFT_SHIFT,
106 HID_KEYBOARD_D | KEY_MOD_LEFT_SHIFT,
107 HID_KEYBOARD_E | KEY_MOD_LEFT_SHIFT,
108 HID_KEYBOARD_F | KEY_MOD_LEFT_SHIFT,
109 HID_KEYBOARD_G | KEY_MOD_LEFT_SHIFT,
110 HID_KEYBOARD_H | KEY_MOD_LEFT_SHIFT,
111 HID_KEYBOARD_I | KEY_MOD_LEFT_SHIFT,
112 HID_KEYBOARD_J | KEY_MOD_LEFT_SHIFT,
113 HID_KEYBOARD_K | KEY_MOD_LEFT_SHIFT,
114 HID_KEYBOARD_L | KEY_MOD_LEFT_SHIFT,
115 HID_KEYBOARD_M | KEY_MOD_LEFT_SHIFT,
116 HID_KEYBOARD_N | KEY_MOD_LEFT_SHIFT,
117 HID_KEYBOARD_O | KEY_MOD_LEFT_SHIFT,
118 HID_KEYBOARD_P | KEY_MOD_LEFT_SHIFT,
119 HID_KEYBOARD_Q | KEY_MOD_LEFT_SHIFT,
120 HID_KEYBOARD_R | KEY_MOD_LEFT_SHIFT,
121 HID_KEYBOARD_S | KEY_MOD_LEFT_SHIFT,
122 HID_KEYBOARD_T | KEY_MOD_LEFT_SHIFT,
123 HID_KEYBOARD_U | KEY_MOD_LEFT_SHIFT,
124 HID_KEYBOARD_V | KEY_MOD_LEFT_SHIFT,
125 HID_KEYBOARD_W | KEY_MOD_LEFT_SHIFT,
126 HID_KEYBOARD_X | KEY_MOD_LEFT_SHIFT,
127 HID_KEYBOARD_Y | KEY_MOD_LEFT_SHIFT,
128 HID_KEYBOARD_Z | KEY_MOD_LEFT_SHIFT,
129 HID_KEYBOARD_OPEN_BRACKET,
130 HID_KEYBOARD_BACKSLASH,
131 HID_KEYBOARD_CLOSE_BRACKET,
132 HID_KEYBOARD_6 | KEY_MOD_LEFT_SHIFT,
133 HID_KEYBOARD_MINUS | KEY_MOD_LEFT_SHIFT,
134 HID_KEYBOARD_GRAVE_ACCENT,
161 HID_KEYBOARD_OPEN_BRACKET | KEY_MOD_LEFT_SHIFT,
162 HID_KEYBOARD_BACKSLASH | KEY_MOD_LEFT_SHIFT,
163 HID_KEYBOARD_CLOSE_BRACKET | KEY_MOD_LEFT_SHIFT,
164 HID_KEYBOARD_GRAVE_ACCENT | KEY_MOD_LEFT_SHIFT,
175typedef void (*HidStateCallback)(
bool state,
void* context);
178#define HID_ASCII_TO_KEY(x) (((uint8_t)x < 128) ? (hid_asciimap[(uint8_t)x]) : HID_KEYBOARD_NONE)
181enum HidKeyboardLeds {
182 HID_KB_LED_NUM = (1 << 0),
183 HID_KB_LED_CAPS = (1 << 1),
184 HID_KB_LED_SCROLL = (1 << 2),
188enum HidMouseButtons {
189 HID_MOUSE_BTN_LEFT = (1 << 0),
190 HID_MOUSE_BTN_RIGHT = (1 << 1),
191 HID_MOUSE_BTN_WHEEL = (1 << 2),
198bool furi_hal_hid_is_connected(
void);
204uint8_t furi_hal_hid_get_led_state(
void);
211void furi_hal_hid_set_state_callback(HidStateCallback cb,
void* ctx);
217bool furi_hal_hid_kb_press(uint16_t button);
223bool furi_hal_hid_kb_release(uint16_t button);
228bool furi_hal_hid_kb_release_all(
void);
235bool furi_hal_hid_mouse_move(int8_t dx, int8_t dy);
241bool furi_hal_hid_mouse_press(uint8_t button);
247bool furi_hal_hid_mouse_release(uint8_t button);
253bool furi_hal_hid_mouse_scroll(int8_t delta);
259bool furi_hal_hid_consumer_key_press(uint16_t button);
265bool furi_hal_hid_consumer_key_release(uint16_t button);
270bool furi_hal_hid_consumer_key_release_all(
void);
Definition furi_hal_usb_hid.h:168