void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) { /* if we used to be "none", toggle to the default value */ if (original_seq.length() == 0) selected_seq = selected_defseq; /* otherwise, toggle to "none" */ else selected_seq.reset(); }
void input_manager::seq_from_tokens(input_seq &seq, const char *string) { // start with a blank sequence seq.reset(); // loop until we're done std::string strcopy = string; char *str = const_cast<char *>(strcopy.c_str()); while (1) { // trim any leading spaces while (*str != 0 && isspace((uint8_t)*str)) str++; // bail if we're done if (*str == 0) return; // find the end of the token and make it upper-case along the way char *strtemp; for (strtemp = str; *strtemp != 0 && !isspace((uint8_t)*strtemp); strtemp++) *strtemp = toupper((uint8_t)*strtemp); char origspace = *strtemp; *strtemp = 0; // look for common stuff input_code code; if (strcmp(str, "OR") == 0) code = input_seq::or_code; else if (strcmp(str, "NOT") == 0) code = input_seq::not_code; else if (strcmp(str, "DEFAULT") == 0) code = input_seq::default_code; else code = code_from_token(str); // translate and add to the sequence seq += code; // advance if (origspace == 0) return; str = strtemp + 1; } }