Skip to content

Commit 31428b4

Browse files
committed
Fix wipers not working with raildriver
1 parent cc6264e commit 31428b4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ public override void HandleUserInput(ElapsedTime elapsedTime)
287287
case CABViewControlTypes.ORTS_SELECTED_SPEED_SELECTOR:
288288
Locomotive.CruiseControl.SelectedSpeedMpS = val;
289289
break;
290+
case CABViewControlTypes.WIPERS:
291+
if (val == 0 && Locomotive.Wiper)
292+
Locomotive.SignalEvent(Event.WiperOff);
293+
if (val != 0 && !Locomotive.Wiper)
294+
Locomotive.SignalEvent(Event.WiperOn);
295+
break;
290296
// Other controls can hopefully be controlled faking mouse input
291297
// TODO: refactor HandleUserInput()
292298
default:

Source/RunActivity/Viewer3D/UserInputRailDriver.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public class RailDriverState : ExternalDeviceState
4747
public ExternalDeviceCabControl DynamicBrake = new ExternalDeviceCabControl(); // 0 to 100 if active otherwise less than 0
4848
public ExternalDeviceCabControl TrainBrake = new ExternalDeviceCabControl(); // 0 (release) to 100 (CS), does not include emergency
4949
public ExternalDeviceCabControl EngineBrake = new ExternalDeviceCabControl(); // 0 to 100
50+
public ExternalDeviceCabControl Wipers = new ExternalDeviceCabControl(); // wiper rotary, 1 off, 2 slow, 3 full
5051
public ExternalDeviceCabControl Lights = new ExternalDeviceCabControl(); // lights rotary, 1 off, 2 dim, 3 full
5152
ExternalDeviceButton BailOff;
52-
ExternalDeviceButton Wiper;
5353
public RailDriverState(Game game)
5454
{
5555
try
@@ -140,15 +140,14 @@ public RailDriverState(Game game)
140140
}
141141

142142
BailOff = new ExternalDeviceButton();
143-
Wiper = new ExternalDeviceButton();
144143
RegisterCommand(UserCommand.ControlBailOff, BailOff);
145-
RegisterCommand(UserCommand.ControlWiper, Wiper);
146144

147145
CabControls[(new CabViewControlType(CABViewControlTypes.DIRECTION), -1)] = Direction;
148146
CabControls[(new CabViewControlType(CABViewControlTypes.THROTTLE), -1)] = Throttle;
149147
CabControls[(new CabViewControlType(CABViewControlTypes.TRAIN_BRAKE), -1)] = TrainBrake;
150148
CabControls[(new CabViewControlType(CABViewControlTypes.ENGINE_BRAKE), -1)] = EngineBrake;
151149
CabControls[(new CabViewControlType(CABViewControlTypes.DYNAMIC_BRAKE), -1)] = DynamicBrake;
150+
CabControls[(new CabViewControlType(CABViewControlTypes.WIPERS), -1)] = Wipers;
152151
CabControls[(new CabViewControlType(CABViewControlTypes.FRONT_HLIGHT), -1)] = Lights;
153152
}
154153
public void Update()
@@ -171,7 +170,7 @@ public void Update()
171170
float calOff = (1 - a) * bailoffDisengaged.Item1 + a * bailoffDisengaged.Item2;
172171
float calOn = (1 - a) * bailoffEngaged.Item1 + a * bailoffEngaged.Item2;
173172
BailOff.IsDown = Percentage(readBuffer[5], calOff, calOn) > 50;
174-
Wiper.IsDown = (int)(.01 * Percentage(readBuffer[6], wipers) + 2.5) != 1;
173+
Wipers.Value = (int)(.01 * Percentage(readBuffer[6], wipers) + 2.5) == 1 ? 0 : 1;
175174
Lights.Value = (int)(.01 * Percentage(readBuffer[7], headlight) + 2.5);
176175

177176
foreach (var buttonList in Commands.Values)

0 commit comments

Comments
 (0)