diff --git a/runtime/camera_speed.c b/runtime/camera_speed.c new file mode 100644 index 00000000..520e6095 --- /dev/null +++ b/runtime/camera_speed.c @@ -0,0 +1,160 @@ +// Camera speed: TOTK_STICK_SENS (0.1 to 3, default 1, read at start) multiplies the game's own right-stick camera speeds. +// The game's Options menu offers five camera sensitivities, Very Low to Very High; their turn rates are the array +// StickSensitivity {0.8, 1.2, 1.6, 2.0, 2.4} in Component/PlayerCameraParam/PlayerCamera.game__component__ +// PlayerCameraParam.bgyml inside Pack/Actor/PlayerCamera.pack.zs. romfs.c serves a copy of that pack with every entry +// multiplied (cam_pack_build), so the setting raises the camera's top speed as well as its speed at a partial tilt, at +// any of the five sensitivities. The mouse camera reaches the game as a right-stick deflection (input_win.c, +// mouse_camera); input_win.c divides it by the same factor (cam_speed_applied), so TOTK_MOUSE_SENS alone sets the +// mouse's speed. +// +// The pack is a SARC archive compressed with the dictionary pack.zsdic of Pack/ZsDic.pack.zs. A float in a BYML array +// is stored in the array itself, so the multiplied values take the bytes of the old ones and no offset moves. +#include +#include +#include +#include + +#include "cfg.h" +#include "host.h" + +#define MEMBER "Component/PlayerCameraParam/PlayerCamera.game__component__PlayerCameraParam.bgyml" +#define MAX_RAW (64u << 20) + +static float applied = 1.0f; + +float cam_speed_wanted(void) { + double v = cfg_double("TOTK_STICK_SENS"); + return (float)(v < 0.1 ? 0.1 : v > 3 ? 3 : v); +} + +float cam_speed_applied(void) { return applied; } + +static int u32_at(const uint8_t *p, size_t n, size_t off, uint32_t *v) { + if (off > n || n - off < 4) return 0; + memcpy(v, p + off, 4); + return 1; +} + +// SARC member `name` of the archive p[0..n): its start and size; 0 when it is not there. +static int sarc_member(const uint8_t *p, size_t n, const char *name, size_t *at, size_t *size) { + uint32_t data; + uint16_t head, count, bom; + if (n < 0x14 || memcmp(p, "SARC", 4)) return 0; + memcpy(&head, p + 4, 2); + memcpy(&bom, p + 6, 2); + if (bom != 0xfeff || !u32_at(p, n, 12, &data) || head + 12u > n || memcmp(p + head, "SFAT", 4)) return 0; + memcpy(&count, p + head + 6, 2); + size_t names = head + 12 + (size_t)count * 16; + if (names + 8 > n || memcmp(p + names, "SFNT", 4)) return 0; + names += 8; + for (unsigned i = 0; i < count; i++) { + uint32_t attr, lo, hi; + size_t e = head + 12 + (size_t)i * 16; + if (!u32_at(p, n, e + 4, &attr) || !u32_at(p, n, e + 8, &lo) || !u32_at(p, n, e + 12, &hi)) return 0; + size_t s = names + (size_t)(attr & 0xffffff) * 4, len = strlen(name); + if (!(attr >> 24) || s + len + 1 > n || memcmp(p + s, name, len + 1)) continue; + if (lo > hi || data + (size_t)hi > n) return 0; + *at = data + lo; + *size = hi - lo; + return 1; + } + return 0; +} + +// The StickSensitivity floats of the BYML p[0..n), multiplied by k; their count, 0 when the file has no such array. +static int scale_sensitivity(uint8_t *p, size_t n, float k, float was[8]) { + uint32_t keys, root, head; + if (n < 16 || memcmp(p, "YB", 2) || !u32_at(p, n, 4, &keys) || !u32_at(p, n, 12, &root) || + !u32_at(p, n, root, &head) || (head & 0xff) != 0xc1 || !u32_at(p, n, keys, &head) || (head & 0xff) != 0xc2) + return 0; + uint32_t nkeys = head >> 8; + if (!u32_at(p, n, root, &head)) return 0; + for (uint32_t i = 0; i < head >> 8; i++) { + uint32_t e, at, arr, ah; + if (!u32_at(p, n, root + 4 + 8 * (size_t)i, &e) || (e & 0xffffff) >= nkeys || + !u32_at(p, n, keys + 4 + 4 * (size_t)(e & 0xffffff), &at)) + return 0; + const char *name = (const char *)p + keys + at; + if (keys + at + sizeof "StickSensitivity" > n || strcmp(name, "StickSensitivity")) continue; + if (e >> 24 != 0xc0 || !u32_at(p, n, root + 8 + 8 * (size_t)i, &arr) || !u32_at(p, n, arr, &ah) || + (ah & 0xff) != 0xc0) + return 0; + uint32_t count = ah >> 8; + size_t vals = arr + 4 + ((count + 3) & ~3u); + if (!count || count > 8 || vals + 4 * (size_t)count > n) return 0; + for (uint32_t j = 0; j < count; j++) + if (p[arr + 4 + j] != 0xd2) return 0; + for (uint32_t j = 0; j < count; j++) { + float v; + memcpy(&v, p + vals + 4 * j, 4); + was[j] = v; + v *= k; + memcpy(p + vals + 4 * j, &v, 4); + } + return (int)count; + } + return 0; +} + +int cam_pack_build(const void *in, size_t n, const void *zsdic, size_t zsdic_n, void **out, size_t *out_n) { + float k = cam_speed_wanted(); + *out = NULL; + if (k == 1.0f) return 0; + int ok = 0; + uint8_t *dics = NULL, *raw = NULL; + ZSTD_DDict *dd = NULL; + ZSTD_CDict *cd = NULL; + void *z = NULL; + // The dictionaries: Pack/ZsDic.pack.zs is a SARC compressed without one. + unsigned long long dn = ZSTD_getFrameContentSize(zsdic, zsdic_n); + size_t dic_at, dic_n; + if (dn == ZSTD_CONTENTSIZE_UNKNOWN || dn == ZSTD_CONTENTSIZE_ERROR || dn > MAX_RAW || !(dics = malloc((size_t)dn)) || + ZSTD_decompress(dics, (size_t)dn, zsdic, zsdic_n) != dn || + !sarc_member(dics, (size_t)dn, "pack.zsdic", &dic_at, &dic_n)) { + rt_log("camera speed: no pack.zsdic in Pack/ZsDic.pack.zs; the camera keeps its own speed"); + goto done; + } + unsigned long long rn = ZSTD_getFrameContentSize(in, n); + unsigned id = ZSTD_getDictID_fromFrame(in, n); + dd = ZSTD_createDDict(dics + dic_at, dic_n); + if (!dd || id != ZSTD_getDictID_fromDDict(dd) || rn == ZSTD_CONTENTSIZE_UNKNOWN || + rn == ZSTD_CONTENTSIZE_ERROR || rn > MAX_RAW || !(raw = malloc((size_t)rn))) { + rt_log("camera speed: Pack/Actor/PlayerCamera.pack.zs is not a pack.zsdic frame with a size; the camera keeps its " + "own speed"); + goto done; + } + ZSTD_DCtx *dctx = ZSTD_createDCtx(); + size_t got = dctx ? ZSTD_decompress_usingDDict(dctx, raw, (size_t)rn, in, n, dd) : 0; + ZSTD_freeDCtx(dctx); + size_t at, size; + float was[8]; + int count = !ZSTD_isError(got) && got == rn && sarc_member(raw, (size_t)rn, MEMBER, &at, &size) + ? scale_sensitivity(raw + at, size, k, was) : 0; + if (!count) { + rt_log("camera speed: no StickSensitivity array in %s; the camera keeps its own speed", MEMBER); + goto done; + } + cd = ZSTD_createCDict(dics + dic_at, dic_n, 9); + size_t cap = ZSTD_compressBound((size_t)rn), zn = 0; + ZSTD_CCtx *cctx = cd ? ZSTD_createCCtx() : NULL; + if (cctx && (z = malloc(cap))) zn = ZSTD_compress_usingCDict(cctx, z, cap, raw, (size_t)rn, cd); + ZSTD_freeCCtx(cctx); + if (!z || !zn || ZSTD_isError(zn)) goto done; + *out = z; + *out_n = zn; + z = NULL; + ok = 1; + rt_log("camera speed: x%.2f, StickSensitivity %.2f %.2f %.2f %.2f %.2f -> %.2f %.2f %.2f %.2f %.2f", k, was[0], + count > 1 ? was[1] : 0, count > 2 ? was[2] : 0, count > 3 ? was[3] : 0, count > 4 ? was[4] : 0, was[0] * k, + count > 1 ? was[1] * k : 0, count > 2 ? was[2] * k : 0, count > 3 ? was[3] * k : 0, + count > 4 ? was[4] * k : 0); +done: + free(z); + free(raw); + free(dics); + ZSTD_freeDDict(dd); + ZSTD_freeCDict(cd); + return ok; +} + +void cam_pack_served(void) { applied = cam_speed_wanted(); } diff --git a/runtime/cfg.c b/runtime/cfg.c index 31eb9213..a6a8fad5 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -47,7 +47,7 @@ static const char *const known[] = { "RENDER_SCALE", "REPLAY_ASYNC", "REPLAY_CHECK", "RESOLVE_CHECK", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES", "ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SHADER_CACHE", - "SHADER_MEMO", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "SWKBD_ANSWER", + "SHADER_MEMO", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_SENS", "SWKBD_ANSWER", "SWKBD_TEST", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_MEMO", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "UBO_SNAPSHOT", "UPSCALER", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VOLUME", "VRAM_HEADROOM", "VS_OUTS", "WB_FENCE_LIMIT", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_PROCS", "ZSTD_CHECK", "ZSTD_NATIVE", @@ -63,7 +63,7 @@ static const struct { const char *key, *section; } sections[] = { {"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"}, {"VOLUME", "audio"}, {"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"}, - {"PAD_LAYOUT", "input"}, {"MOUSE_SENS", "input"}, {"INPUT_RECORD", "input"}, + {"PAD_LAYOUT", "input"}, {"STICK_SENS", "input"}, {"MOUSE_SENS", "input"}, {"INPUT_RECORD", "input"}, {"BIND_A", "input"}, {"BIND_B", "input"}, {"BIND_X", "input"}, {"BIND_Y", "input"}, {"BIND_LCLICK", "input"}, {"BIND_RCLICK", "input"}, {"BIND_L", "input"}, {"BIND_R", "input"}, {"BIND_ZL", "input"}, {"BIND_ZR", "input"}, {"BIND_PLUS", "input"}, {"BIND_MINUS", "input"}, {"BIND_LEFT", "input"}, {"BIND_UP", "input"}, @@ -104,7 +104,7 @@ static const CfgMeta metas[] = { {"VOLUME", "100", "0..100", LIVE}, {"MOTION", "1", "0|1", LIVE}, {"RUMBLE_STRENGTH", "130", "0..300", LIVE}, {"RUMBLE_CURVE", "0.6", "0.2..1.5", LIVE}, {"RUMBLE_TRIGGERS", "0", "0|1", LIVE}, {"PAD_LAYOUT", "auto", "auto|nintendo|xbox", LIVE}, - {"MOUSE_SENS", "1", "0..10", LIVE}, + {"STICK_SENS", "1", "0.1..3", RESTART}, {"MOUSE_SENS", "1", "0..10", LIVE}, {"MENU_LANG", "", "en|ru", LIVE}, // Advanced: scheduling {"ASYNC_PREEMPT", "1", "0|1|2", RESTART}, {"REPLAY_ASYNC", "0", "0|1", RESTART}, diff --git a/runtime/host.h b/runtime/host.h index 262b7b98..4ede550f 100644 --- a/runtime/host.h +++ b/runtime/host.h @@ -233,6 +233,13 @@ void account_uid(uint64_t out[2]); // the local user's n // ---- movies (ov_movie.c) void movie_tick(Cpu *c); // at every present, on the presenting guest thread: hands // decoded movie frames over when due, signals their events +// ---- camera speed (camera_speed.c): TOTK_STICK_SENS +float cam_speed_wanted(void); // the factor TOTK_STICK_SENS asks for, 0.1 to 3 +float cam_speed_applied(void); // the factor in effect: 1 until romfs.c serves the pack +int cam_pack_build(const void *in, size_t n, const void *zsdic, size_t zsdic_n, void **out, size_t *out_n); + // Pack/Actor/PlayerCamera.pack.zs with the camera speeds + // multiplied, malloc'd; 0 = factor 1 or cannot (logged) +void cam_pack_served(void); // romfs.c serves the multiplied pack // ---- game resolution (resolution.c): TOTK_OUTPUT_RES, TOTK_RENDER_SCALE uint64_t res_heap_extra_bytes(void); // added to the application pool (mem_init), 2 MiB steps uint64_t res_heap_extra_kib(void); // added to the HeapDef texture heap and its parent; 0 = none diff --git a/runtime/input_win.c b/runtime/input_win.c index 61bb7dea..618b9294 100644 --- a/runtime/input_win.c +++ b/runtime/input_win.c @@ -5,6 +5,7 @@ // The gamepad also rumbles (input_rumble) and, when it has a gyro and an accelerometer, feeds the six-axis sensor from a // thread of its own (input_motion_start). Every SDL call on the gamepad is made under `lock`. #include +#include #include #include #include @@ -399,7 +400,10 @@ int input_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res) { static int key_down(int vk) { return (GetAsyncKeyState(vk) & 0x8000) != 0; } -// The mouse camera as a right-stick sample, held for the whole presented frame. Under `lock`. +// The mouse camera as a right-stick sample, held for the whole presented frame. Under `lock`. The sample is divided by +// the camera speed factor the game runs with (camera_speed.c, cam_speed_applied), which multiplies every right-stick +// turn rate, so TOTK_MOUSE_SENS alone sets the mouse's speed; below 1 the sample stays within the stick's range, so the +// mouse's top speed drops with the factor. static void mouse_camera(int32_t out[2]) { static uint64_t frame = ~0ull; static LARGE_INTEGER t0; @@ -424,8 +428,10 @@ static void mouse_camera(int32_t out[2]) { held[0] = held[1] = 0; // frames stopped: do not hold a deflection } } - out[0] = held[0]; - out[1] = held[1]; + double k = cam_speed_applied(), x = held[0] / k, y = held[1] / k, len = sqrt(x * x + y * y); + if (len > STICK_MAX) x *= STICK_MAX / len, y *= STICK_MAX / len; + out[0] = (int32_t)lround(x); + out[1] = (int32_t)lround(y); } static int32_t axis(int16_t v) { diff --git a/runtime/romfs.c b/runtime/romfs.c index 0d7aee5b..05ac6b62 100644 --- a/runtime/romfs.c +++ b/runtime/romfs.c @@ -343,46 +343,52 @@ static void added_init(void) { rt_log("RomFS overlay: %zu files added to the RomFS", nadded); } -// The HeapDef table a bigger game resolution needs (resolution.c): its texture heap and that heap's parent grow. The -// base is an overlay that replaces the table (a mod's heap sizes stay), else the RomFS original; the grown table is -// written to /resolution/ and served in the base's place. -#define HEAPDEF "System/HeapSize/Product.Nin_NX_NVN.HeapDef.byml.zs" -static void heapdef_overlay(void) { - if (!res_heap_extra_kib()) return; - uint64_t i = lower(HEAPDEF); - if (i >= file_count || strcmp(entry_name(entry(i)), HEAPDEF)) { - rt_log("RomFS: %s missing; the game keeps its own resolution", HEAPDEF); - return; +// RomFS file `rel` as the game would read it: from an overlay that replaces it (*base), else from the image. malloc'd; +// NULL when it is missing, unreadable or 16 MiB or more (logged with `keeps`, what the game does without it). +static void *read_served(const char *rel, Overlay **base, size_t *n, const char *keeps) { + uint64_t i = lower(rel); + *base = NULL; + if (i >= file_count || strcmp(entry_name(entry(i)), rel)) { + rt_log("RomFS: %s missing; %s", rel, keeps); + return NULL; } - Overlay *base = NULL; for (size_t k = 0; k < noverlay; k++) - if (overlays[k].index == i) base = &overlays[k]; - HANDLE f = base ? open_read(base->path, 1) : image; - uint64_t off = base ? 0 : entry(i).offset, n = base ? base->size : entry(i).size; - void *in = n && n < (16u << 20) && f != INVALID_HANDLE_VALUE ? malloc((size_t)n) : NULL; - int ok = in && read_at(f, in, (uint32_t)n, off) == (int64_t)n; - if (base && f != INVALID_HANDLE_VALUE) CloseHandle(f); - void *out = NULL; - size_t out_n = 0; - ok = ok && res_heapdef_build(in, (size_t)n, &out, &out_n); - free(in); - if (!ok) return; + if (overlays[k].index == i) *base = &overlays[k]; + HANDLE f = *base ? open_read((*base)->path, 1) : image; + uint64_t off = *base ? 0 : entry(i).offset, size = *base ? (*base)->size : entry(i).size; + void *in = size && size < (16u << 20) && f != INVALID_HANDLE_VALUE ? malloc((size_t)size) : NULL; + int ok = in && read_at(f, in, (uint32_t)size, off) == (int64_t)size; + if (*base && f != INVALID_HANDLE_VALUE) CloseHandle(f); + if (!ok) { + free(in); + rt_log("RomFS: cannot read %s; %s", rel, keeps); + return NULL; + } + *n = (size_t)size; + return in; +} + +// Serves out[0..out_n) (malloc'd, freed here) in place of RomFS file `rel` and of an overlay that replaces it (base): +// written to //. `what` names the change in the log. 0 when it cannot be written. +static int serve_generated(const char *rel, Overlay *base, void *out, size_t out_n, const char *sub, const char *what, + const char *keeps) { char dir[2100], file[2200]; - need(snprintf(dir, sizeof dir, "%s/resolution", rt_config()->profile) < (int)sizeof dir, "resolution path"); - need(snprintf(file, sizeof file, "%s/Product.Nin_NX_NVN.HeapDef.byml.zs", dir) < (int)sizeof file, "resolution path"); + const char *leaf = strrchr(rel, '/') ? strrchr(rel, '/') + 1 : rel; + need(snprintf(dir, sizeof dir, "%s/%s", rt_config()->profile, sub) < (int)sizeof dir, "generated overlay path"); + need(snprintf(file, sizeof file, "%s/%s", dir, leaf) < (int)sizeof file, "generated overlay path"); wchar_t *wd = fs_wide(dir), *wf = fs_wide(file); CreateDirectoryW(wd, NULL); HANDLE w = CreateFileW(wf, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD put = 0; - ok = w != INVALID_HANDLE_VALUE && WriteFile(w, out, (DWORD)out_n, &put, NULL) && put == out_n; + int ok = w != INVALID_HANDLE_VALUE && WriteFile(w, out, (DWORD)out_n, &put, NULL) && put == out_n; if (w != INVALID_HANDLE_VALUE) CloseHandle(w); free(wd); free(wf); free(out); HANDLE r = ok ? open_read(file, 1) : INVALID_HANDLE_VALUE; if (r == INVALID_HANDLE_VALUE) { - rt_log("RomFS: cannot write %s (error %lu); the game keeps its own resolution", file, GetLastError()); - return; + rt_log("RomFS: cannot write %s (error %lu); %s", file, GetLastError(), keeps); + return 0; } Identity id = identity_of(r); CloseHandle(r); @@ -399,12 +405,45 @@ static void heapdef_overlay(void) { overlays = realloc(overlays, overlay_cap * sizeof *overlays); need(overlays != NULL, "overlay table"); } - char *rel = _strdup(HEAPDEF); - need(rel != NULL, "overlay path copy"); - overlays[noverlay++] = (Overlay){i, out_n, copy, rel, id}; + char *name = _strdup(rel); + need(name != NULL, "overlay path copy"); + overlays[noverlay++] = (Overlay){lower(rel), out_n, copy, name, id}; } - rt_log("RomFS overlay: %s (%zu bytes, grown heaps) replaces %s", file, out_n, base ? "the mod's table" : "the original"); - res_heapdef_served(); + rt_log("RomFS overlay: %s (%zu bytes, %s) replaces %s", file, out_n, what, base ? "the mod's file" : "the original"); + return 1; +} + +// The HeapDef table a bigger game resolution needs (resolution.c): its texture heap and that heap's parent grow. The +// base is an overlay that replaces the table (a mod's heap sizes stay), else the RomFS original; the grown table is +// written to /resolution/ and served in the base's place. +#define HEAPDEF "System/HeapSize/Product.Nin_NX_NVN.HeapDef.byml.zs" +static void heapdef_overlay(void) { + if (!res_heap_extra_kib()) return; + static const char keeps[] = "the game keeps its own resolution"; + Overlay *base; + size_t n; + void *in = read_served(HEAPDEF, &base, &n, keeps), *out = NULL; + size_t out_n = 0; + int ok = in && res_heapdef_build(in, n, &out, &out_n); + free(in); + if (ok && serve_generated(HEAPDEF, base, out, out_n, "resolution", "grown heaps", keeps)) res_heapdef_served(); +} + +// The player camera's pack with its stick speeds multiplied by TOTK_STICK_SENS (camera_speed.c). The base is an +// overlay that replaces the pack (a mod's camera stays), else the RomFS original; the dictionary is the RomFS's own. +#define CAMPACK "Pack/Actor/PlayerCamera.pack.zs" +static void camera_overlay(void) { + if (cam_speed_wanted() == 1.0f) return; + static const char keeps[] = "the camera keeps its own speed"; + Overlay *base, *dic_base; + size_t n, dn; + void *in = read_served(CAMPACK, &base, &n, keeps), *out = NULL; + void *dic = in ? read_served("Pack/ZsDic.pack.zs", &dic_base, &dn, keeps) : NULL; + size_t out_n = 0; + int ok = in && dic && cam_pack_build(in, n, dic, dn, &out, &out_n); + free(in); + free(dic); + if (ok && serve_generated(CAMPACK, base, out, out_n, "camera", "camera speed", keeps)) cam_pack_served(); } static void overlay_init(void) { @@ -420,6 +459,7 @@ static void overlay_init(void) { for (int i = 0; i < 2; i++) if (dirs[i] && *dirs[i] && strcmp(dirs[i], "0")) overlay_load(dirs[i]); heapdef_overlay(); + camera_overlay(); added_init(); if (noverlay) qsort(overlays, noverlay, sizeof *overlays, overlay_order); for (size_t k = 1; k < noverlay; k++) diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index 7d52baa9..05829688 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -573,6 +573,7 @@ static void tab_controls(float scale) { opt_slider("TOTK_RUMBLE_STRENGTH", UI_MENU_RUMBLE_STRENGTH, 0, 300, UI_MENU_RUMBLE_STRENGTH_DESC, 10, "%.0f %%"); opt_slider("TOTK_RUMBLE_CURVE", UI_MENU_RUMBLE_CURVE, 0.2f, 1.5f, UI_MENU_RUMBLE_CURVE_DESC, 0.05f, "%.2f"); opt_toggle("TOTK_RUMBLE_TRIGGERS", UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC); + opt_slider("TOTK_STICK_SENS", UI_MENU_STICK_SENS, 0.1f, 3, UI_MENU_STICK_SENS_DESC, 0.05f, "%.2f"); opt_slider("TOTK_MOUSE_SENS", UI_MENU_MOUSE_SENS, 0, 10, UI_MENU_MOUSE_SENS_DESC, 0.1f, "%.1f"); binds_rows(scale); opt_end(); diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 0de0818f..2ae8b839 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -99,6 +99,9 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_PAD_LAYOUT_XBOX] = "Xbox (A bottom)", [UI_MENU_PAD_LAYOUT_IN_USE] = "in use: %s", [UI_MENU_MOUSE_SENS] = "Mouse camera sensitivity", [UI_MENU_MOUSE_SENS_DESC] = "How fast the mouse turns the camera.", + [UI_MENU_STICK_SENS] = "Stick camera speed", + [UI_MENU_STICK_SENS_DESC] = "Multiplies the game's own right-stick camera speed, top speed included, at each of the " + "game's five camera sensitivities. The mouse keeps its own setting.", [UI_BINDS_HELP] = "Select a cell and press A or Enter, then the key, mouse button or controller button. Delete or " "X clears a cell. A key in use moves here; a controller button swaps with the one it replaces.", @@ -317,6 +320,9 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_PAD_LAYOUT_XBOX] = "Xbox (A снизу)", [UI_MENU_PAD_LAYOUT_IN_USE] = "сейчас: %s", [UI_MENU_MOUSE_SENS] = "Чувствительность мыши", [UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.", + [UI_MENU_STICK_SENS] = "Скорость камеры (стик)", + [UI_MENU_STICK_SENS_DESC] = "Умножает скорость поворота камеры правым стиком, включая наибольшую, при каждой из пяти " + "чувствительностей камеры в игре. На мышь не влияет.", [UI_BINDS_HELP] = "Выберите ячейку и нажмите A или Enter, затем клавишу, кнопку мыши или кнопку контроллера. " "Delete или X очищает ячейку. Занятая клавиша переходит сюда; кнопка контроллера меняется " diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 96e10618..6fdb955b 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -57,7 +57,7 @@ typedef enum { UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC, UI_MENU_PAD_LAYOUT, UI_MENU_PAD_LAYOUT_DESC, UI_MENU_PAD_LAYOUT_AUTO, UI_MENU_PAD_LAYOUT_NINTENDO, UI_MENU_PAD_LAYOUT_XBOX, UI_MENU_PAD_LAYOUT_IN_USE, - UI_MENU_MOUSE_SENS, UI_MENU_MOUSE_SENS_DESC, + UI_MENU_MOUSE_SENS, UI_MENU_MOUSE_SENS_DESC, UI_MENU_STICK_SENS, UI_MENU_STICK_SENS_DESC, // Controls tab: the remapping rows (ui/binds_page.cpp) UI_BINDS_HELP, UI_BINDS_COL_KEY1, UI_BINDS_COL_KEY2, UI_BINDS_COL_PAD, diff --git a/totk.ini.example b/totk.ini.example index 30c3a2af..8752f35f 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -150,6 +150,10 @@ # west X, north Y, as an Xbox pad labels them; cross A on a PlayStation pad) or auto (nintendo for a pad with Nintendo # labels, xbox for the others). The bind_ lines below apply on top. Changes while the game runs take effect at once. # pad_layout = auto +# Right-stick camera speed (0.1 to 3): multiplies the game's own camera turn rates, top speed included, at each of the +# five camera sensitivities in the game's Options. Keys bound to the right stick follow it; the mouse keeps mouse_sens. +# Read at start. +# stick_sens = 1 # Mouse camera sensitivity (0 to 10; 0 = no mouse camera and no cursor capture). # mouse_sens = 1 # Write the input of this run to a file that replays as a script (docs/controls.md, "Scripted input"). Default: off.