Repository navigation
fix the absolute throttle axis giving zero thrust when inverted - #7829
Goober5000 wants to merge 2 commits into
Conversation
ba10110 to
7ebec6e
Compare
dustinspace217
left a comment
There was a problem hiding this comment.
This also fixes #7951 (inverted absolute throttle stuck at zero with mouse flight on), so "Fixes #7951" in the description would close it. From reading the source and the new tests, three things:
- The anchors only reset at mission load. If the throttle is rebound or inverted mid-mission (the controls screen, or Lua
bind->invert), a new lever is ignored until it moves 1.5%, and an inversion toggle can let an idle second lever take over. Could the anchors andactivebe cleared when that action's binding or inversion changes, keepingvalue? analog_throttle_lastandoverride_analog_throttle(playercontrol.cpp:648-649) never reset. After a throttle key in one mission, the next mission's lever is ignored until it moves, which contradicts "a lever sets the throttle on the first frame". Reset them alongsidecontrol_reset_axes(), or reword that line?- The
update_abs_axesflag already stops the free-look double read, since only one caller passes true. Could the serial go? That also drops the mouse.cpp/h changes.
Smaller: the keyboard gate is about 1.25% (819 fix units), not 1.5%. Was the mouse taking control with no threshold intended? The description could say mouse Z does nothing, since Mouse_dz is never set. A test through update_abs_axis would pin the wiring.
7ebec6e to
b30bb3d
Compare
Joystick axes report positions and mouse axes report deltas, so an absolute axis action can't simply sum its inputs. abs_axis_state keeps the action's value: a joystick sets it, the mouse nudges it, and whichever moved last is in control. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With mouse flight on, a Joy-0 axis binding also reads the mouse. For the absolute throttle, the mouse's per-frame delta was added to the lever's position and inverted as a position (F1_0 - delta), so a still mouse added F1_0 times the mouse scale and pinned the throttle at zero. Mouse deltas are now always inverted as relative values. Absolute actions no longer sum their inputs: each keeps an abs_axis_state, which joysticks set and the mouse nudges, with the mouse scaled to match its feel on the relative throttle. Since the axes can be read twice in one frame, the mouse deltas are only accumulated once per delta serial. The state is reset at mission load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b30bb3d to
c3f26e6
Compare
|
@dustinspace217 Ok, points addressed and PR updated |
dustinspace217
left a comment
There was a problem hiding this comment.
This is a code-reading review of c3f26e6; nothing was built or run.
Thanks, all three earlier points are resolved:
- Anchors now clear when an absolute action's bindings change (controlsconfig.cpp:3159). Keeping
activeinstead of clearing it, as I had asked, is the better choice, since an idle lever only re-anchors and the lever in control applies its new reading at once. analog_throttle_lastandoverride_analog_throttlenow reset inplayer_level_init(), which runs once per mission.- The mouse delta serial is gone, and mouse.cpp/h are out of the diff.
The smaller points are handled too: the threshold is now F1_0 / 80 (819 fix units), matching the keyboard gate, and the description now covers the mouse threshold and mouse Z.
One new issue in the rebind path. If the mouse moved last (active == -1) and the bindings then change, clear_anchors() leaves nothing anchored and nothing in control, so the lever's next reading takes control and the throttle jumps to the lever.
That contradicts "its levers re-anchor without moving the throttle". clear_anchors_keeps_value_from_delta stops right after clear_anchors(), and going by the source, adding state.update_position(0, 20000); ASSERT_EQ(25000, state.value); would fail on the current code.
One fix is a flag set by any reading, cleared by reset() and kept by clear_anchors(), so a first reading after a rebind only anchors. Narrowing that line of the description would also work.
Still open from last time: the tests only cover abs_axis_state, so the mouse invert type in update_abs_axis, the disconnected joystick guard and the rebind check can each be reverted with the suite staying green.
Smaller: no test moves a lever down to retake control or pins the 1.25% value, so dropping abs() or zeroing TAKEOVER_THRESHOLD would also pass.
Cause
With mouse flight on ("Mouse: Joy-0"), a Joy-0 axis binding also reads the mouse. In
scale_invert(), the mouse's per-frame delta was added to the absolute throttle's position and inverted with the absolute rule (F1_0 - val). So a still mouse contributedF1_0 * factor(~2×10⁸), which pinned the throttle at 0% at every lever position. Relative axes were unaffected, because inverting a zero delta is still zero. New pilots have mouse flight on by default.More broadly, a mouse on an absolute axis action was an incomplete feature: the delta was read as a position instead of being accumulated into one. Absolute actions also summed all their inputs, which doesn't make sense for positions; two levers bound as first and second were already broken this way.
Fixes #7951.
Fix
F1_0 - v, and mouse deltas always invert by negating.abs_axis_statefor absolute actions: it keeps the action's current value. A joystick sets the value outright and the mouse nudges it, and whichever input moved last is in control./frame_time. Mouse Z does nothing, becauseMouse_dzis never set.view_modify(), and photo mode), so those callers passupdate_abs_axes = falseand onlyread_keyboard_controls()updates them.override_analog_throttle,analog_throttle_last) also resets each mission; before, a throttle key pressed in one mission made the next mission ignore the lever until it moved. A mouse-only absolute throttle starts at 50%, the same as the existinganalog_valuedefault.Testing
abs_axis_stateintest/src/controlconfig/test_abs_axis.cpp. The full unit suite passes.🤖 Generated with Claude Code