void nds_flush(int ignore) { memset(&old_touch_coords, 0, sizeof(old_touch_coords)); memset(&touch_coords, 0, sizeof(touch_coords)); while (1) { int held; swiWaitForVBlank(); scanKeys(); held = nds_keysHeld(); if ((held & ~ignore) == 0) { return; } } }
void nds_config_key() { int prev_held = 0; int held = 0; nds_cmd_t cmd; char buf[BUFSZ]; u16 key; char command[INPUT_BUFFER_SIZE]; nds_flush(0); nds_draw_prompt("Press the key to modify."); while (1) { swiWaitForVBlank(); scanKeys(); prev_held = held; held = nds_keysHeld(); /* We don't let the user configure these */ if ((prev_held & chord_keys) && (held == 0) && (nds_count_bits(prev_held) == 1)) { key = prev_held; break; } else if ((held & cmd_key) || ((held & ~chord_keys) == 0)) { continue; } else if (held) { key = held; break; } } nds_clear_prompt(); cmd = nds_get_config_cmd(key); if (cmd.f_char < 0) { return; } command[0] = cmd.f_char; command[1] = '\0'; if (! nds_input_buffer_is_empty()) { strcat(command, nds_input_buffer_shiftall()); DEBUG_PRINT("cmd: %s\n", command); sprintf(buf, "Mapped %s to %s x%s.", nds_key_to_string(key), cmd.name, command); } else { sprintf(buf, "Mapped %s to %s.", nds_key_to_string(key), cmd.name); } nds_add_keymap_entry(key, command); clear_nhwindow(WIN_MESSAGE); putstr(WIN_MESSAGE, ATR_NONE, buf); nds_save_key_config(); nds_flush(0); }