/** Called when command mode is active. * * First pressed key is mapped to first layer defined and evaluated. Use only a-z and 0-9 for commands, others exit this mode. * * @todo: leave automatically on unknown command or timeout, or signal mode through leds. * */ void handleCommand(void) { if(!commandMode()) return; if(activeKeys.keycnt==0) return; struct Key k=activeKeys.keys[0]; uint8_t hid = getKeyCode(k.row, k.col, 0); if(subcmd) { handleSubCmd(k); return; } clearActiveKeys(); clearRowData(); // Char with Meaning: // A:ASCIIPrint, B:BootL, C:PrintConfig, G:GeoArea, H:HardwarePC/Mac, L: SwitchLayout, M:Macro, P:PrintLayout, Q:QuitCommand, T: Trackpoint // Char without Meaning: // O:MouseMode, R:PrintKeyHID switch(hid) { #ifdef PINKYDROP case HID_D: g_pinkydrop = g_pinkydrop ? 0 : 1; printf("\nPinkydrop %d", g_pinkydrop); eeprom_write_byte(&ee_pinkyDrop, g_pinkydrop); setCommandMode(false); break; #endif case HID_V: printf("\nAdNW %s", FW_VERSION); setCommandMode(false); break; case HID_Q: case HID_ESC: printf("\nLeaving command mode::"); setCommandMode(false); break; case HID_B: printf("\nBootloader::"); jump_bootloader(); break; /* case HID_P: // Print Layout: one layer per press on key 'p' printLayout(layer); layer=(layer+1)%LAYERS; if(layer==0) setCommandMode(false); break; */ #ifdef MOUSE_HAS_SCROLL_WHEELS case HID_T: printf("\nTrackpoint:"); tp_id(); setCommandMode(false); break; #endif case HID_L: g_alternateLayer = g_alternateLayer ? 0 : 1; eeprom_write_byte(&ee_alternateLayer,g_alternateLayer); printf("\nAlternate layer %s", g_alternateLayer ? "selected." : "off."); setCommandMode(false); break; #ifdef PS2MOUSE case HID_M: g_mouse_enabled = g_mouse_enabled > 0 ? 0 : 1; printf("\nMouse %sabled", g_mouse_enabled ? "en" : "dis"); setCommandMode(false); break; #endif case HID_X: subcmd=SUB_MACRO; printf("Macro mode true\n"); break; case HID_R: printf("Macro recording\n"); subcmd=SUB_MACRO_REC; break; case HID_H: subcmd=SUB_PASSHASH; break; default: printf("\nUnknown command."); break; } }
/** Called when command mode is active. * * First pressed key is mapped to first layer defined and evaluated. Use only a-z and 0-9 for commands, others exit this mode. * * @todo: leave automatically on unknown command or timeout, or signal mode through leds. * */ void handleCommand(void) { if(!commandMode()) return; if(activeKeys.keycnt==0) return; struct Key k=activeKeys.keys[0]; uint8_t hid = getKeyCode(k.row, k.col, 0); if(subcmd) { handleSubCmd(k); return; } clearActiveKeys(); clearRowData(); // Char with Meaning: // A:ASCIIPrint, B:BootL, C:PrintConfig, G:GeoArea, H:HardwarePC/Mac, L: SwitchLayout, M:Macro, P:PrintLayout, Q:QuitCommand, T: Trackpoint // Char without Meaning: // O:MouseMode, R:PrintKeyHID switch(hid) { case HID_D: g_pinkydrop = !g_pinkydrop; printf("\nPinkydrop %d", g_pinkydrop); setCommandMode(false); break; case HID_V: printf("\nAdNW %s", FW_VERSION); setCommandMode(false); break; case HID_C: PrintConfiguration(); break; case HID_G: // G:GeoArea umschalten printf("\nG:GeoArea::"); subcmd=SUB_GEOAREA; break; case HID_H: // HardwarePC/Mac umschalten printf("\nHardwarePC/Mac::"); subcmd=SUB_PC_MAC; break; case HID_Q: case HID_ESC: printf("\nLeaving command mode::"); setCommandMode(false); break; case HID_B: printf("\nBootloader::"); jump_bootloader(); break; case HID_P: // Print Layout: one layer per press on key 'p' printLayout(layer); layer=(layer+1)%LAYERS; if(layer==0) setCommandMode(false); break; #ifdef MOUSE_HAS_SCROLL_WHEELS case HID_T: printf("\nTrackpoint:"); tp_id(); setCommandMode(false); break; #endif case HID_L: g_alternateLayer=!g_alternateLayer; printf("\nAlternate layer %s", g_alternateLayer ? "selected." : "off."); setCommandMode(false); /* // Layout umschalten printf("\nSwitch layout::"); subcmd=SUB_LAYOUT; */ break; case HID_A: for(uint8_t i=32; i<255; ++i) { if(i%16==0) printf("\n %03d", i); printf("%c ", (char)(i)); if(i==127) i+=33; } setCommandMode(false); break; case HID_M: g_mouse_enabled = g_mouse_enabled > 0 ? 0 : 1; printf("\nMouse %sabled", g_mouse_enabled ? "en" : "dis"); setCommandMode(false); break; case HID_R: // print HID code of pressed key printf("\nHID code read active."); subcmd=SUB_READ; idx=0; break; case HID_X: subcmd=SUB_MACRO; printf("Macro mode true\n"); break; default: printf("\nUnknown command."); break; } }