]> git.gir.st - tmk_keyboard.git/blame_incremental - tmk_core/common/host.c
core: Debug print for system and consumer keys
[tmk_keyboard.git] / tmk_core / common / host.c
... / ...
CommitLineData
1/*
2Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdint.h>
19//#include <avr/interrupt.h>
20#include "keycode.h"
21#include "host.h"
22#include "util.h"
23#include "debug.h"
24
25
26#ifdef NKRO_ENABLE
27bool keyboard_nkro = true;
28#endif
29
30static host_driver_t *driver;
31static uint16_t last_system_report = 0;
32static uint16_t last_consumer_report = 0;
33
34
35void host_set_driver(host_driver_t *d)
36{
37 driver = d;
38}
39
40host_driver_t *host_get_driver(void)
41{
42 return driver;
43}
44
45uint8_t host_keyboard_leds(void)
46{
47 if (!driver) return 0;
48 return (*driver->keyboard_leds)();
49}
50/* send report */
51void host_keyboard_send(report_keyboard_t *report)
52{
53 if (!driver) return;
54 (*driver->send_keyboard)(report);
55
56 if (debug_keyboard) {
57 dprint("keyboard: ");
58 for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
59 dprintf("%02X ", report->raw[i]);
60 }
61 dprint("\n");
62 }
63}
64
65void host_mouse_send(report_mouse_t *report)
66{
67 if (!driver) return;
68 (*driver->send_mouse)(report);
69}
70
71void host_system_send(uint16_t report)
72{
73 if (report == last_system_report) return;
74 last_system_report = report;
75
76 if (!driver) return;
77 (*driver->send_system)(report);
78
79 if (debug_keyboard) {
80 dprintf("system: %04X\n", report);
81 }
82}
83
84void host_consumer_send(uint16_t report)
85{
86 if (report == last_consumer_report) return;
87 last_consumer_report = report;
88
89 if (!driver) return;
90 (*driver->send_consumer)(report);
91
92 if (debug_keyboard) {
93 dprintf("consumer: %04X\n", report);
94 }
95}
96
97uint16_t host_last_sysytem_report(void)
98{
99 return last_system_report;
100}
101
102uint16_t host_last_consumer_report(void)
103{
104 return last_consumer_report;
105}
Imprint / Impressum