Add a walk key that tilts the keyboard's sticks part of the way

A keyboard key is all or nothing, so the game only ever saw a full tilt from it and the keyboard could not walk. While
the key named by walk_key is held, the two keyboard stick samples are scaled to walk_scale, the same thing yuzu and eden
do with their modifier setting; the gamepad's axes and the mouse camera keep their own values.

0.51 rather than half: a sample of 32767 times 0.5 is 16383, one short of the 16384 the game's stick-direction bits
need, so half a tilt would leave the direction clear while the axis moved. No key is on by default, because Shift is B
in the default bindings. The Controls tab lists the keys players pick, steps the scale in hundredths and names the
action a key also presses.

Co-authored-by: deepseek-v4.1-flash-1017 <noreply@deepseek.com>
This commit is contained in:
shenjackanddeepseek-v4.1-flash-1017 committed 2026-11-01 02:33:39 +08:00
1 parent f469c5a774
commit 6e73cd813d
6 files changed
+111 -2

No files matched your search

+33
View File
@@ -668,6 +668,37 @@ static const char *pad_layout_note(void) {
return note;
}
// The action a key presses, or -1: the walk key is a key of its own, but Shift is B in the default bindings, and a
// walk key that also presses something walks and does that something at the same time.
static int key_action(int key) {
for (int a = 0; a < ACTION_COUNT; a++) {
uint8_t keys[2];
int n = input_map_keys_of(&input_map, a, keys, 2);
for (int i = 0; i < n; i++)
if (keys[i] == key) return a;
}
return -1;
}
// The walk key as the handful of keys a player is likely to pick. "none" rather than an empty value closes it: an
// unset key falls back to the default in the settings table, the same as a fresh installation. totk.ini takes any name
// input_map.c knows (walks of the keyboard sticks, not of the gamepad). A key the current bindings also use says which
// action it presses.
static void row_walk_key(void) {
static const char *const keys[] = {"none", "lshift", "lalt", "lctrl", "tab", "capslock"};
const char *names[sizeof keys / sizeof *keys] = {menu_text(UI_MENU_OFF), "Shift", "Alt", "Ctrl", "Tab", "Caps Lock"};
const char *cur = cfg_value("TOTK_WALK_KEY");
static char note[64];
const char *n = nullptr;
for (int k = KEY_A; k < KEY_COUNT && !n; k++) {
if (!input_key_name(k) || _stricmp(input_key_name(k), cur)) continue;
int a = key_action(k);
if (a >= 0 && input_action_name(a)) snprintf(note, sizeof note, menu_text(UI_MENU_WALK_KEY_TAKEN), input_action_name(a)), n = note;
}
opt_choice_list("TOTK_WALK_KEY", UI_MENU_WALK_KEY, keys, names, sizeof keys / sizeof *keys, UI_MENU_WALK_KEY_DESC,
-1, n);
}
static void tab_controls(float scale) {
opt_begin("##controls", scale);
static const UiTextId layout[] = {UI_MENU_PAD_LAYOUT_AUTO, UI_MENU_PAD_LAYOUT_NINTENDO, UI_MENU_PAD_LAYOUT_XBOX,
@@ -679,6 +710,8 @@ static void tab_controls(float scale) {
opt_toggle("TOTK_RUMBLE_TRIGGERS", UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC);
opt_slider("TOTK_STICK_DEADZONE", UI_MENU_STICK_DEADZONE, 0, 50, UI_MENU_STICK_DEADZONE_DESC, 1, "%.0f %%");
opt_slider("TOTK_MOUSE_SENS", UI_MENU_MOUSE_SENS, 0, 10, UI_MENU_MOUSE_SENS_DESC, 0.1f, "%.1f");
row_walk_key();
opt_slider("TOTK_WALK_SCALE", UI_MENU_WALK_SCALE, 0.2f, 0.9f, UI_MENU_WALK_SCALE_DESC, 0.01f, "%.2f");
binds_rows(scale);
opt_end();
binds_after_page();