mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-27 21:45:16 +01:00
origin/staging7ac2472c3into feat/gl46-migrationdb26a33ed, so that #468 merges into staging. Merge base037158104. Staging carries master up to571487612(squashed in #514); this branch had merged master up to7c12b83ba. Conflicts, file by file: - README.md: WITH_BETTER_RENDERER row dropped (gl46), USE_SYSTEM_JSON row kept (staging) - CMakeLists.txt: gl46 lists, plus staging's new core sources (hardwareinfo, sn_utils, regionfile, inionlysettings, fieldshunting, gaugewrap, drivingaid, signalpassing, brakereleaser, crew, brakecharge); none listed twice - tests/unit/CMakeLists.txt: both (texturealpha, freecameramotion; editorSwitchDrives, Camera) - vehicle/brakingcurve.{h,cpp}, tests/unit/test_braking_curve.cpp (add/add): staging (#479 brake_acting on the same #409 code) - editor/editorHttp.cpp: staging (it has gl46's #432 and certificate fixes, plus #439 libcurl loaded at run time) - tests/unit/test_editor_http.cpp (add/add): staging (adds the available() case of #439) - utilities/Globals.h: gl46 crashdump_full (staging's CrashDumpFull is #425, replaced here by utilities/crashdump.cpp); fmradio and staging's OpenAL options both; gfx_headlights_beamwidth (#481) not taken - utilities/Globals.cpp: both (odometer.expiry, OpenAL keys, fmradio, gl46 gfx keys); gfx.headlights.beamwidth (#481) not taken - utilities/Logs.cpp: staging's log_file_name() for both files, with gl46's crashdump_set_log_file() for both - utilities/utilities.h: gl46 set_thread_random_engine(); Random(int, int) gone on both sides - tests/unit/test_utilities.cpp: staging's includes - simulation/simulationtest.cpp: gl46 (no NvRenderer, LegacyRenderer, BasicRenderer here) - ci_shadervalidator/* (incl. add/add utilities/Logs.h): gl46's validator of shaders/ogl46 and shaders/vk14; staging's #437 fixed the GL 3.3 one - gl/shader.cpp, gl/glsl_common.cpp: gl46 (shaders come from rendering/common/shadersource.cpp); HEADLIGHT_BEAM_WIDTH (#481) not taken - shaders/mat_wire.frag: gl46. Rename detection paired staging's mat_colored.frag (#481) with it - lang/editor_pl.po: union; the 12 camera speed / orthophoto entries staging adds are here already (master #312) - audio/audiorenderer.{h,cpp}: both (fmradio; startsample and the low-pass filter); the destructor releases the radio, then the filter - application/editormode.h, application/editormodeswitchdrive.cpp: staging (#509 on #330, which is all this side had) - application/application.cpp: gl46's start sequence (no init_ogl, ANGLE or NvRenderer; crash window after init_ui) with staging's hardware::log_system() (#389) - EU07.cpp: gl46 (crash reports of utilities/crashdump.cpp); staging's side was #425's handler, replaced here - model/Texture.{h,cpp}: gl46 (texture_source); staging's side is master #399/#411/#362/#386, merged here before - world/Track.h, world/TrackSleepers.h: both (TrackBlend, lay(Fastened)/fasten; TrackBuckle, pack_models) - world/Segment.cpp: staging's track buckling on the split stray factors both sides have - vehicle/Driver.h: staging's additions (#444, #494, #473, #346, timetable flags) - vehicle/Driver.cpp: staging's file, with this branch'sf4f8c75e4(road orders measured along the lane) and8fbf05674(a holding road order blocks the ones past it) applied again; #409's SeenAheadTolerance gives way to #473 - vehicle/DynObj.h: friend opengl46_renderer and friend class vehicle_table - vehicle/DynObj.cpp: gl46's vehicle_table::update() with staging's update_off_track_contacts() and update_brake_pipes() - McZapkie/Mover.cpp: staging's function splits (#239) and hose exchange (#388); every line this branch added to Mover.cpp/MOVER.h is kept - .github/workflows/build_bin.yml: staging's apt-install step (#497) and pinned download-artifact (#331) Modify/delete, kept deleted: - rendering/opengl33renderer.{cpp,h}, rendering/openglparticles.cpp, rendering/openglrenderer.{cpp,h}: staging's versions are master's, and every master change to them is in this branch's history already - shaders/light_common.glsl, shaders/mat_sunlessnormalmap_specgloss.frag: see below Carried into this branch's code: - the hose exchange after each sub-step (#387/#388) also in update_steps_parallel(), per group of vehicles, as update() does it single-threaded - physics.pipewake (pipe_wakes(), wake_cause::scndpipe) in staging's GetScndDVc(), where the main reservoir hose exchange went - hardware::log_gl_context() (#389) in after_window() of the GL 4.6 backend, init_ogl() being gone Taken back out of the auto-merge (renderers this branch removed): - shaders/vk14/tonemapping.glsl: #481's switch to ACES, applied there by rename detection - environment/skydome.cpp, simulation/simulationenvironment.cpp: #415, the sky of the legacy renderer - application/application.cpp: #384's fallback of an unknown gfxrenderer, which this branch had dropped Not carried from staging (renderer files removed here): - master #481 (571487612): old assets drawn as in 26.05 (metal diffuse, sun highlight tint, ACES, SUN_DIFFUSE_SCALE 2.5, untinted Diffuse, mat_colored base) and gfx.headlights.beamwidth. Made for the GL 3.3 shaders; the PBR shaders of shaders/ogl46 and vk14 (and their SPIR-V binaries) are the author's call - #437: the unique temporary file of the shader validator (Sonar S5443); gl46's validator still writes /tmp/shader* Unit tests: 1133 of 1137 cases pass. Four staging tests fail (derailment: a repaired vehicle is back on the rails; three pullee cases): the vehicle stands, and with physics.sleepheld (on by default here) its physics sleeps with the Fb / FStand of before. With physics.sleepheld off they pass. Left to the author.
1261 lines
40 KiB
C++
1261 lines
40 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "input/drivermouseinput.h"
|
|
|
|
#include "utilities/Globals.h"
|
|
#include "application/application.h"
|
|
#include "utilities/Globals.h"
|
|
#include "utilities/Timer.h"
|
|
#include "simulation/simulation.h"
|
|
#include "vehicle/Train.h"
|
|
#include "model/AnimModel.h"
|
|
#include "rendering/renderer.h"
|
|
#include "application/uilayer.h"
|
|
#include "utilities/Logs.h"
|
|
#include "utilities/utilities.h"
|
|
|
|
auto const EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 };
|
|
|
|
void
|
|
mouse_slider::bind( user_command const &Command ) {
|
|
|
|
m_command = Command;
|
|
m_universal.reset();
|
|
m_universaldrag.reset();
|
|
|
|
auto const *train { simulation::Train };
|
|
TMoverParameters const *vehicle { nullptr };
|
|
switch( m_command ) {
|
|
using enum user_command;
|
|
case jointcontrollerset:
|
|
case mastercontrollerset:
|
|
case secondcontrollerset: {
|
|
vehicle = train ? train->Controlled() : nullptr;
|
|
break;
|
|
}
|
|
case trainbrakeset:
|
|
case independentbrakeset: {
|
|
vehicle = train ? train->Occupied() : nullptr;
|
|
break;
|
|
}
|
|
default: {
|
|
break;
|
|
}
|
|
}
|
|
if( vehicle == nullptr ) { return; }
|
|
|
|
// calculate initial value and accepted range
|
|
switch( m_command ) {
|
|
case user_command::jointcontrollerset: {
|
|
// NOTE: special case, merges two separate controls
|
|
auto const *occupied { train ? train->Occupied() : nullptr };
|
|
if( occupied == nullptr ) { return; }
|
|
|
|
auto const powerrange { static_cast<double>(
|
|
vehicle->CoupledCtrl ?
|
|
vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo :
|
|
vehicle->MainCtrlPosNo ) };
|
|
// for simplicity upper half of the range controls power, lower controls brakes
|
|
|
|
m_valuerange = 1.0;
|
|
m_value =
|
|
0.5
|
|
+ 0.5 * ( vehicle->CoupledCtrl ?
|
|
vehicle->MainCtrlPos + vehicle->ScndCtrlPos :
|
|
vehicle->MainCtrlPos ) / powerrange
|
|
- 0.5 * occupied->LocalBrakePosA;
|
|
m_analogue = true;
|
|
m_invertrange = false;
|
|
break;
|
|
}
|
|
case user_command::mastercontrollerset: {
|
|
m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : vehicle->MainCtrlPosNo;
|
|
m_value = vehicle->CoupledCtrl ? vehicle->MainCtrlPos + vehicle->ScndCtrlPos : vehicle->MainCtrlPos;
|
|
m_analogue = false;
|
|
m_invertrange = false;
|
|
break;
|
|
}
|
|
case user_command::secondcontrollerset: {
|
|
m_valuerange = vehicle->ScndCtrlPosNo;
|
|
m_value = vehicle->ScndCtrlPos;
|
|
m_analogue = false;
|
|
m_invertrange = true;
|
|
break;
|
|
}
|
|
case user_command::trainbrakeset: {
|
|
m_valuerange = 1.0;
|
|
m_value = ( vehicle->fBrakeCtrlPos - vehicle->Handle->GetPos( bh_MIN ) ) / ( vehicle->Handle->GetPos( bh_MAX ) - vehicle->Handle->GetPos( bh_MIN ) );
|
|
m_analogue = true;
|
|
m_invertrange = true;
|
|
break;
|
|
}
|
|
case user_command::independentbrakeset: {
|
|
m_valuerange = 1.0;
|
|
m_value = vehicle->LocalBrakePosA;
|
|
m_analogue = true;
|
|
m_invertrange = true;
|
|
break;
|
|
}
|
|
default: {
|
|
m_valuerange = 1;
|
|
break;
|
|
}
|
|
}
|
|
// hide the cursor and place it in accordance with current slider value
|
|
m_cursorposition = glm::dvec2(Global.cursor_pos);
|
|
Application.set_cursor( GLFW_CURSOR_DISABLED );
|
|
|
|
auto const controlsize { Global.window_size.y * EU07_CONTROLLER_MOUSESLIDERSIZE };
|
|
auto const controledge { Global.window_size.y * 0.5 + controlsize * 0.5 };
|
|
auto const stepsize { controlsize / m_valuerange };
|
|
|
|
if( m_invertrange ) {
|
|
m_value = ( m_analogue ? 1.0 : m_valuerange ) - m_value;
|
|
}
|
|
|
|
Application.set_cursor_pos(
|
|
Global.window_size.y,
|
|
m_analogue ? controledge - m_value * controlsize : controledge - m_value * stepsize - 0.5 * stepsize );
|
|
}
|
|
|
|
void
|
|
mouse_slider::bind_universal( int const Index, universal_drag::direction const Drag, float const Position ) {
|
|
|
|
m_command = static_cast<user_command>( static_cast<int>( user_command::genericset0 ) + Index );
|
|
m_universal = Index;
|
|
m_universaldrag.emplace( Drag, Position );
|
|
m_value = m_universaldrag->position();
|
|
m_valuerange = 1.0;
|
|
m_analogue = true;
|
|
m_invertrange = false;
|
|
// the cursor is hidden for the drag and put back where it was when the drag ends; the drag follows its moves
|
|
// from wherever it is, so it isn't placed anywhere
|
|
m_cursorposition = glm::dvec2( Global.cursor_pos );
|
|
Application.set_cursor( GLFW_CURSOR_DISABLED );
|
|
}
|
|
|
|
void
|
|
mouse_slider::release() {
|
|
|
|
m_command = user_command::none;
|
|
m_universal.reset();
|
|
m_universaldrag.reset();
|
|
Application.set_cursor_pos( m_cursorposition.x, m_cursorposition.y );
|
|
Application.set_cursor( GLFW_CURSOR_NORMAL );
|
|
}
|
|
|
|
bool
|
|
mouse_slider::on_move( double const Mousex, double const Mousey ) {
|
|
|
|
auto const controlsize { Global.window_size.y * EU07_CONTROLLER_MOUSESLIDERSIZE };
|
|
|
|
if( m_universaldrag ) {
|
|
// a universal control, dragged the same way as the controllers: the move of the cursor over the size of the
|
|
// slider takes it from one end to the other
|
|
if( false == m_universaldrag->move( Mousex, Mousey, controlsize ) ) {
|
|
return false;
|
|
}
|
|
m_value = m_universaldrag->position();
|
|
return true;
|
|
}
|
|
|
|
auto const controledge { Global.window_size.y * 0.5 + controlsize * 0.5 };
|
|
auto const stepsize { controlsize / m_valuerange };
|
|
|
|
auto mousey = std::clamp( Mousey, controledge - controlsize, controledge );
|
|
m_value = m_analogue ? (controledge - mousey) / controlsize : std::floor((controledge - mousey) / stepsize);
|
|
if( m_invertrange ) {
|
|
m_value = ( m_analogue ? 1.0 : m_valuerange ) - m_value; }
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
drivermouse_input::init() {
|
|
|
|
#ifdef _WIN32
|
|
DWORD systemkeyboardspeed;
|
|
::SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &systemkeyboardspeed, 0 );
|
|
m_updaterate = std::lerp( 0.5, 0.04, systemkeyboardspeed / 31.0 );
|
|
DWORD systemkeyboarddelay;
|
|
::SystemParametersInfo( SPI_GETKEYBOARDDELAY, 0, &systemkeyboarddelay, 0 );
|
|
m_updatedelay = std::lerp( 0.25, 1.0, systemkeyboarddelay / 3.0 );
|
|
#endif
|
|
|
|
default_bindings();
|
|
recall_bindings();
|
|
|
|
return true;
|
|
}
|
|
namespace fs = std::filesystem;
|
|
|
|
bool
|
|
drivermouse_input::recall_bindings() {
|
|
|
|
std::string filePath = "eu07_input-mouse.ini";
|
|
|
|
if (fs::path appPath = user_config_path("eu07_input-mouse.ini"); !appPath.empty() && fs::exists(appPath))
|
|
filePath = appPath.string();
|
|
|
|
cParser bindingparser(filePath, cParser::buffer_FILE);
|
|
|
|
if (false == bindingparser.ok()) {
|
|
return false;
|
|
}
|
|
|
|
// build helper translation tables
|
|
std::unordered_map<std::string, user_command> nametocommandmap;
|
|
std::size_t commandid = 0;
|
|
for( auto const &description : simulation::Commands_descriptions ) {
|
|
nametocommandmap.try_emplace(
|
|
description.name,
|
|
static_cast<user_command>( commandid ) );
|
|
++commandid;
|
|
}
|
|
|
|
// NOTE: to simplify things we expect one entry per line, and whole entry in one line
|
|
while( true == bindingparser.getTokens( 1, true, "\n\r" ) ) {
|
|
|
|
std::string bindingentry;
|
|
bindingparser >> bindingentry;
|
|
cParser entryparser( bindingentry );
|
|
|
|
if( true == entryparser.getTokens( 1, true, "\n\r\t " ) ) {
|
|
|
|
std::string bindingpoint {};
|
|
entryparser >> bindingpoint;
|
|
|
|
std::vector< std::reference_wrapper<user_command> > bindingtargets;
|
|
|
|
if( bindingpoint == "wheel" ) {
|
|
bindingtargets.emplace_back( std::ref( m_wheelbindings.up ) );
|
|
bindingtargets.emplace_back( std::ref( m_wheelbindings.down ) );
|
|
}
|
|
// TODO: binding targets for mouse buttons
|
|
|
|
for( auto const &bindingtarget : bindingtargets ) {
|
|
// grab command(s) associated with the input pin
|
|
auto const bindingcommandname{ entryparser.getToken<std::string>() };
|
|
if( true == bindingcommandname.empty() ) {
|
|
// no tokens left, may as well complain then call it a day
|
|
WriteLog( "Mouse binding for " + bindingpoint + " didn't specify associated command(s)" );
|
|
break;
|
|
}
|
|
auto const commandlookup = nametocommandmap.find( bindingcommandname );
|
|
if( commandlookup == nametocommandmap.end() ) {
|
|
WriteLog( "Mouse binding for " + bindingpoint + " specified unknown command, \"" + bindingcommandname + "\"" );
|
|
}
|
|
else {
|
|
bindingtarget.get() = commandlookup->second;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void
|
|
drivermouse_input::move( double Mousex, double Mousey ) {
|
|
|
|
if( false == Global.ControlPicking ) {
|
|
// default control mode
|
|
m_relay.post(
|
|
user_command::viewturn,
|
|
Mousex,
|
|
Mousey,
|
|
GLFW_PRESS,
|
|
0 );
|
|
}
|
|
else {
|
|
// control picking mode
|
|
if( m_slider.command() != user_command::none
|
|
&& true == m_slider.on_move( Mousex, Mousey ) ) {
|
|
m_relay.post(
|
|
m_slider.command(),
|
|
m_slider.value(),
|
|
0,
|
|
GLFW_PRESS,
|
|
0 );
|
|
}
|
|
|
|
if( false == m_pickmodepanning ) {
|
|
// even if the view panning isn't active we capture the cursor position in case it does get activated
|
|
m_cursorposition.x = Mousex;
|
|
m_cursorposition.y = Mousey;
|
|
return;
|
|
}
|
|
glm::dvec2 cursorposition { Mousex, Mousey };
|
|
auto const viewoffset = cursorposition - m_cursorposition;
|
|
m_relay.post(
|
|
user_command::viewturn,
|
|
viewoffset.x,
|
|
viewoffset.y,
|
|
GLFW_PRESS,
|
|
0 );
|
|
m_cursorposition = cursorposition;
|
|
}
|
|
}
|
|
|
|
void
|
|
drivermouse_input::scroll( double const /*Xoffset*/, double const Yoffset ) {
|
|
|
|
if( Global.ctrlState ) {
|
|
// ctrl + scroll wheel adjusts fov
|
|
Global.FieldOfView = std::clamp( static_cast<float>( Global.FieldOfView - Yoffset * 20.0 / Timer::subsystem.mainloop_total.average() ), 15.0f, 75.0f );
|
|
}
|
|
else {
|
|
// scroll adjusts master controller
|
|
// TODO: allow configurable scroll commands
|
|
auto command {
|
|
adjust_command(
|
|
Yoffset > 0.0 ?
|
|
m_wheelbindings.up :
|
|
m_wheelbindings.down ) };
|
|
|
|
m_relay.post(
|
|
command,
|
|
0,
|
|
0,
|
|
GLFW_PRESS,
|
|
// TODO: pass correct entity id once the missing systems are in place
|
|
0 );
|
|
}
|
|
}
|
|
|
|
void
|
|
drivermouse_input::button( int const Button, int const Action ) {
|
|
|
|
// store key state
|
|
if( Button >= 0 ) {
|
|
m_buttons[ Button ] = Action;
|
|
}
|
|
|
|
if( false == Global.ControlPicking ) { return; }
|
|
|
|
if( true == FreeFlyModeFlag ) {
|
|
// freefly mode
|
|
// left mouse button launches on_click event associated with to the node
|
|
if (Button == GLFW_MOUSE_BUTTON_LEFT && Action == GLFW_PRESS) {
|
|
GfxRenderer->Pick_Node_Callback(
|
|
[](scene::basic_node const *node) {
|
|
if( node == nullptr
|
|
|| typeid(*node) != typeid(TAnimModel) )
|
|
return;
|
|
simulation::Region->on_click( static_cast<TAnimModel const *>( node ) ); } );
|
|
}
|
|
// right button controls panning
|
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
|
m_pickmodepanning = Action == GLFW_PRESS;
|
|
}
|
|
}
|
|
else {
|
|
// cab controls mode
|
|
user_command &mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? m_mousecommandleft : m_mousecommandright;
|
|
|
|
if( Action == GLFW_RELEASE ) {
|
|
if( mousecommand != user_command::none ) {
|
|
// NOTE: basic keyboard controls don't have any parameters
|
|
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
|
// TODO: pass correct entity id once the missing systems are in place
|
|
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
|
mousecommand = user_command::none;
|
|
}
|
|
else {
|
|
m_pickwaiting = false;
|
|
if (Button == GLFW_MOUSE_BUTTON_LEFT && m_slider.command() != user_command::none) {
|
|
if( auto const universal { m_slider.universal() };
|
|
universal && m_slider.is_click() ) {
|
|
// a universal control clicked rather than dragged goes to its end, as a click on any universal does
|
|
toggle_universal( *universal );
|
|
}
|
|
else {
|
|
m_relay.post( m_slider.command(), 0, 0, Action, 0 );
|
|
}
|
|
m_slider.release();
|
|
}
|
|
// if it's the right mouse button that got released and we had no command active, we were potentially in view panning mode; stop it
|
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
|
m_pickmodepanning = false;
|
|
}
|
|
}
|
|
// if we were in varying command repeat rate, we can stop that now. done without any conditions, to catch some unforeseen edge cases
|
|
m_varyingpollrate = false;
|
|
}
|
|
else {
|
|
// if not release then it's press
|
|
m_pickwaiting = true;
|
|
GfxRenderer->Pick_Control_Callback(
|
|
[this, Button, Action, &mousecommand](TSubModel const *controlsubmodel, const glm::vec2 pos) {
|
|
using enum user_command;
|
|
|
|
bool pickwaiting = m_pickwaiting;
|
|
m_pickwaiting = false;
|
|
|
|
// click on python screen
|
|
if (Button == GLFW_MOUSE_BUTTON_LEFT
|
|
&& controlsubmodel && controlsubmodel->screen_touch_list) {
|
|
|
|
controlsubmodel->screen_touch_list->emplace_back(pos);
|
|
}
|
|
|
|
auto const [leftbinding, rightbinding]{ bindings( simulation::Train->GetLabel( controlsubmodel ) ) };
|
|
// if the recognized element under the cursor has a command associated with the pressed button, notify the recipient
|
|
mousecommand = Button == GLFW_MOUSE_BUTTON_LEFT ? leftbinding : rightbinding;
|
|
|
|
if( mousecommand == none ) {
|
|
// if we don't have any recognized element under the cursor and the right button was pressed, enter view panning mode
|
|
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
|
m_pickmodepanning = true;
|
|
}
|
|
return;
|
|
}
|
|
// check manually for commands which have 'fast' variants launched with shift modifier
|
|
if( Global.shiftState ) {
|
|
switch( mousecommand ) {
|
|
case mastercontrollerincrease: { mousecommand = mastercontrollerincreasefast; break; }
|
|
case mastercontrollerdecrease: { mousecommand = mastercontrollerdecreasefast; break; }
|
|
case secondcontrollerincrease: { mousecommand = secondcontrollerincreasefast; break; }
|
|
case secondcontrollerdecrease: { mousecommand = secondcontrollerdecreasefast; break; }
|
|
case independentbrakeincrease: { mousecommand = independentbrakeincreasefast; break; }
|
|
case independentbrakedecrease: { mousecommand = independentbrakedecreasefast; break; }
|
|
default: { break; }
|
|
}
|
|
}
|
|
// a universal control with drag: in its definition is dragged to any position between its ends,
|
|
// and a click without dragging toggles it as before (MaSzyna-EU07/maszyna#62)
|
|
if( Button == GLFW_MOUSE_BUTTON_LEFT ) {
|
|
auto const universal { universal_index( mousecommand ) };
|
|
auto const drag {
|
|
universal ?
|
|
simulation::Train->universal_drag_direction( *universal ) :
|
|
universal_drag::direction::none };
|
|
if( drag != universal_drag::direction::none ) {
|
|
mousecommand = none;
|
|
if( false == pickwaiting ) {
|
|
// the button was let go before the control was found under the cursor: a click
|
|
toggle_universal( *universal );
|
|
return;
|
|
}
|
|
m_slider.bind_universal( *universal, drag, simulation::Train->universal_position( *universal ) );
|
|
return;
|
|
}
|
|
}
|
|
|
|
switch( mousecommand ) {
|
|
case mastercontrollerincrease:
|
|
case mastercontrollerdecrease:
|
|
case secondcontrollerincrease:
|
|
case secondcontrollerdecrease:
|
|
case trainbrakeincrease:
|
|
case trainbrakedecrease:
|
|
case independentbrakeincrease:
|
|
case independentbrakedecrease: {
|
|
// these commands trigger varying repeat rate mode,
|
|
// which scales the rate based on the distance of the cursor from its point when the command was first issued
|
|
m_varyingpollrateorigin = m_cursorposition;
|
|
m_varyingpollrate = true;
|
|
break;
|
|
}
|
|
case jointcontrollerset:
|
|
case mastercontrollerset:
|
|
case secondcontrollerset:
|
|
case trainbrakeset:
|
|
case independentbrakeset: {
|
|
m_slider.bind( mousecommand );
|
|
mousecommand = none;
|
|
return;
|
|
}
|
|
default: {
|
|
break;
|
|
}
|
|
}
|
|
// NOTE: basic keyboard controls don't have any parameters
|
|
// NOTE: as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
|
// TODO: pass correct entity id once the missing systems are in place
|
|
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
|
if (!pickwaiting) // already depressed
|
|
m_relay.post( mousecommand, 0, 0, GLFW_RELEASE, 0 );
|
|
m_updateaccumulator = -0.25; // prevent potential command repeat right after issuing one
|
|
} );
|
|
}
|
|
}
|
|
}
|
|
|
|
int
|
|
drivermouse_input::button( int const Button ) const {
|
|
|
|
return m_buttons[ Button ];
|
|
}
|
|
|
|
void
|
|
drivermouse_input::poll() {
|
|
|
|
m_updateaccumulator += Timer::GetDeltaRenderTime();
|
|
|
|
auto updaterate { m_updaterate };
|
|
if( m_varyingpollrate ) {
|
|
updaterate /= std::max( 0.15, 2.0 * glm::length( m_cursorposition - m_varyingpollrateorigin ) / std::max( 1, Global.window_size.y ) );
|
|
}
|
|
|
|
while( m_updateaccumulator > updaterate ) {
|
|
|
|
if( m_mousecommandleft != user_command::none ) {
|
|
// NOTE: basic keyboard controls don't have any parameters
|
|
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
|
// TODO: pass correct entity id once the missing systems are in place
|
|
m_relay.post( m_mousecommandleft, 0, 0, GLFW_REPEAT, 0 );
|
|
}
|
|
if( m_mousecommandright != user_command::none ) {
|
|
// NOTE: basic keyboard controls don't have any parameters
|
|
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
|
// TODO: pass correct entity id once the missing systems are in place
|
|
m_relay.post( m_mousecommandright, 0, 0, GLFW_REPEAT, 0 );
|
|
}
|
|
m_updateaccumulator -= updaterate;
|
|
}
|
|
}
|
|
|
|
user_command
|
|
drivermouse_input::command() const {
|
|
|
|
return m_slider.command() != user_command::none ? m_slider.command() : m_mousecommandleft != user_command::none ? m_mousecommandleft : m_mousecommandright;
|
|
}
|
|
|
|
// returns pair of bindings associated with specified cab control
|
|
std::pair<user_command, user_command>
|
|
drivermouse_input::bindings( std::string const &Control ) const {
|
|
|
|
auto const lookup{ m_buttonbindings.find( Control ) };
|
|
|
|
if( lookup != m_buttonbindings.end() )
|
|
return { lookup->second.left, lookup->second.right };
|
|
else {
|
|
return { user_command::none, user_command::none };
|
|
}
|
|
}
|
|
|
|
void
|
|
drivermouse_input::default_bindings() {
|
|
using enum user_command;
|
|
// pierwsza komenda jest od zwiekszania a druga od zmniejszania - ewentualnie kolejno lewy i prawy przycisk
|
|
m_buttonbindings = {
|
|
{ "jointctrl:", {
|
|
jointcontrollerset,
|
|
none } },
|
|
{ "mainctrl:", {
|
|
mastercontrollerset,
|
|
none } },
|
|
{ "dynamicbrakectrl:", {
|
|
dynamicbrakecontrollerset,
|
|
none } },
|
|
{ "scndctrl:", {
|
|
secondcontrollerset,
|
|
none } },
|
|
{ "shuntmodepower:", {
|
|
secondcontrollerincrease,
|
|
secondcontrollerdecrease } },
|
|
{ "tempomat_sw:", {
|
|
tempomattoggle,
|
|
none } },
|
|
{ "tempomatoff_sw:", {
|
|
tempomattoggle,
|
|
none } },
|
|
{ "dirkey:", {
|
|
reverserincrease,
|
|
reverserdecrease } },
|
|
{ "dirforward_bt:", {
|
|
reverserforward,
|
|
none } },
|
|
{ "dirneutral_bt:", {
|
|
reverserneutral,
|
|
none } },
|
|
{ "dirbackward_bt:", {
|
|
reverserbackward,
|
|
none } },
|
|
{ "brakectrl:", {
|
|
trainbrakeset,
|
|
none } },
|
|
{ "localbrake:", {
|
|
independentbrakeset,
|
|
none } },
|
|
{ "manualbrake:", {
|
|
manualbrakeincrease,
|
|
manualbrakedecrease } },
|
|
{ "alarmchain:", {
|
|
alarmchaintoggle,
|
|
none } },
|
|
{ "alarmchainon:", {
|
|
alarmchainenable,
|
|
none} },
|
|
{ "alarmchainoff:", {
|
|
alarmchainenable,
|
|
none} },
|
|
{ "brakeprofile_sw:", {
|
|
brakeactingspeedincrease,
|
|
brakeactingspeeddecrease } },
|
|
// TODO: dedicated methods for braking speed switches
|
|
{ "brakeprofileg_sw:", {
|
|
brakeactingspeedsetcargo,
|
|
brakeactingspeedsetpassenger } },
|
|
{ "brakeprofiler_sw:", {
|
|
brakeactingspeedsetrapid,
|
|
brakeactingspeedsetpassenger } },
|
|
{ "brakeopmode_sw:", {
|
|
trainbrakeoperationmodeincrease,
|
|
trainbrakeoperationmodedecrease } },
|
|
{ "maxcurrent_sw:", {
|
|
motoroverloadrelaythresholdtoggle,
|
|
none } },
|
|
{ "autorelay_sw:", {
|
|
notchingrelaytoggle,
|
|
none } },
|
|
{ "waterpumpbreaker_sw:", {
|
|
waterpumpbreakertoggle,
|
|
none } },
|
|
{ "waterpump_sw:", {
|
|
waterpumptoggle,
|
|
none } },
|
|
{ "waterheaterbreaker_sw:", {
|
|
waterheaterbreakertoggle,
|
|
none } },
|
|
{ "waterheater_sw:", {
|
|
waterheatertoggle,
|
|
none } },
|
|
{ "fuelpump_sw:", {
|
|
fuelpumptoggle,
|
|
none } },
|
|
{ "oilpump_sw:", {
|
|
oilpumptoggle,
|
|
none } },
|
|
{ "oilfuelpump_sw:", {
|
|
oilfuelpumptoggle,
|
|
none } },
|
|
{ "tractionmode_sw:", {
|
|
tractionmodetoggle,
|
|
none } },
|
|
{ "genset_sw:", {
|
|
gensettoggle,
|
|
none } },
|
|
{ "motorblowersfront_sw:", {
|
|
motorblowerstogglefront,
|
|
none } },
|
|
{ "motorblowersrear_sw:", {
|
|
motorblowerstogglerear,
|
|
none } },
|
|
{ "motorblowersalloff_sw:", {
|
|
motorblowersdisableall,
|
|
none } },
|
|
{ "coolingfans_sw:", {
|
|
coolingfanstoggle,
|
|
none } },
|
|
{ "main_off_bt:", {
|
|
linebreakeropen,
|
|
none } },
|
|
{ "main_on_bt:",{
|
|
linebreakerclose,
|
|
none } },
|
|
{ "mainb_off_bt:", {
|
|
linebreakeropenb,
|
|
none } },
|
|
{ "mainb_on_bt:", {
|
|
linebreakercloseb,
|
|
none } },
|
|
{ "mainc_off_bt:", {
|
|
linebreakeropenc,
|
|
none } },
|
|
{ "mainc_on_bt:", {
|
|
linebreakerclosec,
|
|
none } },
|
|
{ "security_reset_bt:", {
|
|
alerteracknowledge,
|
|
none } },
|
|
{ "shp_reset_bt:", {
|
|
cabsignalacknowledge,
|
|
none } },
|
|
{ "releaser_bt:", {
|
|
independentbrakebailoff,
|
|
none } },
|
|
{ "springbraketoggle_bt:",{
|
|
springbraketoggle,
|
|
none } },
|
|
{ "springbrakeon_bt:",{
|
|
springbrakeenable,
|
|
none } },
|
|
{ "springbrakeoff_bt:",{
|
|
springbrakedisable,
|
|
none } },
|
|
{ "universalbrake1_bt:",{
|
|
universalbrakebutton1,
|
|
none } },
|
|
{ "universalbrake2_bt:",{
|
|
universalbrakebutton2,
|
|
none } },
|
|
{ "universalbrake3_bt:",{
|
|
universalbrakebutton3,
|
|
none } },
|
|
{ "epbrake_bt:",{
|
|
epbrakecontroltoggle,
|
|
none } },
|
|
{ "epbrakeon_bt:",{
|
|
epbrakecontrolenable,
|
|
none } },
|
|
{ "epbrakeoff_bt:",{
|
|
epbrakecontroldisable,
|
|
none } },
|
|
{ "sand_bt:", {
|
|
sandboxactivate,
|
|
none } },
|
|
{ "antislip_bt:", {
|
|
wheelspinbrakeactivate,
|
|
none } },
|
|
{ "horn_bt:", {
|
|
hornhighactivate,
|
|
hornlowactivate } },
|
|
{ "hornlow_bt:", {
|
|
hornlowactivate,
|
|
none } },
|
|
{ "hornhigh_bt:", {
|
|
hornhighactivate,
|
|
none } },
|
|
{ "whistle_bt:", {
|
|
whistleactivate,
|
|
none } },
|
|
{ "fuse_bt:", {
|
|
motoroverloadrelayreset,
|
|
none } },
|
|
{ "converterfuse_bt:", {
|
|
converteroverloadrelayreset,
|
|
none } },
|
|
{ "relayreset1_bt:", {
|
|
universalrelayreset1,
|
|
none } },
|
|
{ "relayreset2_bt:", {
|
|
universalrelayreset2,
|
|
none } },
|
|
{ "relayreset3_bt:", {
|
|
universalrelayreset3,
|
|
none } },
|
|
{ "stlinoff_bt:", {
|
|
motorconnectorsopen,
|
|
none } },
|
|
{ "doorleftpermit_sw:", {
|
|
doorpermitleft,
|
|
none } },
|
|
{ "doorrightpermit_sw:", {
|
|
doorpermitright,
|
|
none } },
|
|
{ "doorpermitpreset_sw:", {
|
|
doorpermitpresetactivatenext,
|
|
doorpermitpresetactivateprevious } },
|
|
{ "door_left_sw:", {
|
|
doortoggleleft,
|
|
none } },
|
|
{ "door_right_sw:", {
|
|
doortoggleright,
|
|
none } },
|
|
{ "doorlefton_sw:", {
|
|
dooropenleft,
|
|
none } },
|
|
{ "doorrighton_sw:", {
|
|
dooropenright,
|
|
none } },
|
|
{ "doorleftoff_sw:", {
|
|
doorcloseleft,
|
|
none } },
|
|
{ "doorrightoff_sw:", {
|
|
doorcloseright,
|
|
none } },
|
|
{ "doorallon_sw:", {
|
|
dooropenall,
|
|
none } },
|
|
{ "dooralloff_sw:", {
|
|
doorcloseall,
|
|
none } },
|
|
{ "doorstep_sw:", {
|
|
doorsteptoggle,
|
|
none } },
|
|
{ "doormode_sw:", {
|
|
doormodetoggle,
|
|
none } },
|
|
{ "mirrors_sw:", {
|
|
mirrorstoggle,
|
|
none } },
|
|
{ "departure_signal_bt:", {
|
|
departureannounce,
|
|
none } },
|
|
{ "upperlight_sw:", {
|
|
headlighttoggleupper,
|
|
none } },
|
|
{ "leftlight_sw:", {
|
|
headlighttoggleleft,
|
|
none } },
|
|
{ "rightlight_sw:", {
|
|
headlighttoggleright,
|
|
none } },
|
|
{ "dimheadlights_sw:", {
|
|
headlightsdimtoggle,
|
|
none } },
|
|
{"moderndimmer_sw:", {
|
|
modernlightdimmerincrease,
|
|
modernlightdimmerdecrease } },
|
|
{ "leftend_sw:", {
|
|
redmarkertoggleleft,
|
|
none } },
|
|
{ "rightend_sw:", {
|
|
redmarkertoggleright,
|
|
none } },
|
|
{ "lights_sw:", {
|
|
lightspresetactivatenext,
|
|
lightspresetactivateprevious } },
|
|
{ "rearupperlight_sw:", {
|
|
headlighttogglerearupper,
|
|
none } },
|
|
{ "rearleftlight_sw:", {
|
|
headlighttogglerearleft,
|
|
none } },
|
|
{ "rearrightlight_sw:", {
|
|
headlighttogglerearright,
|
|
none } },
|
|
{ "rearleftend_sw:", {
|
|
redmarkertogglerearleft,
|
|
none } },
|
|
{ "rearrightend_sw:", {
|
|
redmarkertogglerearright,
|
|
none } },
|
|
{ "compressor_sw:", {
|
|
compressortoggle,
|
|
none } },
|
|
{ "compressorlocal_sw:", {
|
|
compressortogglelocal,
|
|
none } },
|
|
{ "compressorlist_sw:", {
|
|
compressorpresetactivatenext,
|
|
compressorpresetactivateprevious } },
|
|
{ "converter_sw:", {
|
|
convertertoggle,
|
|
none } },
|
|
{ "converterlocal_sw:", {
|
|
convertertogglelocal,
|
|
none } },
|
|
{ "converteroff_sw:", {
|
|
convertertoggle,
|
|
none } }, // TODO: dedicated converter shutdown command
|
|
{ "main_sw:", {
|
|
linebreakertoggle,
|
|
none } },
|
|
{ "mainb_sw:", {
|
|
linebreakertoggleb,
|
|
none } },
|
|
{ "mainc_sw:", {
|
|
linebreakertogglec,
|
|
none } },
|
|
{ "radio_sw:", {
|
|
radiotoggle,
|
|
none } },
|
|
{ "radioon_sw:", {
|
|
radioenable,
|
|
none } },
|
|
{ "radiooff_sw:", {
|
|
radiodisable,
|
|
none } },
|
|
{ "radiofuse_sw:", {
|
|
radiofusetoggle,
|
|
none } },
|
|
{ "radiofuseon_sw:", {
|
|
radiofuseenable,
|
|
none } },
|
|
{ "radiofuseoff_sw:", {
|
|
radiofusedisable,
|
|
none } },
|
|
{ "radiochannel_sw:", {
|
|
radiochannelincrease,
|
|
radiochanneldecrease } },
|
|
{ "radiochannelprev_sw:", {
|
|
radiochanneldecrease,
|
|
none } },
|
|
{ "radiochannelnext_sw:", {
|
|
radiochannelincrease,
|
|
none } },
|
|
{ "radiostop_sw:", {
|
|
radiostopsend,
|
|
none } },
|
|
{ "radiostopon_sw:", {
|
|
radiostopenable,
|
|
none } },
|
|
{ "radiostopoff_sw:", {
|
|
radiostopdisable,
|
|
none } },
|
|
{ "radiotest_sw:", {
|
|
radiostoptest,
|
|
none } },
|
|
{ "radiocall1_sw:", {
|
|
radiocall1send,
|
|
none } },
|
|
{ "radiocall3_sw:", {
|
|
radiocall3send,
|
|
none } },
|
|
{ "radiovolume_sw:",{
|
|
radiovolumeincrease,
|
|
radiovolumedecrease } },
|
|
{ "radiovolumeprev_sw:",{
|
|
radiovolumedecrease,
|
|
none } },
|
|
{ "radiovolumenext_sw:",{
|
|
radiovolumeincrease,
|
|
none } },
|
|
{ "fmradio_sw:",{
|
|
fmradiotoggle,
|
|
none } },
|
|
{ "fmradiovolume_sw:",{
|
|
fmradiovolumeincrease,
|
|
fmradiovolumedecrease } },
|
|
{ "fmradiotune_sw:",{
|
|
fmradiotuneincrease,
|
|
fmradiotunedecrease } },
|
|
{ "pantfront_sw:", {
|
|
pantographtogglefront,
|
|
none } },
|
|
{ "pantrear_sw:", {
|
|
pantographtogglerear,
|
|
none } },
|
|
{ "pantfrontoff_sw:", {
|
|
pantographlowerfront,
|
|
none } },
|
|
{ "pantrearoff_sw:", {
|
|
pantographlowerrear,
|
|
none } },
|
|
{ "pantalloff_sw:", {
|
|
pantographlowerall,
|
|
none } },
|
|
{ "pantselected_sw:", {
|
|
pantographtoggleselected,
|
|
none } }, // TBD: bind lowerselected in case of toggle switch
|
|
{ "pantselectedoff_sw:", {
|
|
pantographlowerselected,
|
|
none } },
|
|
{ "pantselect_sw:", {
|
|
pantographselectnext,
|
|
pantographselectprevious } },
|
|
{ "pantvalves_sw:", {
|
|
pantographvalvesupdate,
|
|
pantographvalvesoff } },
|
|
{ "pantvalvesupdate_bt:", {
|
|
pantographvalvesupdate,
|
|
none}},
|
|
{ "pantvalvesoff_bt:", {
|
|
pantographvalvesoff,
|
|
none}},
|
|
{ "pantcompressor_sw:", {
|
|
pantographcompressoractivate,
|
|
none } },
|
|
{ "pantcompressorvalve_sw:", {
|
|
pantographcompressorvalvetoggle,
|
|
none } },
|
|
{ "trainheating_sw:", {
|
|
heatingtoggle,
|
|
none } },
|
|
{ "signalling_sw:", {
|
|
mubrakingindicatortoggle,
|
|
none } },
|
|
{ "door_signalling_sw:", {
|
|
doorlocktoggle,
|
|
none } },
|
|
{ "nextcurrent_sw:", {
|
|
mucurrentindicatorothersourceactivate,
|
|
none } },
|
|
{ "distancecounter_sw:", {
|
|
distancecounteractivate,
|
|
none } },
|
|
{ "instrumentlight_sw:", {
|
|
instrumentlighttoggle,
|
|
none } },
|
|
{ "dashboardlight_sw:", {
|
|
dashboardlighttoggle,
|
|
none } },
|
|
{ "dashboardlighton_sw:", {
|
|
dashboardlightenable,
|
|
none } },
|
|
{ "dashboardlightoff_sw:", {
|
|
dashboardlightdisable,
|
|
none } },
|
|
{ "timetablelight_sw:", {
|
|
timetablelighttoggle,
|
|
none } },
|
|
{ "timetablelighton_sw:", {
|
|
timetablelightenable,
|
|
none } },
|
|
{ "timetablelightoff_sw:", {
|
|
timetablelightdisable,
|
|
none } },
|
|
{ "cablight_sw:", {
|
|
interiorlighttoggle,
|
|
none } },
|
|
{ "cablightdim_sw:", {
|
|
interiorlightdimtoggle,
|
|
none } },
|
|
{ "compartmentlights_sw:", {
|
|
compartmentlightstoggle,
|
|
none } },
|
|
{ "compartmentlightson_sw:", {
|
|
compartmentlightsenable,
|
|
none } },
|
|
{ "compartmentlightsoff_sw:", {
|
|
compartmentlightsdisable,
|
|
none } },
|
|
{ "battery_sw:", {
|
|
batterytoggle,
|
|
none } },
|
|
{ "batteryon_sw:", {
|
|
batteryenable,
|
|
none } },
|
|
{ "batteryoff_sw:", {
|
|
batterydisable,
|
|
none } },
|
|
{ "cabactivation_sw:", {
|
|
cabactivationtoggle,
|
|
none } },
|
|
{ "couplingdisconnect_sw:",{
|
|
occupiedcarcouplingdisconnect,
|
|
none } },
|
|
{ "couplingdisconnectback_sw:",{
|
|
occupiedcarcouplingdisconnectback,
|
|
none } },
|
|
{"universal0:", {generictoggle0, none}},
|
|
{"universal1:", {generictoggle1, none}},
|
|
{"universal2:", {generictoggle2, none}},
|
|
{"universal3:", {generictoggle3, none}},
|
|
{"universal4:", {generictoggle4, none}},
|
|
{"universal5:", {generictoggle5, none}},
|
|
{"universal6:", {generictoggle6, none}},
|
|
{"universal7:", {generictoggle7, none}},
|
|
{"universal8:", {generictoggle8, none}},
|
|
{"universal9:", {generictoggle9, none}},
|
|
{"universal10:", {generictoggle10, none}},
|
|
{"universal11:", {generictoggle11, none}},
|
|
{"universal12:", {generictoggle12, none}},
|
|
{"universal13:", {generictoggle13, none}},
|
|
{"universal14:", {generictoggle14, none}},
|
|
{"universal15:", {generictoggle15, none}},
|
|
{"universal16:", {generictoggle16, none}},
|
|
{"universal17:", {generictoggle17, none}},
|
|
{"universal18:", {generictoggle18, none}},
|
|
{"universal19:", {generictoggle19, none}},
|
|
{"universal20:", {generictoggle20, none}},
|
|
{"universal21:", {generictoggle21, none}},
|
|
{"universal22:", {generictoggle22, none}},
|
|
{"universal23:", {generictoggle23, none}},
|
|
{"universal24:", {generictoggle24, none}},
|
|
{"universal25:", {generictoggle25, none}},
|
|
{"universal26:", {generictoggle26, none}},
|
|
{"universal27:", {generictoggle27, none}},
|
|
{"universal28:", {generictoggle28, none}},
|
|
{"universal29:", {generictoggle29, none}},
|
|
{ "speedinc_bt:",{
|
|
speedcontrolincrease,
|
|
none } },
|
|
{ "speeddec_bt:",{
|
|
speedcontroldecrease,
|
|
none } },
|
|
{ "speedctrlpowerinc_bt:",{
|
|
speedcontrolpowerincrease,
|
|
none } },
|
|
{ "speedctrlpowerdec_bt:",{
|
|
speedcontrolpowerdecrease,
|
|
none } },
|
|
{ "speedbutton0:",{
|
|
speedcontrolbutton0,
|
|
none } },
|
|
{ "speedbutton1:",{
|
|
speedcontrolbutton1,
|
|
none } },
|
|
{ "speedbutton2:",{
|
|
speedcontrolbutton2,
|
|
none } },
|
|
{ "speedbutton3:",{
|
|
speedcontrolbutton3,
|
|
none } },
|
|
{ "speedbutton4:",{
|
|
speedcontrolbutton4,
|
|
none } },
|
|
{ "speedbutton5:",{
|
|
speedcontrolbutton5,
|
|
none } },
|
|
{ "speedbutton6:",{
|
|
speedcontrolbutton6,
|
|
none } },
|
|
{ "speedbutton7:",{
|
|
speedcontrolbutton7,
|
|
none } },
|
|
{ "speedbutton8:",{
|
|
speedcontrolbutton8,
|
|
none } },
|
|
{ "speedbutton9:",{
|
|
speedcontrolbutton9,
|
|
none } },
|
|
{ "inverterenable1_bt:",{
|
|
inverterenable1,
|
|
none } },
|
|
{ "inverterenable2_bt:",{
|
|
inverterenable2,
|
|
none } },
|
|
{ "inverterenable3_bt:",{
|
|
inverterenable3,
|
|
none } },
|
|
{ "inverterenable4_bt:",{
|
|
inverterenable4,
|
|
none } },
|
|
{ "inverterenable5_bt:",{
|
|
inverterenable5,
|
|
none } },
|
|
{ "inverterenable6_bt:",{
|
|
inverterenable6,
|
|
none } },
|
|
{ "inverterenable7_bt:",{
|
|
inverterenable7,
|
|
none } },
|
|
{ "inverterenable8_bt:",{
|
|
inverterenable8,
|
|
none } },
|
|
{ "inverterenable9_bt:",{
|
|
inverterenable9,
|
|
none } },
|
|
{ "inverterenable10_bt:",{
|
|
inverterenable10,
|
|
none } },
|
|
{ "inverterenable11_bt:",{
|
|
inverterenable11,
|
|
none } },
|
|
{ "inverterenable12_bt:",{
|
|
inverterenable12,
|
|
none } },
|
|
{ "inverterdisable1_bt:",{
|
|
inverterdisable1,
|
|
none } },
|
|
{ "inverterdisable2_bt:",{
|
|
inverterdisable2,
|
|
none } },
|
|
{ "inverterdisable3_bt:",{
|
|
inverterdisable3,
|
|
none } },
|
|
{ "inverterdisable4_bt:",{
|
|
inverterdisable4,
|
|
none } },
|
|
{ "inverterdisable5_bt:",{
|
|
inverterdisable5,
|
|
none } },
|
|
{ "inverterdisable6_bt:",{
|
|
inverterdisable6,
|
|
none } },
|
|
{ "inverterdisable7_bt:",{
|
|
inverterdisable7,
|
|
none } },
|
|
{ "inverterdisable8_bt:",{
|
|
inverterdisable8,
|
|
none } },
|
|
{ "inverterdisable9_bt:",{
|
|
inverterdisable9,
|
|
none } },
|
|
{ "inverterdisable10_bt:",{
|
|
inverterdisable10,
|
|
none } },
|
|
{ "inverterdisable11_bt:",{
|
|
inverterdisable11,
|
|
none } },
|
|
{ "inverterdisable12_bt:",{
|
|
inverterdisable12,
|
|
none } },
|
|
{ "invertertoggle1_bt:",{
|
|
invertertoggle1,
|
|
none } },
|
|
{ "invertertoggle2_bt:",{
|
|
invertertoggle2,
|
|
none } },
|
|
{ "invertertoggle3_bt:",{
|
|
invertertoggle3,
|
|
none } },
|
|
{ "invertertoggle4_bt:",{
|
|
invertertoggle4,
|
|
none } },
|
|
{ "invertertoggle5_bt:",{
|
|
invertertoggle5,
|
|
none } },
|
|
{ "invertertoggle6_bt:",{
|
|
invertertoggle6,
|
|
none } },
|
|
{ "invertertoggle7_bt:",{
|
|
invertertoggle7,
|
|
none } },
|
|
{ "invertertoggle8_bt:",{
|
|
invertertoggle8,
|
|
none } },
|
|
{ "invertertoggle9_bt:",{
|
|
invertertoggle9,
|
|
none } },
|
|
{ "invertertoggle10_bt:",{
|
|
invertertoggle10,
|
|
none } },
|
|
{ "invertertoggle11_bt:",{
|
|
invertertoggle11,
|
|
none } },
|
|
{ "invertertoggle12_bt:",{
|
|
invertertoggle12,
|
|
none } },
|
|
{ "wipers_sw:",{
|
|
wiperswitchincrease,
|
|
wiperswitchdecrease
|
|
} },
|
|
|
|
};
|
|
}
|
|
|
|
user_command
|
|
drivermouse_input::adjust_command( user_command Command ) const {
|
|
using enum user_command;
|
|
|
|
if( true == Global.shiftState
|
|
&& Command != none ) {
|
|
switch( Command ) {
|
|
case mastercontrollerincrease: { Command = mastercontrollerincreasefast; break; }
|
|
case mastercontrollerdecrease: { Command = mastercontrollerdecreasefast; break; }
|
|
case secondcontrollerincrease: { Command = secondcontrollerincreasefast; break; }
|
|
case secondcontrollerdecrease: { Command = secondcontrollerdecreasefast; break; }
|
|
case independentbrakeincrease: { Command = independentbrakeincreasefast; break; }
|
|
case independentbrakedecrease: { Command = independentbrakedecreasefast; break; }
|
|
default: { break; }
|
|
}
|
|
}
|
|
|
|
return Command;
|
|
}
|
|
|
|
std::optional<int>
|
|
drivermouse_input::universal_index( user_command const Command ) {
|
|
|
|
auto const index { static_cast<int>( Command ) - static_cast<int>( user_command::generictoggle0 ) };
|
|
if( index < 0
|
|
|| index > static_cast<int>( user_command::generictoggle29 ) - static_cast<int>( user_command::generictoggle0 ) ) {
|
|
return std::nullopt;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
void
|
|
drivermouse_input::toggle_universal( int const Index ) const {
|
|
|
|
auto const toggle { static_cast<user_command>( static_cast<int>( user_command::generictoggle0 ) + Index ) };
|
|
m_relay.post( toggle, 0, 0, GLFW_PRESS, 0 );
|
|
m_relay.post( toggle, 0, 0, GLFW_RELEASE, 0 );
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|