Esempio n. 1
0
File: command.c Progetto: corum/adnw
void handleSubCmd(struct Key k) {
    uint8_t type=PH_TYPE_ALNUMSYM;
    uint8_t len=12;
    char password[PH_MAX_LEN+1];
    uint8_t ret;

    switch( subcmd )
    {
        case SUB_MACRO:
            setMacroMode(true);
            activateMacro(k.row*ROWS+k.col);
            setCommandMode(false);
            break;
        case SUB_MACRO_REC:
            setMacroRecording(1+k.row*ROWS+k.col);
            setCommandMode(false);
            break;
        case SUB_PASSHASH:
            ret = passHash(password, len, type, "secret", "key", "tag");
            printf("\nPH len=%d type=%d = %s", len, type, password);
            setCommandMode(false);
            break;

        default:
            setCommandMode(false);
            break;
    }
    clearActiveKeys();
    clearRowData();
}
Esempio n. 2
0
File: command.c Progetto: 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();
}
Esempio n. 3
0
/**
 * \brief
 * \detailed
 * \param pvParameters - pointer to parameters
 */
static void handleHttpRequestsTask(void *pvParameters) {
	TickType_t xLastWakeTime;
	xLastWakeTime = xTaskGetTickCount();
	char response, stringToPrint[30];

	while (1) {
		response = process_client_request();

//		get_next_client_response();

		if (response != ' ' && response != '\0') {
			sprintf(stringToPrint, "Command: %c", response);
			displayToTerminal(stringToPrint);

			if (response == 'A') {
				setCommandMode(-2);
			} else if (response == 'C') {
				setCommandMode(-1);
			} else if (response == '0') {
				setCommandMode(STOP_MOVEMENT);
			} else if (response == '1') {
				setCommandMode(FORWARD_MOVEMENT);
			} else if (response == '2') {
				setCommandMode(BACKWARD_MOVEMENT);
			} else if (response == '3') {
				setCommandMode(ROTATE_LEFT_MOVEMENT);
			} else if (response == '4') {
				setCommandMode(ROTATE_RIGHT_MOVEMENT);
			} else if (response == '5') {
				setCommandMode(5);
			} else if (response == '6') {
				setCommandMode(6);
			}
		}

		vTaskDelayUntil(&xLastWakeTime, (5000 / portTICK_PERIOD_MS));
	}
}
Esempio n. 4
0
/*
 *  Constructs a QG_CommandWidget as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
QG_CommandWidget::QG_CommandWidget(QWidget* parent, const char* name, Qt::WindowFlags fl)
    : QWidget(parent, fl)
    , actionHandler(nullptr)
{
    setObjectName(name);
    setupUi(this);
    connect(leCommand, SIGNAL(command(QString)), this, SLOT(handleCommand(QString)));
    connect(leCommand, SIGNAL(escape()), this, SLOT(escape()));
    connect(leCommand, SIGNAL(focusOut()), this, SLOT(setNormalMode()));
    connect(leCommand, SIGNAL(focusIn()), this, SLOT(setCommandMode()));
    connect(leCommand, SIGNAL(tabPressed()), this, SLOT(tabPressed()));
    connect(leCommand, SIGNAL(clearCommandsHistory()), teHistory, SLOT(clear()));
    connect(leCommand, SIGNAL(message(QString)), this, SLOT(appendHistory(QString)));
    connect(leCommand, &QG_CommandEdit::keycode, this, &QG_CommandWidget::handleKeycode);

    auto a1 = new QAction(QObject::tr("Keycode Mode"), this);
    a1->setObjectName("keycode_action");
    a1->setCheckable(true);
    connect(a1, &QAction::toggled, this, &QG_CommandWidget::setKeycodeMode);
    options_button->addAction(a1);

    QSettings settings;
    if (settings.value("Widgets/KeycodeMode", false).toBool())
    {
        leCommand->keycode_mode = true;
        a1->setChecked(true);
    }

    auto a2 = new QAction(QObject::tr("Load Command File"), this);
    connect(a2, &QAction::triggered, this, &QG_CommandWidget::chooseCommandFile);
    options_button->addAction(a2);

    auto a3 = new QAction(QObject::tr("Paste Multiple Commands"), this);
    connect(a3, &QAction::triggered, leCommand, &QG_CommandEdit::modifiedPaste);
    options_button->addAction(a3);

    options_button->setStyleSheet("QToolButton::menu-indicator { image: none; }");
}
Esempio n. 5
0
    void initializeVoiceRecognition()
    {
        auto session = senseManager->QuerySession();

        // 音声入力デバイスを作成する
        audioSource = session->CreateAudioSource();
        if ( audioSource == 0 ){
            throw std::runtime_error( "音声入力デバイスの作成に失敗しました" );
        }

        // 音声入力デバイスを列挙する
        std::cout << "音声入力デバイス" << std::endl;

        PXCAudioSource::DeviceInfo device = {};

        audioSource->ScanDevices();
        for ( int i = 0;; ++i ) {
            PXCAudioSource::DeviceInfo dinfo = {};
            auto sts = audioSource->QueryDeviceInfo( i, &dinfo );
            if ( sts < PXC_STATUS_NO_ERROR ) {
                break;
            }

            // 音声入力デバイス名を表示する
            std::wcout << "\t" << dinfo.name << std::endl;

            // 最初のデバイスを使う
            if ( i == 0 ){
                device = dinfo;
            }
        }

        // 音声入力デバイスを設定する
        auto sts = audioSource->SetDevice( &device );
        if ( sts < PXC_STATUS_NO_ERROR ) {
            throw std::runtime_error( "音声入力デバイスの設定に失敗しました" );
        }


        // 音声認識エンジンを列挙する
        std::cout << "音声認識エンジン" << std::endl;

        PXCSession::ImplDesc in = {};
        PXCSession::ImplDesc out = {};
        in.cuids[0] = PXCSpeechRecognition::CUID;

        for ( int i = 0; ; ++i ) {
            // 音声認識エンジンを取得する
            auto sts = session->QueryImpl( &in, i, &out );
            if ( sts < PXC_STATUS_NO_ERROR ) {
                break;
            }

            // 音声認識エンジン名称を表示する
            std::wcout << "\t" << out.friendlyName << std::endl;
        }


        // 最初の音声認識エンジンを使う
        sts = session->QueryImpl( &in, 0, &out );

        // 音声認識エンジンオブジェクトを作成する
        sts = session->CreateImpl<PXCSpeechRecognition>( &out, &recognition );
        if ( sts < PXC_STATUS_NO_ERROR ) {
            throw std::runtime_error( "音声認識エンジンオブジェクトの作成に失敗しました" );
        }

        // 対応言語を列挙する
        PXCSpeechRecognition::ProfileInfo profile;

        for ( int j = 0;; ++j ) {
            // 音声認識エンジンが持っているプロファイルを取得する
            PXCSpeechRecognition::ProfileInfo pinfo;
            sts = recognition->QueryProfile( j, &pinfo );
            if ( sts < PXC_STATUS_NO_ERROR ) {
                break;
            }

            // 対応言語を表示する
            std::wcout << "\t\t" << LanguageToString( pinfo.language ) << std::endl;

            // 英語のエンジンを使う(日本語対応時には日本語に変更する)
            if ( pinfo.language == PXCSpeechRecognition::LANGUAGE_JP_JAPANESE ){
                profile = pinfo;
            }
        }

        if ( profile.language == 0 ){
            throw std::runtime_error( "選択した音声認識エンジンが見つかりませんでした" );
        }

        // 使用する言語を設定する
        sts = recognition->SetProfile( &profile );
        if ( sts < PXC_STATUS_NO_ERROR ) {
            throw std::runtime_error( "音声認識エンジンオブジェクトの設定に失敗しました" );
        }

        // コマンドモードに設定する
        setCommandMode();

        // 音声認識を開始する
        sts = recognition->StartRec( audioSource, this );
        if ( sts < PXC_STATUS_NO_ERROR ) {
            throw std::runtime_error( "音声認識の開始に失敗しました" );
        }
    }
Esempio n. 6
0
File: command.c Progetto: corum/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) {
#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;
    }
}
Esempio n. 7
0
File: command.c Progetto: 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;
    }
}