]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - common/command.c
Fixing typo in console mode
[max/tmk_keyboard.git] / common / command.c
index 2c65f0da78ca7117a442ad86a215858500255c4d..380f2d8c08bde117fc8f8763ac388ece781cc279 100644 (file)
@@ -63,19 +63,22 @@ static uint8_t numkey2num(uint8_t code);
 static void switch_default_layer(uint8_t layer);
 
 
-typedef enum { ONESHOT, CONSOLE, MOUSEKEY } cmdstate_t;
-static cmdstate_t state = ONESHOT;
+command_state_t command_state = ONESHOT;
 
 
 bool command_proc(uint8_t code)
 {
-    switch (state) {
+    switch (command_state) {
         case ONESHOT:
             if (!IS_COMMAND())
                 return false;
             return (command_extra(code) || command_common(code));
+            break;
         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;
 #ifdef MOUSEKEY_ENABLE
         case MOUSEKEY:
@@ -83,12 +86,13 @@ bool command_proc(uint8_t code)
             break;
 #endif
         default:
-            state = ONESHOT;
+            command_state = ONESHOT;
             return false;
     }
     return true;
 }
 
+/* TODO: Refactoring is needed. */
 /* 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)
@@ -96,6 +100,12 @@ bool command_extra(uint8_t code)
     return false;
 }
 
+bool command_console_extra(uint8_t code) __attribute__ ((weak));
+bool command_console_extra(uint8_t code)
+{
+    return false;
+}
+
 
 /***********************************************************
  * Command common
@@ -203,7 +213,7 @@ static bool command_common(uint8_t code)
             command_console_help();
             print("\nEnter Console Mode\n");
             print("C> ");
-            state = CONSOLE;
+            command_state = CONSOLE;
             break;
         case KC_PAUSE:
             clear_keyboard();
@@ -292,7 +302,7 @@ static bool command_common(uint8_t code)
 #endif
             " " STR(BOOTLOADER_SIZE) "\n");
 
-            print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) 
+            print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
                   " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
                   " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
             break;
@@ -388,14 +398,14 @@ static bool command_console(uint8_t code)
         case KC_Q:
         case KC_ESC:
             print("\nQuit Console Mode\n");
-            state = ONESHOT;
+            command_state = ONESHOT;
             return false;
 #ifdef MOUSEKEY_ENABLE
         case KC_M:
             mousekey_console_help();
             print("\nEnter Mousekey Console\n");
             print("M0>");
-            state = MOUSEKEY;
+            command_state = MOUSEKEY;
             return true;
 #endif
         default:
@@ -531,12 +541,12 @@ static void mousekey_console_help(void)
     print("4:  select mk_time_to_max\n");
     print("5:  select mk_wheel_max_speed\n");
     print("6:  select mk_wheel_time_to_max\n");
-    print("p:  print prameters\n");
+    print("p:  print parameters\n");
     print("d:  set default values\n");
-    print("up: increase prameters(+1)\n");
-    print("down:       decrease prameters(-1)\n");
-    print("pgup:       increase prameters(+10)\n");
-    print("pgdown:     decrease prameters(-10)\n");
+    print("up: increase parameters(+1)\n");
+    print("down:       decrease parameters(-1)\n");
+    print("pgup:       increase parameters(+10)\n");
+    print("pgdown:     decrease parameters(-10)\n");
     print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
     print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
     print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");
@@ -555,7 +565,7 @@ static bool mousekey_console(uint8_t code)
             mousekey_param = 0;
             print("\nQuit Mousekey Console\n");
             print("C> ");
-            state = CONSOLE;
+            command_state = CONSOLE;
             return false;
         case KC_P:
             mousekey_param_print();