+/*
+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
/* 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;
void host_swap_keyboard_report(void)
{
+ uint8_t sreg = SREG;
+ cli();
report_keyboard_t *tmp = keyboard_report_prev;
keyboard_report_prev = keyboard_report;
keyboard_report = tmp;
+ SREG = sreg;
}
void host_clear_keyboard_report(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++)
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)