The free camera combo counts the gamepad and an input script, not the keys bound to its buttons.

The previous commit read the combo from the merged buttons, where a key bound to ZL is the same bit as the left
trigger: with freecam_pad = zl+zr, the right mouse button and F switched the free camera in play. The keyboard has
freecam_key for that, so the gamepad combo now counts the gamepad and the input script, which stands in for one.

runtime/input.c poll_merged: script_apply writes its buttons into script_seen, which is then merged into the buttons as
before. freecam_gate counts a position of the combo when pad_seen has it or script_seen has the Switch buttons it stands
for; Home stays gamepad only. docs/controls.md ("Free camera") says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lebomisandClaude Opus 5.5 committed 2026-11-19 13:32:23 +11:00
1 parent 8dfc3609c4
commit 58930c152c
2 files changed
+19 -13

No files matched your search

+17 -10
View File
@@ -146,6 +146,10 @@ static void script_load(void) {
rt_log("input: script %s, %d events", path, script_n);
}
// Under lock: the Switch buttons the input script pressed in the last poll, apart from the keys' and the gamepad's, so
// a gamepad combo can count a scripted press as the gamepad's without counting the keys bound to the same buttons
static uint64_t script_seen;
static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
if (!script_state) script_load();
if (!script_n) return;
@@ -850,12 +854,12 @@ static float trigger_unit(int16_t v) { // 0..1 past a 5 % dead zone
}
// The free camera combo, latched like Minus+Plus (input_map.c, chord): once every button of it is down (on the gamepad,
// or as the merged Switch buttons from bound keys or an input script) the free camera switches once, and the buttons
// stay hidden from the game until all are released; the free camera key switches it on its press. While the free camera
// is on it gets the input and the game gets nothing, so Link stands still: the sticks (the keys' sticks merged into sl
// and sr), the trigger axes or else ZL and ZR as buttons, a press of L or R as a speed click, and the mouse's motion,
// which input_direct_mouse_sample then keeps from the game's camera. ZL, ZR, L and R are the merged Switch buttons, so
// the keys bound to them count. Off for other updates and with the freecam patch set off. Under lock.
// or pressed by an input script) the free camera switches once, and the buttons stay hidden from the game until all are
// released; the free camera key switches it on its press. While the free camera is on it gets the input and the game
// gets nothing, so Link stands still: the sticks (the keys' sticks merged into sl and sr), the trigger axes or else ZL
// and ZR as buttons, a press of L or R as a speed click, and the mouse's motion, which input_direct_mouse_sample then
// keeps from the game's camera. ZL, ZR, L and R are the merged Switch buttons, so the keys bound to them count. Off for
// other updates and with the freecam patch set off. Under lock.
static void freecam_gate(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
static int held, key_held, available = -1, shoulder[2];
if (available < 0) available = freecam_available();
@@ -863,11 +867,12 @@ static void freecam_gate(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
int layout = pad_layout_get();
for (int p = PAD_SOUTH; p <= PAD_GUIDE; p++) {
if (!(mask >> p & 1)) continue;
// A position counts as down on the gamepad or through the Switch buttons it stands for in the merged buttons,
// so the keys bound to them and an input script press the combo too. Home has no Switch button: gamepad only.
// A position counts as down on the gamepad or when the input script presses the Switch buttons it stands for,
// as a gamepad would; the keys bound to those buttons do not (the free camera key is theirs). Home has no
// Switch button: gamepad only.
uint8_t one[PAD_COUNT] = {0};
if (p < PAD_COUNT) one[p] = 1;
if (pad_seen[p] || (p < PAD_COUNT && *b & input_map_pad_buttons(one, layout))) raw |= 1u << p;
if (pad_seen[p] || (p < PAD_COUNT && script_seen & input_map_pad_buttons(one, layout))) raw |= 1u << p;
}
if (!mask) held = 0;
else if (held) held = raw != 0;
@@ -1017,7 +1022,9 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
if (pad_used) __atomic_store_n(&g_kbm_last, 0, __ATOMIC_RELAXED);
else if (kbm_used) __atomic_store_n(&g_kbm_last, 1, __ATOMIC_RELAXED);
}
script_apply(&b, sl, sr);
script_seen = 0;
script_apply(&script_seen, sl, sr);
b |= script_seen;
wheel_route(&b, sl, sr);
gameplay_tweaks_apply(__atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED), input_gameplay_active(), &b, &sl[0], &sl[1], &sr[0], &sr[1]);
rec_apply(b, sl, sr);