Exemplo n.º 1
0
Arquivo: command.c Projeto: obra/adnw
void handleSubCmd(struct Key k) {
    uint8_t h =getKeyCode(k.row, k.col, getActiveLayer());
    switch( subcmd )
    {
        case SUB_READ:
            if(h == HID_ESC) {
                printf("\nSubRead terminated");
                setCommandMode(false);
            } else {
                if(idx>=MAXLEN) {
                    idx=0;
                    setCommandMode(false);
                }
                str[idx++]=h;
                printf("\n%2d %d: ",idx,h);
                for(uint8_t i=0; i<idx; ++i)
                    printf("%02x", str[i]);
            }
            break;
        case SUB_LAYOUT:
        {
            // das nŠchste Layout auf die gedrŸckte Spalte setzen, also 12 verschiedene Layouts verfŸgbar
            /*
            Layout nextLayout = k.col < LAYOUTS ? k.col : eeprom_read_byte (&alternateLayoutNr);
            eeprom_write_byte(&alternateLayoutNr, nextLayout);
            PrintConfiguration();
            */
            printf("\nLAYOUTS not yet implemented");
            setCommandMode(false);
            break;
        }
        case SUB_GEOAREA:
        {
            // den geografischen Bereich auf die gedrŸckte Spalte setzen, DE, GB und US verfŸgbar
            GeoArea nextAlternateGeoArea = k.col < 3 ? k.col : eeprom_read_byte (&alternateGeoArea);
            eeprom_write_byte(&alternateGeoArea, nextAlternateGeoArea);
            PrintConfiguration();
            setCommandMode(false);
            break;
        }
        case SUB_PC_MAC:
        {
            // die Hardware auf die gedrŸckte Spalte setzen, PC/Mac verfŸgbar
            MacOrPC  nextAltMacOrPC = k.col < 2 ? k.col : eeprom_read_byte (&altMacOrPC);
            eeprom_write_byte(&altMacOrPC, nextAltMacOrPC);
            PrintConfiguration();
            setCommandMode(false);
            break;
        }
        case SUB_MACRO:
            setMacroMode(true);
            activateMacro(k.row*ROWS+k.col);
            setCommandMode(false);
            break;
        default:
            break;
    }
    clearActiveKeys();
    clearRowData();
}
Exemplo n.º 2
0
 inline int Print(){return PrintConfiguration();};
Exemplo n.º 3
0
Arquivo: command.c Projeto: obra/adnw
/** 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;
    }
}