|
|
@ -63,19 +63,22 @@ static uint8_t numkey2num(uint8_t code);
|
|
|
|
static void switch_default_layer(uint8_t layer);
|
|
|
|
static void switch_default_layer(uint8_t layer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum { ONESHOT, CONSOLE, MOUSEKEY } cmdstate_t;
|
|
|
|
command_state_t command_state = ONESHOT;
|
|
|
|
static cmdstate_t state = ONESHOT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool command_proc(uint8_t code)
|
|
|
|
bool command_proc(uint8_t code)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
switch (command_state) {
|
|
|
|
case ONESHOT:
|
|
|
|
case ONESHOT:
|
|
|
|
if (!IS_COMMAND())
|
|
|
|
if (!IS_COMMAND())
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
return (command_extra(code) || command_common(code));
|
|
|
|
return (command_extra(code) || command_common(code));
|
|
|
|
|
|
|
|
break;
|
|
|
|
case CONSOLE:
|
|
|
|
case CONSOLE:
|
|
|
|
command_console(code);
|
|
|
|
if (IS_COMMAND())
|
|
|
|
|
|
|
|
return (command_extra(code) || command_common(code));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return (command_console_extra(code) || command_console(code));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#ifdef MOUSEKEY_ENABLE
|
|
|
|
#ifdef MOUSEKEY_ENABLE
|
|
|
|
case MOUSEKEY:
|
|
|
|
case MOUSEKEY:
|
|
|
@ -83,12 +86,13 @@ bool command_proc(uint8_t code)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
state = ONESHOT;
|
|
|
|
command_state = ONESHOT;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: Refactoring is needed. */
|
|
|
|
/* This allows to define extra commands. return false when not processed. */
|
|
|
|
/* This allows to define extra commands. return false when not processed. */
|
|
|
|
bool command_extra(uint8_t code) __attribute__ ((weak));
|
|
|
|
bool command_extra(uint8_t code) __attribute__ ((weak));
|
|
|
|
bool command_extra(uint8_t code)
|
|
|
|
bool command_extra(uint8_t code)
|
|
|
@ -96,6 +100,12 @@ bool command_extra(uint8_t code)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool command_console_extra(uint8_t code) __attribute__ ((weak));
|
|
|
|
|
|
|
|
bool command_console_extra(uint8_t code)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
/***********************************************************
|
|
|
|
* Command common
|
|
|
|
* Command common
|
|
|
@ -203,7 +213,7 @@ static bool command_common(uint8_t code)
|
|
|
|
command_console_help();
|
|
|
|
command_console_help();
|
|
|
|
print("\nEnter Console Mode\n");
|
|
|
|
print("\nEnter Console Mode\n");
|
|
|
|
print("C> ");
|
|
|
|
print("C> ");
|
|
|
|
state = CONSOLE;
|
|
|
|
command_state = CONSOLE;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case KC_PAUSE:
|
|
|
|
case KC_PAUSE:
|
|
|
|
clear_keyboard();
|
|
|
|
clear_keyboard();
|
|
|
@ -388,14 +398,14 @@ static bool command_console(uint8_t code)
|
|
|
|
case KC_Q:
|
|
|
|
case KC_Q:
|
|
|
|
case KC_ESC:
|
|
|
|
case KC_ESC:
|
|
|
|
print("\nQuit Console Mode\n");
|
|
|
|
print("\nQuit Console Mode\n");
|
|
|
|
state = ONESHOT;
|
|
|
|
command_state = ONESHOT;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
#ifdef MOUSEKEY_ENABLE
|
|
|
|
#ifdef MOUSEKEY_ENABLE
|
|
|
|
case KC_M:
|
|
|
|
case KC_M:
|
|
|
|
mousekey_console_help();
|
|
|
|
mousekey_console_help();
|
|
|
|
print("\nEnter Mousekey Console\n");
|
|
|
|
print("\nEnter Mousekey Console\n");
|
|
|
|
print("M0>");
|
|
|
|
print("M0>");
|
|
|
|
state = MOUSEKEY;
|
|
|
|
command_state = MOUSEKEY;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -555,7 +565,7 @@ static bool mousekey_console(uint8_t code)
|
|
|
|
mousekey_param = 0;
|
|
|
|
mousekey_param = 0;
|
|
|
|
print("\nQuit Mousekey Console\n");
|
|
|
|
print("\nQuit Mousekey Console\n");
|
|
|
|
print("C> ");
|
|
|
|
print("C> ");
|
|
|
|
state = CONSOLE;
|
|
|
|
command_state = CONSOLE;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
case KC_P:
|
|
|
|
case KC_P:
|
|
|
|
mousekey_param_print();
|
|
|
|
mousekey_param_print();
|
|
|
|