]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/common/host.c
ergodox qwerty_code_friendly: add macro keys (#1918)
[qmk_firmware.git] / tmk_core / common / host.c
1 /*
2 Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
3
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.
8
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.
13
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/>.
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 static host_driver_t *driver;
26 static uint16_t last_system_report = 0;
27 static uint16_t last_consumer_report = 0;
28
29
30 void host_set_driver(host_driver_t *d)
31 {
32     driver = d;
33 }
34
35 host_driver_t *host_get_driver(void)
36 {
37     return driver;
38 }
39
40 uint8_t host_keyboard_leds(void)
41 {
42     if (!driver) return 0;
43     return (*driver->keyboard_leds)();
44 }
45 /* send report */
46 void host_keyboard_send(report_keyboard_t *report)
47 {
48     if (!driver) return;
49     (*driver->send_keyboard)(report);
50
51     if (debug_keyboard) {
52         dprint("keyboard_report: ");
53         for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
54             dprintf("%02X ", report->raw[i]);
55         }
56         dprint("\n");
57     }
58 }
59
60 void host_mouse_send(report_mouse_t *report)
61 {
62     if (!driver) return;
63     (*driver->send_mouse)(report);
64 }
65
66 void host_system_send(uint16_t report)
67 {
68     if (report == last_system_report) return;
69     last_system_report = report;
70
71     if (!driver) return;
72     (*driver->send_system)(report);
73 }
74
75 void host_consumer_send(uint16_t report)
76 {
77     if (report == last_consumer_report) return;
78     last_consumer_report = report;
79
80     if (!driver) return;
81     (*driver->send_consumer)(report);
82 }
83
84 uint16_t host_last_system_report(void)
85 {
86     return last_system_report;
87 }
88
89 uint16_t host_last_consumer_report(void)
90 {
91     return last_consumer_report;
92 }