X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=protocol%2Fiwrap%2Fmain.c;h=3abdce8dfc90a6e3e471e3d064d5c4535d8e8248;hb=190dd9a18cefdcc453c6aa9fb14c477b9cc17382;hp=a552afb67ed0a027da50eca8667dc3b19121d3aa;hpb=f4125707399d11a7d80587659c464b9bcddb8c56;p=max%2Ftmk_keyboard.git
diff --git a/protocol/iwrap/main.c b/protocol/iwrap/main.c
index a552afb6..3abdce8d 100644
--- a/protocol/iwrap/main.c
+++ b/protocol/iwrap/main.c
@@ -25,8 +25,9 @@ along with this program. If not, see .
#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
@@ -34,13 +35,13 @@ along with this program. If not, see .
#include "suart.h"
#include "timer.h"
#include "debug.h"
-#include "usb_keycodes.h"
+#include "keycode.h"
#include "command.h"
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_proc();
-#ifdef HOST_VUSB
+ keyboard_task();
+#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();
@@ -320,59 +318,59 @@ static uint8_t console_command(uint8_t c)
static uint8_t key2asc(uint8_t key)
{
switch (key) {
- case KB_A: return 'a';
- case KB_B: return 'b';
- case KB_C: return 'c';
- case KB_D: return 'd';
- case KB_E: return 'e';
- case KB_F: return 'f';
- case KB_G: return 'g';
- case KB_H: return 'h';
- case KB_I: return 'i';
- case KB_J: return 'j';
- case KB_K: return 'k';
- case KB_L: return 'l';
- case KB_M: return 'm';
- case KB_N: return 'n';
- case KB_O: return 'o';
- case KB_P: return 'p';
- case KB_Q: return 'q';
- case KB_R: return 'r';
- case KB_S: return 's';
- case KB_T: return 't';
- case KB_U: return 'u';
- case KB_V: return 'v';
- case KB_W: return 'w';
- case KB_X: return 'x';
- case KB_Y: return 'y';
- case KB_Z: return 'z';
- case KB_1: return '1';
- case KB_2: return '2';
- case KB_3: return '3';
- case KB_4: return '4';
- case KB_5: return '5';
- case KB_6: return '6';
- case KB_7: return '7';
- case KB_8: return '8';
- case KB_9: return '9';
- case KB_0: return '0';
- case KB_ENTER: return '\n';
- case KB_ESCAPE: return 0x1B;
- case KB_BSPACE: return '\b';
- case KB_TAB: return '\t';
- case KB_SPACE: return ' ';
- case KB_MINUS: return '-';
- case KB_EQUAL: return '=';
- case KB_LBRACKET: return '[';
- case KB_RBRACKET: return ']';
- case KB_BSLASH: return '\\';
- case KB_NONUS_HASH: return '\\';
- case KB_SCOLON: return ';';
- case KB_QUOTE: return '\'';
- case KB_GRAVE: return '`';
- case KB_COMMA: return ',';
- case KB_DOT: return '.';
- case KB_SLASH: return '/';
+ case KC_A: return 'a';
+ case KC_B: return 'b';
+ case KC_C: return 'c';
+ case KC_D: return 'd';
+ case KC_E: return 'e';
+ case KC_F: return 'f';
+ case KC_G: return 'g';
+ case KC_H: return 'h';
+ case KC_I: return 'i';
+ case KC_J: return 'j';
+ case KC_K: return 'k';
+ case KC_L: return 'l';
+ case KC_M: return 'm';
+ case KC_N: return 'n';
+ case KC_O: return 'o';
+ case KC_P: return 'p';
+ case KC_Q: return 'q';
+ case KC_R: return 'r';
+ case KC_S: return 's';
+ case KC_T: return 't';
+ case KC_U: return 'u';
+ case KC_V: return 'v';
+ case KC_W: return 'w';
+ case KC_X: return 'x';
+ case KC_Y: return 'y';
+ case KC_Z: return 'z';
+ case KC_1: return '1';
+ case KC_2: return '2';
+ case KC_3: return '3';
+ case KC_4: return '4';
+ case KC_5: return '5';
+ case KC_6: return '6';
+ case KC_7: return '7';
+ case KC_8: return '8';
+ case KC_9: return '9';
+ case KC_0: return '0';
+ case KC_ENTER: return '\n';
+ case KC_ESCAPE: return 0x1B;
+ case KC_BSPACE: return '\b';
+ case KC_TAB: return '\t';
+ case KC_SPACE: return ' ';
+ case KC_MINUS: return '-';
+ case KC_EQUAL: return '=';
+ case KC_LBRACKET: return '[';
+ case KC_RBRACKET: return ']';
+ case KC_BSLASH: return '\\';
+ case KC_NONUS_HASH: return '\\';
+ case KC_SCOLON: return ';';
+ case KC_QUOTE: return '\'';
+ case KC_GRAVE: return '`';
+ case KC_COMMA: return ',';
+ case KC_DOT: return '.';
+ case KC_SLASH: return '/';
default: return 0x00;
}
}