]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - pjrc/host.c
Merge branch 'fix_layer_delay'
[max/tmk_keyboard.git] / pjrc / host.c
index b69c6cb20c513af34347200bc6fc686c97f6814a..fcf71d57907f6475c7f21ac5bf4cfa9ea7765cd5 100644 (file)
@@ -1,14 +1,36 @@
+/*
+Copyright 2011 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
 #include <stdint.h>
 #include <avr/interrupt.h>
 #include "usb_keycodes.h"
 #include "usb_keyboard.h"
+#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
 #include "usb_mouse.h"
+#endif
+#ifdef EXTRAKEY_ENABLE
+#include "usb_extra.h"
+#endif
 #include "debug.h"
 #include "host.h"
 #include "util.h"
 
 
-#ifdef USB_NKRO_ENABLE
+#ifdef NKRO_ENABLE
 bool keyboard_nkro = false;
 #endif
 
@@ -29,7 +51,7 @@ uint8_t host_keyboard_leds(void)
 /* keyboard report operations */
 void host_add_key(uint8_t key)
 {
-#ifdef USB_NKRO_ENABLE
+#ifdef NKRO_ENABLE
     if (keyboard_nkro) {
         add_key_bit(key);
         return;
@@ -87,7 +109,7 @@ uint8_t host_has_anykey(void)
 
 uint8_t host_get_first_key(void)
 {
-#ifdef USB_NKRO_ENABLE
+#ifdef NKRO_ENABLE
     if (keyboard_nkro) {
         uint8_t i = 0;
         for (; i < REPORT_KEYS && !keyboard_report->keys[i]; i++)
@@ -104,10 +126,28 @@ void host_send_keyboard_report(void)
     usb_keyboard_send_report(keyboard_report);
 }
 
+#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE)
 void host_mouse_send(report_mouse_t *report)
 {
     usb_mouse_send(report->x, report->y, report->v, report->h, report->buttons);
 }
+#endif
+
+#ifdef EXTRAKEY_ENABLE
+void host_system_send(uint16_t data)
+{
+    usb_extra_system_send(data);
+}
+
+void host_consumer_send(uint16_t data)
+{
+    static uint16_t last_data = 0;
+    if (data == last_data) return;
+    last_data = data;
+
+    usb_extra_consumer_send(data);
+}
+#endif
 
 
 static inline void add_key_byte(uint8_t code)