mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 04:55:56 +00:00
Add a stick dead zone setting for drifting gamepads
stick_deadzone (0 to 50 percent, default 8) replaces the fixed per-axis cutoff of 2500. The zone is round and the travel past it is scaled to start at 0, so a drifting stick rests centred and full deflection still reaches full. The Controls tab shows it as a slider; --probe-cfg checks the math (input_pad_stick). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fb06577c23
commit
ed1973a68b
10 files changed
+57
-11
No files matched your search
@@ -325,6 +325,15 @@ void input_mouse_stick(int32_t dx, int32_t dy, double dt_s, float sens, int32_t
|
||||
out[1] = (int32_t)lrint(y);
|
||||
}
|
||||
|
||||
void input_pad_stick(int32_t x, int32_t y, float dead, int32_t out[2]) {
|
||||
double fx = x / (double)STICK_MAX, fy = y / (double)STICK_MAX, m = sqrt(fx * fx + fy * fy);
|
||||
out[0] = out[1] = 0;
|
||||
if (m <= dead) return;
|
||||
double k = ((m > 1 ? 1 : m) - dead) / (1 - dead) / m; // past the edge (a square gate's corner) the length is 1
|
||||
out[0] = (int32_t)lrint(fmax(-1, fmin(1, fx * k)) * STICK_MAX);
|
||||
out[1] = (int32_t)lrint(fmax(-1, fmin(1, fy * k)) * STICK_MAX);
|
||||
}
|
||||
|
||||
// Minus and Plus held together open or close the menu. *held: latched from the poll where both go down until neither is
|
||||
// down (the caller keeps it). Every poll of the latch reports neither to the game, so releasing one button first does not
|
||||
// leak the other; Minus alone before Plus reaches the game unchanged. With the menu open the game sees a neutral pad.
|
||||
|
||||
Reference in new issue
Block a user