2 Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //#include <avr/interrupt.h>
26 # include "keycode_config.h"
27 extern keymap_config_t keymap_config
;
30 static host_driver_t
*driver
;
31 static uint16_t last_system_report
= 0;
32 static uint16_t last_consumer_report
= 0;
34 void host_set_driver(host_driver_t
*d
) { driver
= d
; }
36 host_driver_t
*host_get_driver(void) { return driver
; }
38 uint8_t host_keyboard_leds(void) {
39 if (!driver
) return 0;
40 return (*driver
->keyboard_leds
)();
43 led_t
host_keyboard_led_state(void) {
44 if (!driver
) return (led_t
){0};
45 return (led_t
)((*driver
->keyboard_leds
)());
49 void host_keyboard_send(report_keyboard_t
*report
) {
51 #if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP)
52 if (keyboard_protocol
&& keymap_config
.nkro
) {
53 /* The callers of this function assume that report->mods is where mods go in.
54 * But report->nkro.mods can be at a different offset if core keyboard does not have a report ID.
56 report
->nkro
.mods
= report
->mods
;
57 report
->nkro
.report_id
= REPORT_ID_NKRO
;
61 #ifdef KEYBOARD_SHARED_EP
62 report
->report_id
= REPORT_ID_KEYBOARD
;
65 (*driver
->send_keyboard
)(report
);
68 dprint("keyboard_report: ");
69 for (uint8_t i
= 0; i
< KEYBOARD_REPORT_SIZE
; i
++) {
70 dprintf("%02X ", report
->raw
[i
]);
76 void host_mouse_send(report_mouse_t
*report
) {
78 #ifdef MOUSE_SHARED_EP
79 report
->report_id
= REPORT_ID_MOUSE
;
81 (*driver
->send_mouse
)(report
);
84 void host_system_send(uint16_t report
) {
85 if (report
== last_system_report
) return;
86 last_system_report
= report
;
89 (*driver
->send_system
)(report
);
92 void host_consumer_send(uint16_t report
) {
93 if (report
== last_consumer_report
) return;
94 last_consumer_report
= report
;
97 (*driver
->send_consumer
)(report
);
100 uint16_t host_last_system_report(void) { return last_system_report
; }
102 uint16_t host_last_consumer_report(void) { return last_consumer_report
; }