]> git.gir.st - tmk_keyboard.git/blob - host.h
added HHKB/README and clean some codes.
[tmk_keyboard.git] / host.h
1 #ifndef HOST_H
2 #define HOST_H
3
4 #include <stdint.h>
5
6
7 /* report id */
8 #define REPORT_ID_MOUSE 1
9 #define REPORT_ID_SYSTEM 2
10 #define REPORT_ID_AUDIO 3
11
12 /* keyboard Modifiers in boot protocol report */
13 #define BIT_LCTRL (1<<0)
14 #define BIT_LSHIFT (1<<1)
15 #define BIT_LALT (1<<2)
16 #define BIT_LGUI (1<<3)
17 #define BIT_RCTRL (1<<4)
18 #define BIT_RSHIFT (1<<5)
19 #define BIT_RALT (1<<6)
20 #define BIT_RGUI (1<<7)
21 #define BIT_LCTL BIT_LCTRL
22 #define BIT_RCTL BIT_RCTRL
23 #define BIT_LSFT BIT_LSHIFT
24 #define BIT_RSFT BIT_RSHIFT
25
26 /* mouse buttons */
27 #define MOUSE_BTN1 (1<<0)
28 #define MOUSE_BTN2 (1<<1)
29 #define MOUSE_BTN3 (1<<2)
30 #define MOUSE_BTN4 (1<<3)
31 #define MOUSE_BTN5 (1<<4)
32
33 // Consumer Page(0x0C) Consumer Control(0x01)
34 #define AUDIO_VOL_UP (1<<0)
35 #define AUDIO_VOL_DOWN (1<<1)
36 #define AUDIO_MUTE (1<<2)
37
38 // Generic Desktop Page(0x01) System Control(0x80)
39 #define SYSTEM_POWER_DOWN (1<<0)
40 #define SYSTEM_SLEEP (1<<1)
41 #define SYSTEM_WAKE_UP (1<<2)
42
43
44 #if defined(HOST_PJRC)
45 # include "usb.h"
46 # if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
47 # define REPORT_KEYS KBD2_REPORT_KEYS
48 # else
49 # define REPORT_KEYS KBD_REPORT_KEYS
50 # endif
51 #elif defined(HOST_VUSB)
52 # define REPORT_KEYS 6
53 #endif
54
55 typedef struct {
56 uint8_t mods;
57 uint8_t rserved;
58 uint8_t keys[REPORT_KEYS];
59 } report_keyboard_t;
60
61 typedef struct {
62 uint8_t report_id;
63 uint8_t buttons;
64 int8_t x;
65 int8_t y;
66 int8_t v;
67 int8_t h;
68 } report_mouse_t;
69
70
71 #ifdef USB_NKRO_ENABLE
72 extern bool keyboard_nkro;
73 #endif
74
75 extern report_keyboard_t *keyboard_report;
76 extern report_keyboard_t *keyboard_report_prev;
77
78
79 uint8_t host_keyboard_leds(void);
80
81 /* keyboard report operations */
82 void host_add_key(uint8_t key);
83 void host_add_mod_bit(uint8_t mod);
84 void host_set_mods(uint8_t mods);
85 void host_add_code(uint8_t code);
86 void host_swap_keyboard_report(void);
87 void host_clear_keyboard_report(void);
88 uint8_t host_has_anykey(void);
89 uint8_t host_get_first_key(void);
90
91
92 void host_send_keyboard_report(void);
93 #if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
94 void host_mouse_send(report_mouse_t *report);
95 #endif
96 #ifdef USB_EXTRA_ENABLE
97 void host_system_send(uint8_t data);
98 void host_audio_send(uint8_t data);
99 #endif
100
101 #endif
Imprint / Impressum