18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00
Files
maszyna/vehicle
jerrrrycho 96bc3e6863 fix(cab): the compartment lights keyboard toggle works more than once in a cab without the switch (#353)
* fix(cab): the compartment lights keyboard toggle works more than once in a cab without the switch

The compartment lights get two requests, on (CompartmentLights.is_enabled)
and off (is_disabled), and the off one wins in LightsCheck(). The enable
and disable commands withdrew the other request only when the cab had a
toggle type compartmentlights_sw:. A push type switch and the separate
compartmentlightson_sw:/compartmentlightsoff_sw: push buttons withdraw
their own request when released, but a cab with none of these controls
(the CD 810 cab A, where only the engine compartment has the switch)
never withdrew anything: after one on/off both requests stayed set, the
lights stayed off and ctrl+; kept choosing "turn off".

Now a command withdraws the other request when the cab has the toggle
type switch (as before), or when it has no compartmentlights_sw: and no
push button for the other request, so the keyboard toggle acts as a
two-state switch there. Cabs with a push type switch or with the on/off
push buttons keep their behaviour. The decision is in
vehicle/compartmentlightsswitch.h, unit tested together with the
vehicle's LightsCheck() on the Elf definition.

* fix(cab): the compartment lights keyboard toggle latches in a cab with the on and off push buttons (#355)

In a cab with the compartmentlightson_sw: / compartmentlightsoff_sw: push
buttons and no compartmentlights_sw: (the EN57-2000, the SA134, the 214M,
the EN57AKL/AL/KM and EN71) ctrl+; turned the compartment lights off only
while the key was held. OnCommand_compartmentlightstoggle picked the
command from the lights' state again on the key release, after the press
had changed that state, so the release went to the other command: the
push button that was pressed never withdrew its request. After the first
press the on request stayed set, and from then on every release withdrew
the off request and the lights came back on.

The toggle now sends the release to both commands, as a release of the
push buttons would: each returns its own push type control to the
neutral position and withdraws its request. The press is picked from the
state as before. Mouse clicks on the push buttons go to the enable and
disable commands directly and are unchanged; with a compartmentlights_sw:
both commands release it the same way, and a cab without the controls
has nothing to release. In the Elf cab (an impulse compartmentlights_sw:
and the on/off return buttons) the lights worked, but the button the key
had pressed stayed pressed; now it returns too.

* test(cab): the compartment lights switch test without Sonar issues

using enum for range_t in the release helpers, and the lights declared
in the if that reads them. No change in what is tested.
2026-11-20 16:33:42 +01:00
..