]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - protocol/iwrap/main.c
Fix rn42.h API
[tmk_firmware.git] / protocol / iwrap / main.c
index c11ff7ab95bcaa3b79cb1aba2cf0899ecbf135c3..3abdce8dfc90a6e3e471e3d064d5c4535d8e8248 100644 (file)
@@ -25,8 +25,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #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
@@ -40,7 +41,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 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);
 
 
@@ -78,7 +79,7 @@ static void pullup_pins(void)
 */
 
 
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
 static void disable_vusb(void)
 {
     // disable interrupt & disconnect to prevent host from enumerating
@@ -108,10 +109,13 @@ static void init_vusb(void)
 
 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);
 }
@@ -131,10 +135,7 @@ int main(void)
     //pullup_pins();
     //set_prr();
 
-    print_enable = true;
-    debug_enable = false;
-
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
     disable_vusb();
 #endif
     uart_init(115200);
@@ -162,15 +163,16 @@ int main(void)
 
     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;
@@ -179,6 +181,7 @@ int main(void)
             iwrap_check_connection();
         }
 
+        // TODO: suspend.h
         if (host_get_driver() == iwrap_driver()) {
             if (sleeping && !insomniac) {
                 _delay_ms(1);   // wait for UART to send
@@ -204,11 +207,6 @@ static void sleep(uint8_t term)
     WD_SET(WD_OFF);
 }
 
-ISR(WDT_vect)
-{
-    // wake up
-}
-
 static bool console(void)
 {
         // Send to Bluetoot module WT12
@@ -247,12 +245,12 @@ static bool console(void)
         }
 }
 
-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':
@@ -261,7 +259,7 @@ static uint8_t console_command(uint8_t c)
             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
@@ -284,7 +282,7 @@ static uint8_t console_command(uint8_t c)
             print("iwrap_call()\n");
             iwrap_call();
             return 1;
-#ifdef HOST_VUSB
+#ifdef PROTOCOL_VUSB
         case 'u':
             print("USB mode\n");
             init_vusb();