aboutsummaryrefslogtreecommitdiff
path: root/common/command.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-02-15 15:34:46 +0900
committertmk <nobody@nowhere>2013-02-15 15:34:46 +0900
commitf8d289e66965f99469292370c3b9200a03254f8e (patch)
tree98b2502fd231d4916270b76632242a15bb27781d /common/command.c
parent7a31451a077a55e1ad97cf8b31a111c7cd311a4d (diff)
parent2b811352a1497e28b946a49f9f31dc15dbda420b (diff)
downloadqmk_firmware-f8d289e66965f99469292370c3b9200a03254f8e.tar.gz
qmk_firmware-f8d289e66965f99469292370c3b9200a03254f8e.zip
Merge branch 'layer_stack'
Diffstat (limited to 'common/command.c')
-rw-r--r--common/command.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/common/command.c b/common/command.c
index 7bb2a23f1..c5b9f0431 100644
--- a/common/command.c
+++ b/common/command.c
@@ -27,6 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27#include "keyboard.h" 27#include "keyboard.h"
28#include "bootloader.h" 28#include "bootloader.h"
29#include "command.h" 29#include "command.h"
30#include "layer_stack.h"
31
30#ifdef MOUSEKEY_ENABLE 32#ifdef MOUSEKEY_ENABLE
31#include "mousekey.h" 33#include "mousekey.h"
32#endif 34#endif
@@ -53,7 +55,7 @@ static void mousekey_console_help(void);
53#endif 55#endif
54 56
55static uint8_t numkey2num(uint8_t code); 57static uint8_t numkey2num(uint8_t code);
56static void switch_layer(uint8_t layer); 58static void switch_default_layer(uint8_t layer);
57 59
58 60
59typedef enum { ONESHOT, CONSOLE, MOUSEKEY } cmdstate_t; 61typedef enum { ONESHOT, CONSOLE, MOUSEKEY } cmdstate_t;
@@ -261,18 +263,16 @@ static bool command_common(uint8_t code)
261#endif 263#endif
262 break; 264 break;
263#endif 265#endif
266 case KC_ESC:
267 case KC_GRV:
264 case KC_0: 268 case KC_0:
265 case KC_F10: 269 switch_default_layer(0);
266 clear_keyboard();
267 switch_layer(0);
268 break; 270 break;
269 case KC_1 ... KC_9: 271 case KC_1 ... KC_9:
270 clear_keyboard(); 272 switch_default_layer((code - KC_1) + 1);
271 switch_layer((code - KC_1) + 1);
272 break; 273 break;
273 case KC_F1 ... KC_F9: 274 case KC_F1 ... KC_F12:
274 clear_keyboard(); 275 switch_default_layer((code - KC_F1) + 1);
275 switch_layer((code - KC_F1) + 1);
276 break; 276 break;
277 default: 277 default:
278 print("?"); 278 print("?");
@@ -541,11 +541,14 @@ static uint8_t numkey2num(uint8_t code)
541 return 0; 541 return 0;
542} 542}
543 543
544static void switch_layer(uint8_t layer) 544static void switch_default_layer(uint8_t layer)
545{ 545{
546 print_val_hex8(current_layer); 546 print_val_hex8(current_layer);
547 print_val_hex8(default_layer); 547 print_val_hex8(default_layer);
548 current_layer = layer;
549 default_layer = layer;
550 print("switch to "); print_val_hex8(layer); 548 print("switch to "); print_val_hex8(layer);
549
550 default_layer = layer;
551 current_layer = 0; /* 0 means default_layer */
552 layer_stack_clear();
553 clear_keyboard();
551} 554}