void FarPlugin::Config() { FarDialog & dlg = Dialogs()[L"SetupDialog"]; dlg.ResetControls(); dlg.LoadState(options); bool Repeat = true; while (Repeat) { Repeat = false; intptr_t res = dlg.Execute(); switch (res) { case 0: dlg.SaveState(options); SaveOptions(); Repeat = false; break; case 1: KeyConfig(); break; case 2: About(); break; case 3: SoundConfig(); break; } } }
void FarPlugin::Config() { FarDialog& dlg = Dialogs()["SetupDialog"]; dlg.ResetControls(); dlg.LoadState(options); rep: int res = dlg.Execute(); switch(res) { case 0: dlg.SaveState(options); SaveOptions(); break; case 1: KeyConfig(); goto rep; case 2: About(); goto rep; case 3: static int bn = 0; beep(bn); if (++bn > 2) { bn = 0; } goto rep; } }
void controlsParseConfig(char* line2) { char line[100]; strncpy(line, line2, 100); while (strlen(line) > 0 && (line[strlen(line)-1] == '\n' || line[strlen(line)-1] == ' ')) line[strlen(line)-1] = '\0'; if (line[0] == '(') { char* bracketEnd; if ((bracketEnd = strrchr(line, ')')) != 0) { *bracketEnd = '\0'; const char* name = line+1; keyConfigs.push_back(KeyConfig()); KeyConfig* config = &keyConfigs.back(); strncpy(config->name, name, 32); config->name[31] = '\0'; for (int i=0; i<NUM_BINDABLE_BUTTONS; i++) config->funcKeys[i] = FUNC_KEY_NONE; } return; } char* equalsPos; if ((equalsPos = strrchr(line, '=')) != 0 && equalsPos != line+strlen(line)-1) { *equalsPos = '\0'; if (strcasecmp(line, "config") == 0) { selectedKeyConfig = atoi(equalsPos+1); } else { int dsKey = -1; for (int i=0; i<NUM_BINDABLE_BUTTONS; i++) { if (strcasecmp(line, dsKeyNames[i]) == 0) { dsKey = i; break; } } int gbKey = -1; for (int i=0; i<NUM_FUNC_KEYS; i++) { if (strcasecmp(equalsPos+1, gbKeyNames[i]) == 0) { gbKey = i; break; } } if (gbKey != -1 && dsKey != -1) { KeyConfig* config = &keyConfigs.back(); config->funcKeys[dsKey] = gbKey; } } } }
void updateKeyConfigChooser() { bool redraw = false; int& option = keyConfigChooser_option; KeyConfig* config = &keyConfigs[selectedKeyConfig]; if (keyJustPressed(KEY_B)) { loadKeyConfig(); closeSubMenu(); } else if (keyJustPressed(KEY_X)) { keyConfigs.push_back(KeyConfig(*config)); selectedKeyConfig = keyConfigs.size()-1; char name[32]; sprintf(name, "Custom %d", keyConfigs.size()-1); strcpy(keyConfigs.back().name, name); option = -1; redraw = true; } else if (keyJustPressed(KEY_Y)) { if (selectedKeyConfig != 0) /* can't erase the default */ { keyConfigs.erase(keyConfigs.begin() + selectedKeyConfig); if (selectedKeyConfig >= keyConfigs.size()) selectedKeyConfig = keyConfigs.size() - 1; redraw = true; } } else if (keyPressedAutoRepeat(KEY_DOWN)) { if (option == NUM_BINDABLE_BUTTONS-1) option = -1; #if defined(_3DS) else if(option == 11) //Skip nonexistant keys option = 14; else if(option == 15) option = 24; #endif else option++; redraw = true; } else if (keyPressedAutoRepeat(KEY_UP)) { if (option == -1) option = NUM_BINDABLE_BUTTONS-1; #if defined(_3DS) else if(option == 14) //Skip nonexistant keys option = 11; else if(option == 24) option = 15; #endif else option--; redraw = true; } else if (keyPressedAutoRepeat(KEY_LEFT)) { if (option == -1) { if (selectedKeyConfig == 0) selectedKeyConfig = keyConfigs.size()-1; else selectedKeyConfig--; } else { config->funcKeys[option]--; if (config->funcKeys[option] < 0) config->funcKeys[option] = NUM_FUNC_KEYS-1; } redraw = true; } else if (keyPressedAutoRepeat(KEY_RIGHT)) { if (option == -1) { selectedKeyConfig++; if (selectedKeyConfig >= keyConfigs.size()) selectedKeyConfig = 0; } else { config->funcKeys[option]++; if (config->funcKeys[option] >= NUM_FUNC_KEYS) config->funcKeys[option] = 0; } redraw = true; } if (redraw) doAtVBlank(redrawKeyConfigChooser); }