#include "keyboard.h"
#include "matrix.h"
#include "host.h"
+#include "action.h"
#include "iwrap.h"
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
# include "vusb.h"
# include "usbdrv.h"
#endif
static void sleep(uint8_t term);
static bool console(void);
-static uint8_t console_command(uint8_t c);
+static bool console_command(uint8_t c);
static uint8_t key2asc(uint8_t key);
*/
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
static void disable_vusb(void)
{
// disable interrupt & disconnect to prevent host from enumerating
void change_driver(host_driver_t *driver)
{
+ /*
host_clear_keyboard_report();
host_swap_keyboard_report();
host_clear_keyboard_report();
host_send_keyboard_report();
+ */
+ clear_keyboard();
_delay_ms(1000);
host_set_driver(driver);
}
//pullup_pins();
//set_prr();
- print_enable = true;
- debug_enable = false;
-
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
disable_vusb();
#endif
uart_init(115200);
last_timer = timer_read();
while (true) {
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
if (host_get_driver() == vusb_driver())
usbPoll();
#endif
keyboard_task();
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
if (host_get_driver() == vusb_driver())
vusb_transfer_keyboard();
#endif
+ // TODO: depricated
if (matrix_is_modified() || console()) {
last_timer = timer_read();
sleeping = false;
iwrap_check_connection();
}
+ // TODO: suspend.h
if (host_get_driver() == iwrap_driver()) {
if (sleeping && !insomniac) {
_delay_ms(1); // wait for UART to send
WD_SET(WD_OFF);
}
-ISR(WDT_vect)
-{
- // wake up
-}
-
static bool console(void)
{
// Send to Bluetoot module WT12
}
}
-uint8_t command_extra()
+bool command_extra(uint8_t code)
{
- return console_command(key2asc(host_get_first_key()));
+ return console_command(key2asc(code));
}
-static uint8_t console_command(uint8_t c)
+static bool console_command(uint8_t c)
{
switch (c) {
case 'h':
print("r: reset. software reset by watchdog\n");
print("i: insomniac. prevent KB from sleeping\n");
print("c: iwrap_call. CALL for BT connection.\n");
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
print("u: USB mode. switch to USB.\n");
print("w: BT mode. switch to Bluetooth.\n");
#endif
print("iwrap_call()\n");
iwrap_call();
return 1;
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
case 'u':
print("USB mode\n");
init_vusb();