From cba929e61c2758470ca2d881b92ba9a21548c0c7 Mon Sep 17 00:00:00 2001 From: Marcin Nowak Date: Mon, 26 Sep 2022 18:05:46 +0200 Subject: [PATCH 1/6] (commands) add enable/disable commands for rear lights and redmarks --- Train.cpp | 244 +++++++++++++++++++++++++++++++++++----- Train.h | 10 ++ command.cpp | 10 ++ command.h | 10 ++ driverkeyboardinput.cpp | 10 ++ 5 files changed, 254 insertions(+), 30 deletions(-) diff --git a/Train.cpp b/Train.cpp index 53c5ac3d7..0c54a569b 100644 --- a/Train.cpp +++ b/Train.cpp @@ -365,10 +365,20 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::redmarkerenableright, &TTrain::OnCommand_redmarkerenableright }, { user_command::redmarkerdisableright, &TTrain::OnCommand_redmarkerdisableright }, { user_command::headlighttogglerearleft, &TTrain::OnCommand_headlighttogglerearleft }, + { user_command::headlightenablerearleft, &TTrain::OnCommand_headlightenablerearleft }, + { user_command::headlightdisablerearleft, &TTrain::OnCommand_headlightdisablerearleft }, { user_command::headlighttogglerearright, &TTrain::OnCommand_headlighttogglerearright }, + { user_command::headlightenablerearright, &TTrain::OnCommand_headlightenablerearright }, + { user_command::headlightdisablerearright, &TTrain::OnCommand_headlightdisablerearright }, { user_command::headlighttogglerearupper, &TTrain::OnCommand_headlighttogglerearupper }, + { user_command::headlightenablerearupper, &TTrain::OnCommand_headlightenablerearupper }, + { user_command::headlightdisablerearupper, &TTrain::OnCommand_headlightdisablerearupper }, { user_command::redmarkertogglerearleft, &TTrain::OnCommand_redmarkertogglerearleft }, + { user_command::redmarkerenablerearleft, &TTrain::OnCommand_redmarkerenablerearleft }, + { user_command::redmarkerdisablerearleft, &TTrain::OnCommand_redmarkerdisablerearleft }, { user_command::redmarkertogglerearright, &TTrain::OnCommand_redmarkertogglerearright }, + { user_command::redmarkerenablerearright, &TTrain::OnCommand_redmarkerenablerearright }, + { user_command::redmarkerdisablerearright, &TTrain::OnCommand_redmarkerdisablerearright }, { user_command::redmarkerstoggle, &TTrain::OnCommand_redmarkerstoggle }, { user_command::endsignalstoggle, &TTrain::OnCommand_endsignalstoggle }, { user_command::headlightsdimtoggle, &TTrain::OnCommand_headlightsdimtoggle }, @@ -4444,22 +4454,73 @@ void TTrain::OnCommand_headlighttogglerearleft( TTrain *Train, command_data cons end::front ) }; // only reacting to press, so the switch doesn't flip back and forth if key is held down if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_right ) == 0 ) { - // turn on - Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_right; - // visual feedback - Train->ggRearLeftLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + OnCommand_headlightenablerearleft(Train, Command); } else { - //turn off + OnCommand_headlightdisablerearleft(Train, Command); + } + } +} + +void TTrain::OnCommand_headlightenablerearleft( TTrain *Train, command_data const &Command ) { + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + // already enabled + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_right ) == 0 ) { + // turn on Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_right; // visual feedback - Train->ggRearLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->ggRearLeftLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } } } +void TTrain::OnCommand_headlightdisablerearleft( TTrain *Train, command_data const &Command ) { + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + if( Command.action == GLFW_PRESS ) { + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + // already disabled + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_right ) == 0 ) {return;} + + //turn off + Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_right; + // visual feedback + Train->ggRearLeftLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + void TTrain::OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command ) { + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_left ) == 0 ) { + OnCommand_headlightenablerearright(Train, Command); + } + else { + OnCommand_headlightdisablerearright(Train, Command); + } + } +} +void TTrain::OnCommand_headlightenablerearright( TTrain *Train, command_data const &Command ) { if( Train->mvOccupied->LightsPosNo > 0 ) { // lights are controlled by preset selector return; @@ -4471,23 +4532,61 @@ void TTrain::OnCommand_headlighttogglerearright( TTrain *Train, command_data con Train->cab_to_end() == end::front ? end::rear : end::front ) }; - // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_left ) == 0 ) { // turn on Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } + } +} + +void TTrain::OnCommand_headlightdisablerearright( TTrain *Train, command_data const &Command ) { + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + // already disabled + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_left ) == 0 ) { return; } + + //turn off + Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_left; + // visual feedback + Train->ggRearRightLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_upper ) == 0 ) { + OnCommand_headlightenablerearupper(Train, Command); + } else { - //turn off - Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_left; - // visual feedback - Train->ggRearRightLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + OnCommand_headlightdisablerearupper(Train, Command); } } } -void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command ) { +void TTrain::OnCommand_headlightenablerearupper( TTrain *Train, command_data const &Command ) { if( Train->mvOccupied->LightsPosNo > 0 ) { // lights are controlled by preset selector @@ -4506,16 +4605,50 @@ void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data con // visual feedback Train->ggRearUpperLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } + } +} + +void TTrain::OnCommand_headlightdisablerearupper( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + // already disabled? + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::headlight_upper ) == 0 ) { return ; } + + //turn off + Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_upper; + // visual feedback + Train->ggRearUpperLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + +void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ) { + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_right ) == 0 ) { + OnCommand_redmarkerenablerearleft(Train, Command); + } else { - //turn off - Train->mvOccupied->iLights[ vehicleotherend ] ^= light::headlight_upper; - // visual feedback - Train->ggRearUpperLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + OnCommand_redmarkerdisablerearleft(Train, Command); } } } -void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ) { +void TTrain::OnCommand_redmarkerenablerearleft( TTrain *Train, command_data const &Command ) { if( Train->mvOccupied->LightsPosNo > 0 ) { // lights are controlled by preset selector @@ -4528,19 +4661,33 @@ void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data cons Train->cab_to_end() == end::front ? end::rear : end::front ) }; - // only reacting to press, so the switch doesn't flip back and forth if key is held down if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_right ) == 0 ) { // turn on Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } - else { - //turn off - Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_right; - // visual feedback - Train->ggRearLeftEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); - } + } +} + +void TTrain::OnCommand_redmarkerdisablerearleft( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_right ) == 0 ) { return; } + //turn off + Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_right; + // visual feedback + Train->ggRearLeftEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); } } @@ -4559,20 +4706,57 @@ void TTrain::OnCommand_redmarkertogglerearright( TTrain *Train, command_data con end::front ) }; // only reacting to press, so the switch doesn't flip back and forth if key is held down if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_left ) == 0 ) { - // turn on - Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_left; - // visual feedback - Train->ggRearRightEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); + OnCommand_redmarkerenablerearright(Train, Command); } else { - //turn off + OnCommand_redmarkerdisablerearright(Train, Command); + } + } +} + +void TTrain::OnCommand_redmarkerenablerearright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_left ) == 0 ) { + // turn on Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_left; // visual feedback - Train->ggRearRightEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + Train->ggRearRightEndLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } } } +void TTrain::OnCommand_redmarkerdisablerearright( TTrain *Train, command_data const &Command ) { + + if( Train->mvOccupied->LightsPosNo > 0 ) { + // lights are controlled by preset selector + return; + } + + if( Command.action == GLFW_PRESS ) { + // NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc + auto const vehicleotherend { ( + Train->cab_to_end() == end::front ? + end::rear : + end::front ) }; + if( ( Train->mvOccupied->iLights[ vehicleotherend ] & light::redmarker_left ) == 0 ) { return; } + //turn off + Train->mvOccupied->iLights[ vehicleotherend ] ^= light::redmarker_left; + // visual feedback + Train->ggRearRightEndLightButton.UpdateValue( 0.0, Train->dsbSwitch ); + } +} + void TTrain::OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Command ) { if( ( true == Command.freefly ) diff --git a/Train.h b/Train.h index 3423a51c0..0f2a61bf1 100644 --- a/Train.h +++ b/Train.h @@ -386,10 +386,20 @@ class TTrain { static void OnCommand_redmarkerenableright( TTrain *Train, command_data const &Command ); static void OnCommand_redmarkerdisableright( TTrain *Train, command_data const &Command ); static void OnCommand_headlighttogglerearleft( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightenablerearleft( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightdisablerearleft( TTrain *Train, command_data const &Command ); static void OnCommand_headlighttogglerearright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightenablerearright( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightdisablerearright( TTrain *Train, command_data const &Command ); static void OnCommand_headlighttogglerearupper( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightenablerearupper( TTrain *Train, command_data const &Command ); + static void OnCommand_headlightdisablerearupper( TTrain *Train, command_data const &Command ); static void OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerenablerearleft( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerdisablerearleft( TTrain *Train, command_data const &Command ); static void OnCommand_redmarkertogglerearright( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerenablerearright( TTrain *Train, command_data const &Command ); + static void OnCommand_redmarkerdisablerearright( TTrain *Train, command_data const &Command ); static void OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Command ); static void OnCommand_endsignalstoggle( TTrain *Train, command_data const &Command ); static void OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &Command ); diff --git a/command.cpp b/command.cpp index dc8978a9c..271badb7b 100644 --- a/command.cpp +++ b/command.cpp @@ -216,10 +216,20 @@ commanddescription_sequence Commands_descriptions = { { "redmarkerenableright", command_target::vehicle, command_mode::oneoff }, { "redmarkerdisableright", command_target::vehicle, command_mode::oneoff }, { "headlighttogglerearleft", command_target::vehicle, command_mode::oneoff }, + { "headlightenablerearleft", command_target::vehicle, command_mode::oneoff }, + { "headlightdisablerearleft", command_target::vehicle, command_mode::oneoff }, { "headlighttogglerearright", command_target::vehicle, command_mode::oneoff }, + { "headlightenablerearright", command_target::vehicle, command_mode::oneoff }, + { "headlightdisablerearright", command_target::vehicle, command_mode::oneoff }, { "headlighttogglerearupper", command_target::vehicle, command_mode::oneoff }, + { "headlightenablerearupper", command_target::vehicle, command_mode::oneoff }, + { "headlightdisablerearupper", command_target::vehicle, command_mode::oneoff }, { "redmarkertogglerearleft", command_target::vehicle, command_mode::oneoff }, + { "redmarkerenablerearleft", command_target::vehicle, command_mode::oneoff }, + { "redmarkerdisablerearleft", command_target::vehicle, command_mode::oneoff }, { "redmarkertogglerearright", command_target::vehicle, command_mode::oneoff }, + { "redmarkerenablerearright", command_target::vehicle, command_mode::oneoff }, + { "redmarkerdisablerearright", command_target::vehicle, command_mode::oneoff }, { "redmarkerstoggle", command_target::vehicle, command_mode::oneoff }, { "endsignalstoggle", command_target::vehicle, command_mode::oneoff }, { "headlightsdimtoggle", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index 4bdef3bbd..444de76ff 100644 --- a/command.h +++ b/command.h @@ -211,10 +211,20 @@ enum class user_command { redmarkerenableright, redmarkerdisableright, headlighttogglerearleft, + headlightenablerearleft, + headlightdisablerearleft, headlighttogglerearright, + headlightenablerearright, + headlightdisablerearright, headlighttogglerearupper, + headlightenablerearupper, + headlightdisablerearupper, redmarkertogglerearleft, + redmarkerenablerearleft, + redmarkerdisablerearleft, redmarkertogglerearright, + redmarkerenablerearright, + redmarkerdisablerearright, redmarkerstoggle, endsignalstoggle, headlightsdimtoggle, diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index 7f91f9987..f4adc9ba6 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -216,10 +216,20 @@ driverkeyboard_input::default_bindings() { // redmarkerenableright, // redmarkerdisableright, { user_command::headlighttogglerearleft, GLFW_KEY_Y | keymodifier::control }, + // headlightenablerearleft + // headlightdisablerearleft { user_command::headlighttogglerearright, GLFW_KEY_I | keymodifier::control }, + // headlightenablerearright + // headlightdisablerearright { user_command::headlighttogglerearupper, GLFW_KEY_U | keymodifier::control }, + // headlightenablerearupper + // headlightdisablerearupper { user_command::redmarkertogglerearleft, GLFW_KEY_Y | keymodifier::control | keymodifier::shift }, + // redmarkerenablerearleft + // redmarkerdisablerearleft { user_command::redmarkertogglerearright, GLFW_KEY_I | keymodifier::control | keymodifier::shift }, + // redmarkerenablerearright + // redmarkerdisablerearright { user_command::redmarkerstoggle, GLFW_KEY_E | keymodifier::shift }, { user_command::endsignalstoggle, GLFW_KEY_E }, { user_command::headlightsdimtoggle, GLFW_KEY_L | keymodifier::control }, From 31fd1dc56f4b7960a3087ea154c3115dc7d71122 Mon Sep 17 00:00:00 2001 From: maciejbaur Date: Wed, 28 Sep 2022 21:36:31 +0200 Subject: [PATCH 2/6] (commands) Add alarmchainenable and alarmchaindisable commands --- Train.cpp | 56 +++++++++++++++++++++++++++-------------- Train.h | 2 ++ command.cpp | 2 ++ command.h | 2 ++ driverkeyboardinput.cpp | 2 ++ drivermouseinput.cpp | 8 +++++- vr/openvr_imp.cpp | 7 +++++- 7 files changed, 58 insertions(+), 21 deletions(-) diff --git a/Train.cpp b/Train.cpp index 0c54a569b..db1a75402 100644 --- a/Train.cpp +++ b/Train.cpp @@ -246,6 +246,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::manualbrakeincrease, &TTrain::OnCommand_manualbrakeincrease }, { user_command::manualbrakedecrease, &TTrain::OnCommand_manualbrakedecrease }, { user_command::alarmchaintoggle, &TTrain::OnCommand_alarmchaintoggle }, + { user_command::alarmchainenable, &TTrain::OnCommand_alarmchainenable}, + { user_command::alarmchaindisable, &TTrain::OnCommand_alarmchaindisable}, { user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate }, { user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate }, { user_command::autosandboxtoggle, &TTrain::OnCommand_autosandboxtoggle }, @@ -1047,7 +1049,7 @@ void TTrain::OnCommand_jointcontrollerset( TTrain *Train, command_data const &Co // on press or hold // value controls brake in range 0-0.5, master controller in range 0.5-1.0 if( Command.param1 >= 0.5 ) { - Train->set_master_controller( + Train->set_master_controller( ( Command.param1 * 2 - 1 ) * ( Train->mvControlled->CoupledCtrl ? Train->mvControlled->MainCtrlPosNo + Train->mvControlled->ScndCtrlPosNo : @@ -1822,20 +1824,36 @@ void TTrain::OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Comm if( Command.action == GLFW_PRESS ) { if( false == Train->mvOccupied->AlarmChainFlag ) { - // pull - Train->mvOccupied->AlarmChainSwitch( true ); - // visual feedback - Train->ggAlarmChain.UpdateValue( 1.0 ); + OnCommand_alarmchainenable(Train, Command); } else { - // release - Train->mvOccupied->AlarmChainSwitch( false ); - // visual feedback - Train->ggAlarmChain.UpdateValue( 0.0 ); + OnCommand_alarmchaindisable(Train, Command); } } } +void TTrain::OnCommand_alarmchainenable(TTrain *Train, command_data const &Command) +{ + if (Command.action == GLFW_PRESS) { + + // pull + Train->mvOccupied->AlarmChainSwitch(true); + // visual feedback + Train->ggAlarmChain.UpdateValue(1.0); + } +} + + +void TTrain::OnCommand_alarmchaindisable(TTrain *Train, command_data const &Command) { + if (Command.action == GLFW_PRESS) { + + // release + Train->mvOccupied->AlarmChainSwitch(false); + // visual feedback + Train->ggAlarmChain.UpdateValue(0.0); + } +} + void TTrain::OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ) { // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels @@ -3682,7 +3700,7 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d if( Train->ggCompressorListButton.type() == TGaugeType::push ) { // impulse switch toggles only between positions 'default' and 'default+1' return; - } + } if ((Train->mvOccupied->CompressorListPos > 1) || (true == Train->mvOccupied->CompressorListWrap)) { @@ -5215,7 +5233,7 @@ void TTrain::OnCommand_heatingdisable( TTrain *Train, command_data const &Comman Train->mvOccupied->HeatingSwitch( false ); // visual feedback - Train->ggTrainHeatingButton.UpdateValue( + Train->ggTrainHeatingButton.UpdateValue( ( Train->ggTrainHeatingButton.type() == TGaugeType::push ? 1.0 : 0.0 ), @@ -5351,7 +5369,7 @@ void TTrain::OnCommand_springbrakeshutoffdisable(TTrain *Train, command_data con void TTrain::OnCommand_springbrakerelease(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - + auto *vehicle{ Train->find_nearest_consist_vehicle(Command.freefly, Command.location) }; if (vehicle == nullptr) { return; } Train->mvOccupied->SpringBrakeRelease(); @@ -5455,7 +5473,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command { itemindex -= p->MoverParameters->InvertersNo; } - + } p = (kier ? p->Next(flag) : p->Prev(flag)); } @@ -6618,8 +6636,8 @@ void TTrain::UpdateCab() { // Ra: przesiadka, jeśli AI zmieniło kabinę (a człon?)... if( ( DynamicObject->Mechanik ) // może nie być? - && ( DynamicObject->Mechanik->AIControllFlag ) ) { - + && ( DynamicObject->Mechanik->AIControllFlag ) ) { + if( iCabn != ( // numer kabiny (-1: kabina B) mvOccupied->CabOccupied == -1 ? 2 : @@ -7650,7 +7668,7 @@ bool TTrain::Update( double const Deltatime ) { #ifdef _WIN32 if (DynamicObject->Mechanik ? - (DynamicObject->Mechanik->AIControllFlag ? false : + (DynamicObject->Mechanik->AIControllFlag ? false : (Global.iFeedbackMode == 4 /*|| (Global.bMWDmasterEnable && Global.bMWDBreakEnable)*/)) : false && Global.fCalibrateIn[ 0 ][ 1 ] != 0.0) // nie blokujemy AI { // Ra: nie najlepsze miejsce, ale na początek gdzieś to dać trzeba @@ -7844,7 +7862,7 @@ bool TTrain::Update( double const Deltatime ) ggHelperButton.UpdateValue( DynamicObject->Mechanik->HelperState ); } ggHelperButton.Update(); - + ggSpeedControlIncreaseButton.Update( lowvoltagepower ); ggSpeedControlDecreaseButton.Update( lowvoltagepower ); ggSpeedControlPowerIncreaseButton.Update( lowvoltagepower ); @@ -8043,7 +8061,7 @@ TTrain::update_sounds( double const Deltatime ) { rsHissX->stop(); } } - // upuszczanie z czasowego + // upuszczanie z czasowego if( rsHissT ) { volume = mvOccupied->Handle->GetSound( s_fv4a_t ) * rsHissT->m_amplitudefactor + +rsHissT->m_amplitudeoffset; if( volume * brakevolumescale > 0.05 ) { @@ -9701,7 +9719,7 @@ void TTrain::set_cab_controls( int const Cab ) { p = (kier ? p->Next(flag) : p->Prev(flag)); } } - + // we reset all indicators, as they're set during the update pass // TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it } diff --git a/Train.h b/Train.h index 0f2a61bf1..31f6c23cc 100644 --- a/Train.h +++ b/Train.h @@ -265,6 +265,8 @@ class TTrain { static void OnCommand_manualbrakeincrease( TTrain *Train, command_data const &Command ); static void OnCommand_manualbrakedecrease( TTrain *Train, command_data const &Command ); static void OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_alarmchainenable(TTrain *Train, command_data const &Command); + static void OnCommand_alarmchaindisable(TTrain *Train, command_data const &Command); static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ); static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command ); static void OnCommand_autosandboxtoggle(TTrain *Train, command_data const &Command); diff --git a/command.cpp b/command.cpp index 271badb7b..bd980d410 100644 --- a/command.cpp +++ b/command.cpp @@ -62,6 +62,8 @@ commanddescription_sequence Commands_descriptions = { { "manualbrakeincrease", command_target::vehicle, command_mode::oneoff }, { "manualbrakedecrease", command_target::vehicle, command_mode::oneoff }, { "alarmchaintoggle", command_target::vehicle, command_mode::oneoff }, + { "alarmchainenable", command_target::vehicle, command_mode::oneoff}, + { "alarmchaindisable", command_target::vehicle, command_mode::oneoff}, { "wheelspinbrakeactivate", command_target::vehicle, command_mode::oneoff }, { "sandboxactivate", command_target::vehicle, command_mode::oneoff }, { "autosandboxtoggle", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index 444de76ff..2c0dff215 100644 --- a/command.h +++ b/command.h @@ -55,6 +55,8 @@ enum class user_command { manualbrakeincrease, manualbrakedecrease, alarmchaintoggle, + alarmchainenable, + alarmchaindisable, wheelspinbrakeactivate, sandboxactivate, autosandboxtoggle, diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index f4adc9ba6..0fe8736b0 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -64,6 +64,8 @@ driverkeyboard_input::default_bindings() { { user_command::manualbrakeincrease, GLFW_KEY_KP_1 | keymodifier::control }, { user_command::manualbrakedecrease, GLFW_KEY_KP_7 | keymodifier::control }, { user_command::alarmchaintoggle, GLFW_KEY_B | keymodifier::shift | keymodifier::control }, + // alarmchainenable, + // alarmchaindisable, { user_command::wheelspinbrakeactivate, GLFW_KEY_KP_ENTER }, { user_command::sandboxactivate, GLFW_KEY_S | keymodifier::shift }, // autosandboxtoggle, diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index 9747b0358..eba971da9 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -64,7 +64,7 @@ mouse_slider::bind( user_command const &Command ) { auto const brakerangemultiplier { powerrange / LocalBrakePosNo }; m_valuerange = 1.0; - m_value = + m_value = 0.5 + 0.5 * ( vehicle->CoupledCtrl ? vehicle->MainCtrlPos + vehicle->ScndCtrlPos : @@ -550,6 +550,12 @@ drivermouse_input::default_bindings() { { "alarmchain:", { user_command::alarmchaintoggle, user_command::none } }, + { "alarmchainon:", { + user_command::alarmchainenable, + user_command::none} }, + { "alarmchainoff:", { + user_command::alarmchainenable, + user_command::none} }, { "brakeprofile_sw:", { user_command::brakeactingspeedincrease, user_command::brakeactingspeeddecrease } }, diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 1c3ef2239..00fdc20f7 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -434,6 +434,12 @@ std::unordered_map vr_openvr::m_buttonb { "alarmchain:", { user_command::alarmchaintoggle, user_command::none } }, + { "alarmchainon:", { + user_command::alarmchainenable, + user_command::none} }, + { "alarmchainoff:", { + user_command::alarmchainenable, + user_command::none} }, { "brakeprofile_sw:", { user_command::brakeactingspeedincrease, user_command::brakeactingspeeddecrease } }, @@ -942,4 +948,3 @@ std::unordered_map vr_openvr::m_buttonb }; bool vr_openvr::backend_register = vr_interface_factory::get_instance()->register_backend("openvr", vr_openvr::create_func); - From 7880063f5c6b58d8487e7052dd2211f645f84e9c Mon Sep 17 00:00:00 2001 From: maciejbaur Date: Wed, 28 Sep 2022 22:13:54 +0200 Subject: [PATCH 3/6] (commands) add radioenable and radiodisable commands --- Train.cpp | 21 +++++++++++++++++++-- Train.h | 2 ++ command.cpp | 2 ++ command.h | 2 ++ driverkeyboardinput.cpp | 2 ++ drivermouseinput.cpp | 6 ++++++ vr/openvr_imp.cpp | 6 ++++++ 7 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Train.cpp b/Train.cpp index db1a75402..f59e9f1d1 100644 --- a/Train.cpp +++ b/Train.cpp @@ -426,6 +426,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::hornhighactivate, &TTrain::OnCommand_hornhighactivate }, { user_command::whistleactivate, &TTrain::OnCommand_whistleactivate }, { user_command::radiotoggle, &TTrain::OnCommand_radiotoggle }, + { user_command::radioenable, &TTrain::OnCommand_radioenable }, + { user_command::radiodisable, &TTrain::OnCommand_radiodisable }, { user_command::radiochannelincrease, &TTrain::OnCommand_radiochannelincrease }, { user_command::radiochanneldecrease, &TTrain::OnCommand_radiochanneldecrease }, { user_command::radiostopsend, &TTrain::OnCommand_radiostopsend }, @@ -6395,7 +6397,6 @@ void TTrain::OnCommand_whistleactivate( TTrain *Train, command_data const &Comma } void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command ) { - if( Command.action != GLFW_PRESS ) { return; } // NOTE: we ignore the lack of 3d model to allow system reset after receiving radio-stop signal @@ -6407,10 +6408,26 @@ void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command ) // only reacting to press, so the sound can loop uninterrupted if( false == Train->mvOccupied->Radio ) { // turn on - Train->mvOccupied->Radio = true; + OnCommand_radioenable(Train, Command); } else { // turn off + OnCommand_radiodisable(Train, Command); + } +} + +void TTrain::OnCommand_radioenable( TTrain *Train, command_data const &Command ) { + if( Command.action != GLFW_PRESS ) { return; } + + if( false == Train->mvOccupied->Radio ) { + Train->mvOccupied->Radio = true; + } +} + +void TTrain::OnCommand_radiodisable( TTrain *Train, command_data const &Command ) { + if( Command.action != GLFW_PRESS ) { return; } + + if(Train->mvOccupied->Radio ) { Train->mvOccupied->Radio = false; } } diff --git a/Train.h b/Train.h index 31f6c23cc..407f6590c 100644 --- a/Train.h +++ b/Train.h @@ -448,6 +448,8 @@ class TTrain { static void OnCommand_hornhighactivate( TTrain *Train, command_data const &Command ); static void OnCommand_whistleactivate( TTrain *Train, command_data const &Command ); static void OnCommand_radiotoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_radioenable( TTrain *Train, command_data const &Command ); + static void OnCommand_radiodisable( TTrain *Train, command_data const &Command ); static void OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command ); static void OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command ); static void OnCommand_radiostopsend( TTrain *Train, command_data const &Command ); diff --git a/command.cpp b/command.cpp index bd980d410..f9e59b065 100644 --- a/command.cpp +++ b/command.cpp @@ -136,6 +136,8 @@ commanddescription_sequence Commands_descriptions = { { "hornhighactivate", command_target::vehicle, command_mode::oneoff }, { "whistleactivate", command_target::vehicle, command_mode::oneoff }, { "radiotoggle", command_target::vehicle, command_mode::oneoff }, + { "radioenable", command_target::vehicle, command_mode::oneoff }, + { "radiodisable", command_target::vehicle, command_mode::oneoff }, { "radiochannelincrease", command_target::vehicle, command_mode::oneoff }, { "radiochanneldecrease", command_target::vehicle, command_mode::oneoff }, { "radiostopsend", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index 2c0dff215..61810e375 100644 --- a/command.h +++ b/command.h @@ -129,6 +129,8 @@ enum class user_command { hornhighactivate, whistleactivate, radiotoggle, + radioenable, + radiodisable, radiochannelincrease, radiochanneldecrease, radiostopsend, diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index 0fe8736b0..7ed2580dc 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -137,6 +137,8 @@ driverkeyboard_input::default_bindings() { { user_command::hornhighactivate, GLFW_KEY_S }, { user_command::whistleactivate, GLFW_KEY_Z }, { user_command::radiotoggle, GLFW_KEY_R | keymodifier::control }, + // radioenable + // radiodisable { user_command::radiochannelincrease, GLFW_KEY_EQUAL }, { user_command::radiochanneldecrease, GLFW_KEY_MINUS }, { user_command::radiostopsend, GLFW_KEY_PAUSE | keymodifier::shift | keymodifier::control }, diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index eba971da9..c611321c3 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -776,6 +776,12 @@ drivermouse_input::default_bindings() { { "radio_sw:", { user_command::radiotoggle, user_command::none } }, + { "radioon_sw:", { + user_command::radioenable, + user_command::none } }, + { "radiooff_sw:", { + user_command::radiodisable, + user_command::none } }, { "radiochannel_sw:", { user_command::radiochannelincrease, user_command::radiochanneldecrease } }, diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 00fdc20f7..3edbc6c91 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -657,6 +657,12 @@ std::unordered_map vr_openvr::m_buttonb { "radio_sw:", { user_command::radiotoggle, user_command::none } }, + { "radioon_sw:", { + user_command::radioenable, + user_command::none } }, + { "radiooff_sw:", { + user_command::radiodisable, + user_command::none } }, { "radiochannel_sw:", { user_command::radiochannelincrease, user_command::radiochanneldecrease } }, From 57dbcf79e15bbfba5969f1278c2ad324d0855841 Mon Sep 17 00:00:00 2001 From: Marcin Nowak Date: Wed, 28 Sep 2022 23:29:36 +0200 Subject: [PATCH 4/6] (commands) add radiostopenable and radiostopdisable commands --- Train.cpp | 20 ++++++++++++++++++++ Train.h | 2 ++ command.cpp | 2 ++ command.h | 2 ++ driverkeyboardinput.cpp | 2 ++ drivermouseinput.cpp | 6 ++++++ vr/openvr_imp.cpp | 6 ++++++ 7 files changed, 40 insertions(+) diff --git a/Train.cpp b/Train.cpp index f59e9f1d1..6701fc104 100644 --- a/Train.cpp +++ b/Train.cpp @@ -431,6 +431,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::radiochannelincrease, &TTrain::OnCommand_radiochannelincrease }, { user_command::radiochanneldecrease, &TTrain::OnCommand_radiochanneldecrease }, { user_command::radiostopsend, &TTrain::OnCommand_radiostopsend }, + { user_command::radiostopenable, &TTrain::OnCommand_radiostopenable }, + { user_command::radiostopdisable, &TTrain::OnCommand_radiostopdisable }, { user_command::radiostoptest, &TTrain::OnCommand_radiostoptest }, { user_command::radiocall3send, &TTrain::OnCommand_radiocall3send }, { user_command::radiovolumeincrease, &TTrain::OnCommand_radiovolumeincrease }, @@ -6476,6 +6478,24 @@ void TTrain::OnCommand_radiostopsend( TTrain *Train, command_data const &Command } } +void TTrain::OnCommand_radiostopenable( TTrain *Train, command_data const &Command ) { + if( Command.action == GLFW_PRESS && Train->ggRadioStop.GetValue() == 0 ) { + if( ( true == Train->mvOccupied->Radio ) + && ( Train->mvOccupied->Power24vIsAvailable || Train->mvOccupied->Power110vIsAvailable ) ) { + simulation::Region->RadioStop( Train->Dynamic()->GetPosition() ); + } + // visual feedback + Train->ggRadioStop.UpdateValue( 1.0 ); + } +} + +void TTrain::OnCommand_radiostopdisable( TTrain *Train, command_data const &Command ) { + if( Command.action == GLFW_PRESS && Train->ggRadioStop.GetValue() > 0 ) { + // visual feedback + Train->ggRadioStop.UpdateValue( 0.0 ); + } +} + void TTrain::OnCommand_radiostoptest( TTrain *Train, command_data const &Command ) { if( Command.action == GLFW_PRESS ) { diff --git a/Train.h b/Train.h index 407f6590c..502dc2448 100644 --- a/Train.h +++ b/Train.h @@ -453,6 +453,8 @@ class TTrain { static void OnCommand_radiochannelincrease( TTrain *Train, command_data const &Command ); static void OnCommand_radiochanneldecrease( TTrain *Train, command_data const &Command ); static void OnCommand_radiostopsend( TTrain *Train, command_data const &Command ); + static void OnCommand_radiostopenable( TTrain *Train, command_data const &Command ); + static void OnCommand_radiostopdisable( TTrain *Train, command_data const &Command ); static void OnCommand_radiostoptest( TTrain *Train, command_data const &Command ); static void OnCommand_radiocall3send( TTrain *Train, command_data const &Command ); static void OnCommand_radiovolumeincrease(TTrain *Train, command_data const &Command); diff --git a/command.cpp b/command.cpp index f9e59b065..605e174f5 100644 --- a/command.cpp +++ b/command.cpp @@ -141,6 +141,8 @@ commanddescription_sequence Commands_descriptions = { { "radiochannelincrease", command_target::vehicle, command_mode::oneoff }, { "radiochanneldecrease", command_target::vehicle, command_mode::oneoff }, { "radiostopsend", command_target::vehicle, command_mode::oneoff }, + { "radiostopenable", command_target::vehicle, command_mode::oneoff }, + { "radiostopdisable", command_target::vehicle, command_mode::oneoff }, { "radiostoptest", command_target::vehicle, command_mode::oneoff }, { "radiocall3send", command_target::vehicle, command_mode::oneoff }, { "radiovolumeincrease", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index 61810e375..410305242 100644 --- a/command.h +++ b/command.h @@ -134,6 +134,8 @@ enum class user_command { radiochannelincrease, radiochanneldecrease, radiostopsend, + radiostopenable, + radiostopdisable, radiostoptest, radiocall3send, radiovolumeincrease, diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index 7ed2580dc..15410f98b 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -142,6 +142,8 @@ driverkeyboard_input::default_bindings() { { user_command::radiochannelincrease, GLFW_KEY_EQUAL }, { user_command::radiochanneldecrease, GLFW_KEY_MINUS }, { user_command::radiostopsend, GLFW_KEY_PAUSE | keymodifier::shift | keymodifier::control }, + // radiostopenable + // radiostopdisable { user_command::radiostoptest, GLFW_KEY_R | keymodifier::shift | keymodifier::control }, { user_command::radiocall3send, GLFW_KEY_BACKSPACE }, // radiovolumeincrease, diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index c611321c3..bdbde82d1 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -794,6 +794,12 @@ drivermouse_input::default_bindings() { { "radiostop_sw:", { user_command::radiostopsend, user_command::none } }, + { "radiostopon_sw:", { + user_command::radiostopenable, + user_command::none } }, + { "radiostopoff_sw:", { + user_command::radiostopdisable, + user_command::none } }, { "radiotest_sw:", { user_command::radiostoptest, user_command::none } }, diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 3edbc6c91..dcec1e2b7 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -675,6 +675,12 @@ std::unordered_map vr_openvr::m_buttonb { "radiostop_sw:", { user_command::radiostopsend, user_command::none } }, + { "radiostopon_sw:", { + user_command::radiostopenable, + user_command::none } }, + { "radiostopoff_sw:", { + user_command::radiostopdisable, + user_command::none } }, { "radiotest_sw:", { user_command::radiostoptest, user_command::none } }, From 1d341944535d14a499e3b4adc249ab20d25a2053 Mon Sep 17 00:00:00 2001 From: Marcin Nowak Date: Wed, 28 Sep 2022 23:56:10 +0200 Subject: [PATCH 5/6] (commands) add timetablelightenable and timetablelightdisable commands --- Train.cpp | 27 ++++++++++++++++++++++++++- Train.h | 2 ++ command.cpp | 2 ++ command.h | 2 ++ driverkeyboardinput.cpp | 2 ++ drivermouseinput.cpp | 6 ++++++ vr/openvr_imp.cpp | 6 ++++++ 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index 6701fc104..0e2764800 100644 --- a/Train.cpp +++ b/Train.cpp @@ -400,6 +400,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::instrumentlightdisable, &TTrain::OnCommand_instrumentlightdisable }, { user_command::dashboardlighttoggle, &TTrain::OnCommand_dashboardlighttoggle }, { user_command::timetablelighttoggle, &TTrain::OnCommand_timetablelighttoggle }, + { user_command::timetablelightenable, &TTrain::OnCommand_timetablelightenable }, + { user_command::timetablelightdisable, &TTrain::OnCommand_timetablelightdisable }, { user_command::doorlocktoggle, &TTrain::OnCommand_doorlocktoggle }, { user_command::doortoggleleft, &TTrain::OnCommand_doortoggleleft }, { user_command::doortoggleright, &TTrain::OnCommand_doortoggleright }, @@ -5171,6 +5173,18 @@ void TTrain::OnCommand_timetablelighttoggle( TTrain *Train, command_data const & // only reacting to press, so the switch doesn't flip back and forth if key is held down if( Command.action != GLFW_PRESS ) { return; } + if( false == Train->TimetableLightActive ) { + OnCommand_timetablelightenable(Train, Command); + } + else { + OnCommand_timetablelightdisable(Train, Command); + } +} + +void TTrain::OnCommand_timetablelightenable( TTrain *Train, command_data const &Command ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Command.action != GLFW_PRESS ) { return; } + if( Train->ggTimetableLightButton.SubModel == nullptr ) { // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels WriteLog( "Timetable Light switch is missing, or wasn't defined" ); @@ -5183,7 +5197,18 @@ void TTrain::OnCommand_timetablelighttoggle( TTrain *Train, command_data const & // visual feedback Train->ggTimetableLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } - else { +} + +void TTrain::OnCommand_timetablelightdisable( TTrain *Train, command_data const &Command ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Command.action != GLFW_PRESS ) { return; } + + if( Train->ggTimetableLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Timetable Light switch is missing, or wasn't defined" ); + return; + } + if( Train->TimetableLightActive ) { //turn off Train->TimetableLightActive = false; // visual feedback diff --git a/Train.h b/Train.h index 502dc2448..cd99c13f9 100644 --- a/Train.h +++ b/Train.h @@ -421,6 +421,8 @@ class TTrain { static void OnCommand_instrumentlightdisable( TTrain *Train, command_data const &Command ); static void OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command ); static void OnCommand_timetablelighttoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_timetablelightenable( TTrain *Train, command_data const &Command ); + static void OnCommand_timetablelightdisable( TTrain *Train, command_data const &Command ); static void OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ); static void OnCommand_doortoggleleft( TTrain *Train, command_data const &Command ); static void OnCommand_doortoggleright( TTrain *Train, command_data const &Command ); diff --git a/command.cpp b/command.cpp index 605e174f5..4fbad190d 100644 --- a/command.cpp +++ b/command.cpp @@ -258,6 +258,8 @@ commanddescription_sequence Commands_descriptions = { { "instrumentlightdisable", command_target::vehicle, command_mode::oneoff }, { "dashboardlighttoggle", command_target::vehicle, command_mode::oneoff }, { "timetablelighttoggle", command_target::vehicle, command_mode::oneoff }, + { "timetablelightenable", command_target::vehicle, command_mode::oneoff }, + { "timetablelightdisable", command_target::vehicle, command_mode::oneoff }, { "generictoggle0", command_target::vehicle, command_mode::oneoff }, { "generictoggle1", command_target::vehicle, command_mode::oneoff }, { "generictoggle2", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index 410305242..f0212a479 100644 --- a/command.h +++ b/command.h @@ -253,6 +253,8 @@ enum class user_command { instrumentlightdisable, dashboardlighttoggle, timetablelighttoggle, + timetablelightenable, + timetablelightdisable, generictoggle0, generictoggle1, generictoggle2, diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index 15410f98b..0b0e1fd08 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -258,6 +258,8 @@ driverkeyboard_input::default_bindings() { // instrumentlightdisable, { user_command::dashboardlighttoggle, GLFW_KEY_SEMICOLON | keymodifier::shift }, { user_command::timetablelighttoggle, GLFW_KEY_APOSTROPHE | keymodifier::shift }, + // timetablelightenable + // timetablelightdisable { user_command::generictoggle0, GLFW_KEY_0 }, { user_command::generictoggle1, GLFW_KEY_1 }, { user_command::generictoggle2, GLFW_KEY_2 }, diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index bdbde82d1..1f331794e 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -872,6 +872,12 @@ drivermouse_input::default_bindings() { { "timetablelight_sw:", { user_command::timetablelighttoggle, user_command::none } }, + { "timetablelighton_sw:", { + user_command::timetablelightenable, + user_command::none } }, + { "timetablelightoff_sw:", { + user_command::timetablelightdisable, + user_command::none } }, { "cablight_sw:", { user_command::interiorlighttoggle, user_command::none } }, diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index dcec1e2b7..ee98ffb0c 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -750,6 +750,12 @@ std::unordered_map vr_openvr::m_buttonb { "timetablelight_sw:", { user_command::timetablelighttoggle, user_command::none } }, + { "timetablelighton_sw:", { + user_command::timetablelightenable, + user_command::none } }, + { "timetablelightoff_sw:", { + user_command::timetablelightdisable, + user_command::none } }, { "cablight_sw:", { user_command::interiorlighttoggle, user_command::none } }, From 3bd90ec5b2c0646feca4ba32a08efa779ea7e52d Mon Sep 17 00:00:00 2001 From: Marcin Nowak Date: Thu, 29 Sep 2022 00:09:14 +0200 Subject: [PATCH 6/6] (commands) add dashboardlightenable and dashboardlightdisable commands --- Train.cpp | 25 ++++++++++++++++++++++++- Train.h | 2 ++ command.cpp | 2 ++ command.h | 2 ++ driverkeyboardinput.cpp | 2 ++ drivermouseinput.cpp | 6 ++++++ vr/openvr_imp.cpp | 6 ++++++ 7 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index 0e2764800..5b0dea55f 100644 --- a/Train.cpp +++ b/Train.cpp @@ -399,6 +399,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::instrumentlightenable, &TTrain::OnCommand_instrumentlightenable }, { user_command::instrumentlightdisable, &TTrain::OnCommand_instrumentlightdisable }, { user_command::dashboardlighttoggle, &TTrain::OnCommand_dashboardlighttoggle }, + { user_command::dashboardlightenable, &TTrain::OnCommand_dashboardlightenable }, + { user_command::dashboardlightdisable, &TTrain::OnCommand_dashboardlightdisable }, { user_command::timetablelighttoggle, &TTrain::OnCommand_timetablelighttoggle }, { user_command::timetablelightenable, &TTrain::OnCommand_timetablelightenable }, { user_command::timetablelightdisable, &TTrain::OnCommand_timetablelightdisable }, @@ -5146,6 +5148,15 @@ void TTrain::OnCommand_instrumentlightdisable( TTrain *Train, command_data const } void TTrain::OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command ) { + if( false == Train->DashboardLightActive ) { + OnCommand_dashboardlightenable(Train, Command); + } + else { + OnCommand_dashboardlightdisable(Train, Command); + } +} + +void TTrain::OnCommand_dashboardlightenable( TTrain *Train, command_data const &Command ) { // only reacting to press, so the switch doesn't flip back and forth if key is held down if( Command.action != GLFW_PRESS ) { return; } @@ -5161,7 +5172,19 @@ void TTrain::OnCommand_dashboardlighttoggle( TTrain *Train, command_data const & // visual feedback Train->ggDashboardLightButton.UpdateValue( 1.0, Train->dsbSwitch ); } - else { +} + +void TTrain::OnCommand_dashboardlightdisable( TTrain *Train, command_data const &Command ) { + // only reacting to press, so the switch doesn't flip back and forth if key is held down + if( Command.action != GLFW_PRESS ) { return; } + + if( Train->ggDashboardLightButton.SubModel == nullptr ) { + // TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels + WriteLog( "Dashboard Light switch is missing, or wasn't defined" ); + return; + } + + if( Train->DashboardLightActive ) { //turn off Train->DashboardLightActive = false; // visual feedback diff --git a/Train.h b/Train.h index cd99c13f9..ba187ef2a 100644 --- a/Train.h +++ b/Train.h @@ -420,6 +420,8 @@ class TTrain { static void OnCommand_instrumentlightenable( TTrain *Train, command_data const &Command ); static void OnCommand_instrumentlightdisable( TTrain *Train, command_data const &Command ); static void OnCommand_dashboardlighttoggle( TTrain *Train, command_data const &Command ); + static void OnCommand_dashboardlightenable( TTrain *Train, command_data const &Command ); + static void OnCommand_dashboardlightdisable( TTrain *Train, command_data const &Command ); static void OnCommand_timetablelighttoggle( TTrain *Train, command_data const &Command ); static void OnCommand_timetablelightenable( TTrain *Train, command_data const &Command ); static void OnCommand_timetablelightdisable( TTrain *Train, command_data const &Command ); diff --git a/command.cpp b/command.cpp index 4fbad190d..03f0bcf4a 100644 --- a/command.cpp +++ b/command.cpp @@ -257,6 +257,8 @@ commanddescription_sequence Commands_descriptions = { { "instrumentlightenable", command_target::vehicle, command_mode::oneoff }, { "instrumentlightdisable", command_target::vehicle, command_mode::oneoff }, { "dashboardlighttoggle", command_target::vehicle, command_mode::oneoff }, + { "dashboardlightenable", command_target::vehicle, command_mode::oneoff }, + { "dashboardlightdisable", command_target::vehicle, command_mode::oneoff }, { "timetablelighttoggle", command_target::vehicle, command_mode::oneoff }, { "timetablelightenable", command_target::vehicle, command_mode::oneoff }, { "timetablelightdisable", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index f0212a479..1ca1a15a4 100644 --- a/command.h +++ b/command.h @@ -252,6 +252,8 @@ enum class user_command { instrumentlightenable, instrumentlightdisable, dashboardlighttoggle, + dashboardlightenable, + dashboardlightdisable, timetablelighttoggle, timetablelightenable, timetablelightdisable, diff --git a/driverkeyboardinput.cpp b/driverkeyboardinput.cpp index 0b0e1fd08..60f53e44f 100644 --- a/driverkeyboardinput.cpp +++ b/driverkeyboardinput.cpp @@ -257,6 +257,8 @@ driverkeyboard_input::default_bindings() { // instrumentlightenable, // instrumentlightdisable, { user_command::dashboardlighttoggle, GLFW_KEY_SEMICOLON | keymodifier::shift }, + // dashboardlightenable + // dashboardlightdisable { user_command::timetablelighttoggle, GLFW_KEY_APOSTROPHE | keymodifier::shift }, // timetablelightenable // timetablelightdisable diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index 1f331794e..f54634067 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -869,6 +869,12 @@ drivermouse_input::default_bindings() { { "dashboardlight_sw:", { user_command::dashboardlighttoggle, user_command::none } }, + { "dashboardlighton_sw:", { + user_command::dashboardlightenable, + user_command::none } }, + { "dashboardlightoff_sw:", { + user_command::dashboardlightdisable, + user_command::none } }, { "timetablelight_sw:", { user_command::timetablelighttoggle, user_command::none } }, diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index ee98ffb0c..8be821588 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -747,6 +747,12 @@ std::unordered_map vr_openvr::m_buttonb { "dashboardlight_sw:", { user_command::dashboardlighttoggle, user_command::none } }, + { "dashboardlighton_sw:", { + user_command::dashboardlightenable, + user_command::none } }, + { "dashboardlightoff_sw:", { + user_command::dashboardlightdisable, + user_command::none } }, { "timetablelight_sw:", { user_command::timetablelighttoggle, user_command::none } },