mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-19 22:47:29 +02:00
Fix/sonar maintainability rebased (#209)
* refactor(sonar): use override instead of redundant virtual (cpp:S3471) * refactor(sonar): remove empty statements, one declaration per statement (cpp:S1116, cpp:S1659) * refactor(sonar): drop redundant lambda return types (cpp:S3574) * refactor(sonar): prefer using over typedef (cpp:S5416) * refactor(sonar): use =default for trivial special members (cpp:S3490) * refactor(sonar): use nullptr literal (cpp:S4962) * refactor(sonar): remove redundant access specifiers (cpp:S3539) * refactor(sonar): remove redundant casts (cpp:S1905) * refactor(sonar): use std::scoped_lock instead of std::lock_guard (cpp:S5997) * refactor(sonar): construct elements in place with emplace_back (cpp:S6003) * refactor(sonar): make narrowing conversions explicit (cpp:S5276) * refactor(sonar): mark unused parameters (cpp:S1172) Unused names are commented out; parameters used only on some platforms are marked [[maybe_unused]]. * refactor(sonar): declare non-mutating member functions const (cpp:S5817) Virtual functions are left untouched so overrides keep matching. * refactor(sonar): merge collapsible nested if statements (cpp:S1066) Comments that preceded the inner if are kept above the merged statement. * refactor(sonar): scope single-use variables in if init-statements (cpp:S6004) * fix(sonar): give polymorphic base classes virtual destructors (cpp:S1235) * refactor(sonar): use try_emplace for map insertion (cpp:S6030) * refactor(sonar): use auto where the type is spelled out on the right (cpp:S5827) * refactor(sonar): remove redundant parentheses (cpp:S1110) * refactor(sonar): document intentionally empty functions (cpp:S1186) * refactor(sonar): remove dead stores (cpp:S1854) Side effects (e.g. LISTLINE++) are kept. * refactor(sonar): remove unused variables, captures and private fields (cpp:S1481, cpp:S1068) * refactor(sonar): use structured bindings for pair access (cpp:S6005) * refactor(sonar): use range-based loops and ranges algorithms (cpp:S5566) * refactor(sonar): split chained assignments (cpp:S1121) * refactor(sonar): add default cases to switch statements (cpp:S3562) * refactor(sonar): use std::size for array lengths (cpp:S7127) * refactor(sonar): use std::ranges algorithms and std::erase(_if) (cpp:S6197) * refactor(sonar): access static members through the class (cpp:S2209) * refactor(sonar): add braces around nested if-else (cpp:S5261) * refactor(sonar): avoid side effects inside typeid operands (cpp:S5279) * refactor(sonar): drop top-level const from by-value return types (cpp:S5951) * refactor(sonar): declare variables separately from their type definitions (cpp:S3646) * refactor(sonar): declare loop counters in the for statement (cpp:S5955) * refactor(sonar): rely on class template argument deduction (cpp:S6012) * refactor(sonar): inherit base constructors instead of forwarding them (cpp:S5952) * refactor(sonar): rename locals that shadow outer declarations (cpp:S1117) Only local variables and definition parameters are renamed; shadowing struct fields and enumerators in headers are left for a separate change. * refactor(sonar): reduce enum qualification with using enum (cpp:S6177) Applied only where no unqualified name in the block could be captured by the introduced enumerators. * refactor(sonar): mark converting constructors explicit (cpp:S1709) sound_source and the gl::object conversion operators stay implicit; they are relied upon by copy-list-initialisation and GL calls. * refactor(sonar): initialise members in initialiser lists or declarations (cpp:S3230) * refactor(sonar): make read-only local references and pointers const (cpp:S5350) * refactor(sonar): take read-only pointer and reference parameters as const (cpp:S995) TTrain command handlers keep their signature, it is fixed by the handler table. * refactor(sonar): pass expensive-to-copy parameters by const reference (cpp:S1238) Signatures declared in files touched by PR 206 (Driver.h, EU07.cpp) and virtual overrides are left unchanged. * refactor(sonar): use transparent comparators for string-keyed maps (cpp:S6045) std::unordered_map instances and map types exposed in headers used by other modules are left as they are. * fix(sonar): do not use UI text as a printf format string (cpp:S5281) Text lines containing '%' would otherwise be interpreted as format specifiers by ImGui::TextColored. * refactor(sonar): use std::bind_front for callbacks (cpp:S5995) * refactor(sonar): drop const_cast on string literals passed to the Python C API (cpp:S859) * refactor(sonar): take read-only string parameters as std::string_view (cpp:S6009) The Windows messaging helpers keep std::string, they need c_str(). * refactor(sonar): make read-only global tables const (cpp:S5421) Mutable global state (flags, timers, singletons) is left as is. * refactor(sonar): replace single-case switch statements with if (cpp:S1301) * refactor(sonar): format UUIDs and log timestamps with std::format (cpp:S6494, cpp:S5945) * refactor(sonar): use std::array for local fixed-size arrays (cpp:S5945) Arrays that are class members or part of headers are left unchanged. * fix(sonar): test the bearing damage bit, not bit 0 (cpp:S872) 'DamageFlag & dtrain_bearing > 0' parsed as 'DamageFlag & (dtrain_bearing > 0)', i.e. DamageFlag & 1, so bearing friction reacted to the wrong damage flag. * refactor(sonar): assorted small fixes - empty() instead of size() comparisons (cpp:S1155) - member initialisers in declaration order (cpp:S3229) - no redundant c_str() when a std::string is accepted (cpp:S7121) - contains() on associative containers (cpp:S6171) - const reference instead of a copying range-for (cpp:S6032) - starts_with() for prefix checks (cpp:S6178) - no std::move on temporaries (cpp:S5274) - has_value() on std::optional (cpp:S7172) - bool literals for bool members (cpp:S5820) - inline only on the definition (cpp:S3548) - explicit base access specifier (cpp:S5965) - explicit element access instead of dereferencing an array (cpp:S7116) - rely on the C++20 rewritten operator!= (cpp:S6186) * refactor(sonar): more small fixes - std::format instead of iostream manipulators in to_string/to_hex_str (cpp:S6495); output verified identical, negative hex values keep the unsigned form - remove an empty compound statement (cpp:S108) - drop an always-false unsigned < 0 branch (cpp:S1768) - explicit lambda capture (cpp:S3608) - std::make_unique (cpp:S5950) * chore: strip stray carriage returns left in TTrain constructor comments * fix: keep quantize() in its own value type The S5276 change cast the result of the generic quantize<Type_>() to unsigned int, which truncated float/double callers (shadow angle slider, editor rotation snapping, AI speed control steps) and broke negative values. * fix(sonar): use integer loop counters in segment sampling (cpp:S2193) * refactor(sonar): clean up issues reported on PR 209 - remove locals left unused after the dead-store cleanup (cpp:S1481, cpp:S1854) - unnamed unused parameter (cpp:S1172) - single-use declarations moved into if init-statements (cpp:S6004) - auto for casted initialisers (cpp:S5827) - const references and pointers where nothing is modified (cpp:S5350) - rename structured bindings shadowed by inner declarations (cpp:S1117)
This commit is contained in:
@@ -408,7 +408,7 @@ commanddescription_sequence Commands_descriptions = {
|
||||
};
|
||||
|
||||
// Maps of command and coresponding strings
|
||||
std::unordered_map<std::string, user_command> commandMap = {
|
||||
std::unordered_map<std::string, user_command> const commandMap = {
|
||||
{"aidriverdisable", user_command::aidriverdisable},
|
||||
{"jointcontrollerset", user_command::jointcontrollerset},
|
||||
{"mastercontrollerincrease", user_command::mastercontrollerincrease},
|
||||
@@ -796,12 +796,12 @@ std::unordered_map<std::string, user_command> commandMap = {
|
||||
void command_queue::update()
|
||||
{
|
||||
double delta = Timer::GetDeltaTime();
|
||||
for (auto c : m_active_continuous)
|
||||
for (auto [activecommand, activerecipient] : m_active_continuous)
|
||||
{
|
||||
command_data data({c.first, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
|
||||
auto lookup = m_commands.emplace( c.second, commanddata_sequence() );
|
||||
command_data data({activecommand, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
|
||||
auto [queueiterator, queueinserted] = m_commands.try_emplace( activerecipient, commanddata_sequence() );
|
||||
// recipient stack was either located or created, so we can add to it quite safely
|
||||
lookup.first->second.emplace_back( data );
|
||||
queueiterator->second.emplace_back( data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,16 +809,15 @@ void command_queue::update()
|
||||
void
|
||||
command_queue::push( command_data const &Command, uint32_t const Recipient ) {
|
||||
if (is_network_target(Recipient)) {
|
||||
auto lookup = m_intercept_queue.emplace(Recipient, commanddata_sequence());
|
||||
lookup.first->second.emplace_back(Command);
|
||||
auto [queueiterator, queueinserted] = m_intercept_queue.try_emplace(Recipient, commanddata_sequence());
|
||||
queueiterator->second.emplace_back(Command);
|
||||
} else {
|
||||
push_direct(Command, Recipient);
|
||||
}
|
||||
}
|
||||
|
||||
void command_queue::push_direct(const command_data &Command, const uint32_t Recipient) {
|
||||
auto const &desc = simulation::Commands_descriptions[ static_cast<std::size_t>( Command.command ) ];
|
||||
if (desc.mode == command_mode::continuous)
|
||||
if (auto const &desc = simulation::Commands_descriptions[ static_cast<std::size_t>( Command.command ) ]; desc.mode == command_mode::continuous)
|
||||
{
|
||||
if (Command.action == GLFW_PRESS)
|
||||
m_active_continuous.emplace(std::make_pair(Command.command, Recipient));
|
||||
@@ -828,9 +827,9 @@ void command_queue::push_direct(const command_data &Command, const uint32_t Reci
|
||||
return;
|
||||
}
|
||||
|
||||
auto lookup = m_commands.emplace( Recipient, commanddata_sequence() );
|
||||
auto [queueiterator, queueinserted] = m_commands.try_emplace( Recipient, commanddata_sequence() );
|
||||
// recipient stack was either located or created, so we can add to it quite safely
|
||||
lookup.first->second.emplace_back( Command );
|
||||
queueiterator->second.emplace_back( Command );
|
||||
}
|
||||
|
||||
// retrieves oldest posted command for specified recipient, if any. returns: true on retrieval, false if there's nothing to retrieve
|
||||
@@ -854,10 +853,9 @@ command_queue::pop( command_data &Command, uint32_t const Recipient ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool command_queue::is_network_target(uint32_t const Recipient) {
|
||||
const command_target target = (command_target)(Recipient & ~0xffff);
|
||||
bool command_queue::is_network_target(uint32_t const Recipient) const {
|
||||
|
||||
if (target == command_target::entity)
|
||||
if (const auto target = (command_target)(Recipient & ~0xffff); target == command_target::entity)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -870,9 +868,9 @@ command_queue::commands_map command_queue::pop_intercept_queue() {
|
||||
}
|
||||
|
||||
void command_queue::push_commands(const commands_map &commands) {
|
||||
for (auto const &kv : commands)
|
||||
for (command_data const &data : kv.second)
|
||||
push_direct(data, kv.first);
|
||||
for (auto const &[recipient, sequence] : commands)
|
||||
for (command_data const &data : sequence)
|
||||
push_direct(data, recipient);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -455,8 +455,8 @@ class command_queue {
|
||||
|
||||
public:
|
||||
// types
|
||||
typedef std::deque<command_data> commanddata_sequence;
|
||||
typedef std::unordered_map<uint32_t, commanddata_sequence> commands_map;
|
||||
using commanddata_sequence = std::deque<command_data>;
|
||||
using commands_map = std::unordered_map<uint32_t, commanddata_sequence>;
|
||||
// methods
|
||||
// posts specified command for specified recipient into m_intercept_queue
|
||||
void
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
update();
|
||||
// checks if given command must be scheduled on server
|
||||
bool
|
||||
is_network_target(const uint32_t Recipient);
|
||||
is_network_target(const uint32_t Recipient) const;
|
||||
|
||||
// pops commands from intercept queue
|
||||
commands_map pop_intercept_queue();
|
||||
@@ -511,13 +511,13 @@ void add_to_dequemap(std::unordered_map<A, std::deque<B>> &lhs, const std::unord
|
||||
// but realistically it's not like we're going to run more than one simulation at a time
|
||||
namespace simulation {
|
||||
|
||||
typedef std::vector<command_description> commanddescription_sequence;
|
||||
using commanddescription_sequence = std::vector<command_description>;
|
||||
|
||||
extern command_queue Commands;
|
||||
// TODO: add name to command map, and wrap these two into helper object
|
||||
extern commanddescription_sequence Commands_descriptions;
|
||||
|
||||
extern std::unordered_map<std::string, user_command> commandMap;
|
||||
extern std::unordered_map<std::string, user_command> const commandMap;
|
||||
}
|
||||
|
||||
// command_relay: composite class component, passes specified command to appropriate command stack
|
||||
@@ -530,7 +530,6 @@ public:
|
||||
void
|
||||
post(user_command const Command, double const Param1, double const Param2,
|
||||
int const Action, uint16_t Recipient, glm::vec3 Position = glm::vec3(0.0f) , const std::string *Payload = nullptr) const;
|
||||
private:
|
||||
// types
|
||||
// members
|
||||
};
|
||||
|
||||
@@ -22,276 +22,277 @@ driverkeyboard_input::init() {
|
||||
|
||||
void
|
||||
driverkeyboard_input::default_bindings() {
|
||||
using enum user_command;
|
||||
|
||||
m_bindingsetups = {
|
||||
{ user_command::aidriverenable, {GLFW_KEY_Q | keymodifier::shift, ""} },
|
||||
{ user_command::aidriverdisable, {GLFW_KEY_Q, ""} },
|
||||
{ aidriverenable, {GLFW_KEY_Q | keymodifier::shift, ""} },
|
||||
{ aidriverdisable, {GLFW_KEY_Q, ""} },
|
||||
// jointcontrollerset,
|
||||
{ user_command::mastercontrollerincrease, {GLFW_KEY_KP_ADD, ""} },
|
||||
{ user_command::mastercontrollerincreasefast, {GLFW_KEY_KP_ADD | keymodifier::shift, ""} },
|
||||
{ user_command::mastercontrollerdecrease, {GLFW_KEY_KP_SUBTRACT, ""} },
|
||||
{ user_command::mastercontrollerdecreasefast, {GLFW_KEY_KP_SUBTRACT | keymodifier::shift, ""} },
|
||||
{ mastercontrollerincrease, {GLFW_KEY_KP_ADD, ""} },
|
||||
{ mastercontrollerincreasefast, {GLFW_KEY_KP_ADD | keymodifier::shift, ""} },
|
||||
{ mastercontrollerdecrease, {GLFW_KEY_KP_SUBTRACT, ""} },
|
||||
{ mastercontrollerdecreasefast, {GLFW_KEY_KP_SUBTRACT | keymodifier::shift, ""} },
|
||||
// mastercontrollerset,
|
||||
|
||||
{ user_command::dynamicbrakecontrollerincrease, {GLFW_KEY_KP_3 | keymodifier::control, ""} },
|
||||
{ user_command::dynamicbrakecontrollerdecrease, {GLFW_KEY_KP_9 | keymodifier::control, ""} },
|
||||
{ dynamicbrakecontrollerincrease, {GLFW_KEY_KP_3 | keymodifier::control, ""} },
|
||||
{ dynamicbrakecontrollerdecrease, {GLFW_KEY_KP_9 | keymodifier::control, ""} },
|
||||
// mastercontrollerset,
|
||||
{ user_command::dynamicbrakecontrollerincreasefast, {GLFW_KEY_KP_3 | keymodifier::control | keymodifier::shift, ""} },
|
||||
{ user_command::dynamicbrakecontrollerdecreasefast, {GLFW_KEY_KP_9 | keymodifier::control | keymodifier::shift, ""} },
|
||||
{ dynamicbrakecontrollerincreasefast, {GLFW_KEY_KP_3 | keymodifier::control | keymodifier::shift, ""} },
|
||||
{ dynamicbrakecontrollerdecreasefast, {GLFW_KEY_KP_9 | keymodifier::control | keymodifier::shift, ""} },
|
||||
|
||||
{ user_command::secondcontrollerincrease, {GLFW_KEY_KP_DIVIDE, ""} },
|
||||
{ user_command::secondcontrollerincreasefast, {GLFW_KEY_KP_DIVIDE | keymodifier::shift, ""} },
|
||||
{ user_command::secondcontrollerdecrease, {GLFW_KEY_KP_MULTIPLY, ""} },
|
||||
{ user_command::secondcontrollerdecreasefast, {GLFW_KEY_KP_MULTIPLY | keymodifier::shift, ""} },
|
||||
{ secondcontrollerincrease, {GLFW_KEY_KP_DIVIDE, ""} },
|
||||
{ secondcontrollerincreasefast, {GLFW_KEY_KP_DIVIDE | keymodifier::shift, ""} },
|
||||
{ secondcontrollerdecrease, {GLFW_KEY_KP_MULTIPLY, ""} },
|
||||
{ secondcontrollerdecreasefast, {GLFW_KEY_KP_MULTIPLY | keymodifier::shift, ""} },
|
||||
// secondcontrollerset,
|
||||
{ user_command::mucurrentindicatorothersourceactivate, {GLFW_KEY_Z | keymodifier::shift, ""} },
|
||||
{ user_command::independentbrakeincrease, {GLFW_KEY_KP_1, ""} },
|
||||
{ user_command::independentbrakeincreasefast, {GLFW_KEY_KP_1 | keymodifier::shift, ""} },
|
||||
{ user_command::independentbrakedecrease, {GLFW_KEY_KP_7, ""} },
|
||||
{ user_command::independentbrakedecreasefast, {GLFW_KEY_KP_7 | keymodifier::shift, ""} },
|
||||
{ mucurrentindicatorothersourceactivate, {GLFW_KEY_Z | keymodifier::shift, ""} },
|
||||
{ independentbrakeincrease, {GLFW_KEY_KP_1, ""} },
|
||||
{ independentbrakeincreasefast, {GLFW_KEY_KP_1 | keymodifier::shift, ""} },
|
||||
{ independentbrakedecrease, {GLFW_KEY_KP_7, ""} },
|
||||
{ independentbrakedecreasefast, {GLFW_KEY_KP_7 | keymodifier::shift, ""} },
|
||||
// independentbrakeset,
|
||||
{ user_command::independentbrakebailoff, {GLFW_KEY_KP_4, ""} },
|
||||
{ independentbrakebailoff, {GLFW_KEY_KP_4, ""} },
|
||||
// universalbrakebutton1,
|
||||
// universalbrakebutton2,
|
||||
// universalbrakebutton3,
|
||||
{ user_command::trainbrakeincrease, {GLFW_KEY_KP_3, ""} },
|
||||
{ user_command::trainbrakedecrease, {GLFW_KEY_KP_9, ""} },
|
||||
{ trainbrakeincrease, {GLFW_KEY_KP_3, ""} },
|
||||
{ trainbrakedecrease, {GLFW_KEY_KP_9, ""} },
|
||||
// trainbrakeset,
|
||||
{ user_command::trainbrakecharging, {GLFW_KEY_KP_DECIMAL, ""} },
|
||||
{ user_command::trainbrakerelease, {GLFW_KEY_KP_6, ""} },
|
||||
{ user_command::trainbrakefirstservice, {GLFW_KEY_KP_8, ""} },
|
||||
{ user_command::trainbrakeservice, {GLFW_KEY_KP_5, ""} },
|
||||
{ user_command::trainbrakefullservice, {GLFW_KEY_KP_2, ""} },
|
||||
{ user_command::trainbrakehandleoff, {GLFW_KEY_KP_5 | keymodifier::control, ""} },
|
||||
{ user_command::trainbrakeemergency, {GLFW_KEY_KP_0, ""} },
|
||||
{ user_command::trainbrakebasepressureincrease, {GLFW_KEY_KP_3 | keymodifier::control, ""} },
|
||||
{ user_command::trainbrakebasepressuredecrease, {GLFW_KEY_KP_9 | keymodifier::control, ""} },
|
||||
{ user_command::trainbrakebasepressurereset, {GLFW_KEY_KP_6 | keymodifier::control, ""} },
|
||||
{ user_command::trainbrakeoperationtoggle, {GLFW_KEY_KP_4 | keymodifier::control, ""} },
|
||||
{ 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, ""} },
|
||||
{ trainbrakecharging, {GLFW_KEY_KP_DECIMAL, ""} },
|
||||
{ trainbrakerelease, {GLFW_KEY_KP_6, ""} },
|
||||
{ trainbrakefirstservice, {GLFW_KEY_KP_8, ""} },
|
||||
{ trainbrakeservice, {GLFW_KEY_KP_5, ""} },
|
||||
{ trainbrakefullservice, {GLFW_KEY_KP_2, ""} },
|
||||
{ trainbrakehandleoff, {GLFW_KEY_KP_5 | keymodifier::control, ""} },
|
||||
{ trainbrakeemergency, {GLFW_KEY_KP_0, ""} },
|
||||
{ trainbrakebasepressureincrease, {GLFW_KEY_KP_3 | keymodifier::control, ""} },
|
||||
{ trainbrakebasepressuredecrease, {GLFW_KEY_KP_9 | keymodifier::control, ""} },
|
||||
{ trainbrakebasepressurereset, {GLFW_KEY_KP_6 | keymodifier::control, ""} },
|
||||
{ trainbrakeoperationtoggle, {GLFW_KEY_KP_4 | keymodifier::control, ""} },
|
||||
{ manualbrakeincrease, {GLFW_KEY_KP_1 | keymodifier::control, ""} },
|
||||
{ manualbrakedecrease, {GLFW_KEY_KP_7 | keymodifier::control, ""} },
|
||||
{ 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, ""} },
|
||||
{ wheelspinbrakeactivate, {GLFW_KEY_KP_ENTER, ""} },
|
||||
{ sandboxactivate, {GLFW_KEY_S | keymodifier::shift, ""} },
|
||||
// autosandboxtoggle,
|
||||
// autosandboxactivate,
|
||||
// autosandboxdeactivate,
|
||||
{ user_command::reverserincrease, {GLFW_KEY_D, ""} },
|
||||
{ user_command::reverserdecrease, {GLFW_KEY_R, ""} },
|
||||
{ reverserincrease, {GLFW_KEY_D, ""} },
|
||||
{ reverserdecrease, {GLFW_KEY_R, ""} },
|
||||
// reverserforwardhigh,
|
||||
// reverserforward,
|
||||
// reverserneutral,
|
||||
// reverserbackward,
|
||||
{ user_command::waterpumpbreakertoggle, {GLFW_KEY_W | keymodifier::control, ""} },
|
||||
{ waterpumpbreakertoggle, {GLFW_KEY_W | keymodifier::control, ""} },
|
||||
// waterpumpbreakerclose,
|
||||
// waterpumpbreakeropen,
|
||||
{ user_command::waterpumptoggle, {GLFW_KEY_W, ""} },
|
||||
{ waterpumptoggle, {GLFW_KEY_W, ""} },
|
||||
// waterpumpenable,
|
||||
// waterpumpdisable,
|
||||
{ user_command::waterheaterbreakertoggle, {GLFW_KEY_W | keymodifier::control | keymodifier::shift, ""} },
|
||||
{ waterheaterbreakertoggle, {GLFW_KEY_W | keymodifier::control | keymodifier::shift, ""} },
|
||||
// waterheaterbreakerclose,
|
||||
// waterheaterbreakeropen,
|
||||
{ user_command::waterheatertoggle, {GLFW_KEY_W | keymodifier::shift, ""} },
|
||||
{ waterheatertoggle, {GLFW_KEY_W | keymodifier::shift, ""} },
|
||||
// waterheaterenable,
|
||||
// waterheaterdisable,
|
||||
{ user_command::watercircuitslinktoggle, {GLFW_KEY_H | keymodifier::shift, ""} },
|
||||
{ watercircuitslinktoggle, {GLFW_KEY_H | keymodifier::shift, ""} },
|
||||
// watercircuitslinkenable,
|
||||
// watercircuitslinkdisable,
|
||||
{ user_command::fuelpumptoggle, {GLFW_KEY_F, ""} },
|
||||
{ fuelpumptoggle, {GLFW_KEY_F, ""} },
|
||||
// fuelpumpenable,
|
||||
// fuelpumpdisable,
|
||||
{ user_command::oilpumptoggle, {GLFW_KEY_F | keymodifier::shift, ""} },
|
||||
{ oilpumptoggle, {GLFW_KEY_F | keymodifier::shift, ""} },
|
||||
// oilpumpenable,
|
||||
// oilpumpdisable,
|
||||
{ user_command::linebreakertoggle, {GLFW_KEY_M, ""} },
|
||||
{ linebreakertoggle, {GLFW_KEY_M, ""} },
|
||||
// linebreakeropen,
|
||||
// linebreakerclose,
|
||||
{ user_command::convertertoggle, {GLFW_KEY_X, ""} },
|
||||
{ convertertoggle, {GLFW_KEY_X, ""} },
|
||||
// converterenable,
|
||||
// converterdisable,
|
||||
{ user_command::convertertogglelocal, {GLFW_KEY_X | keymodifier::shift, ""} },
|
||||
{ user_command::converteroverloadrelayreset, {GLFW_KEY_N | keymodifier::control, ""} },
|
||||
{ user_command::compressortoggle, {GLFW_KEY_C, ""} },
|
||||
{ convertertogglelocal, {GLFW_KEY_X | keymodifier::shift, ""} },
|
||||
{ converteroverloadrelayreset, {GLFW_KEY_N | keymodifier::control, ""} },
|
||||
{ compressortoggle, {GLFW_KEY_C, ""} },
|
||||
// compressorenable,
|
||||
// compressordisable,
|
||||
{ user_command::compressortogglelocal, {GLFW_KEY_C | keymodifier::shift, ""} },
|
||||
{ compressortogglelocal, {GLFW_KEY_C | keymodifier::shift, ""} },
|
||||
// compressorpresetactivatenext,
|
||||
// compressorpresetactivateprevious,
|
||||
// compressorpresetactivatedefault,
|
||||
{ user_command::motoroverloadrelaythresholdtoggle, {GLFW_KEY_F | keymodifier::control, ""} },
|
||||
{ motoroverloadrelaythresholdtoggle, {GLFW_KEY_F | keymodifier::control, ""} },
|
||||
// motoroverloadrelaythresholdsetlow,
|
||||
// motoroverloadrelaythresholdsethigh,
|
||||
{ user_command::motoroverloadrelayreset, {GLFW_KEY_N, ""} },
|
||||
{ motoroverloadrelayreset, {GLFW_KEY_N, ""} },
|
||||
// universalrelayreset1,
|
||||
// universalrelayreset2,
|
||||
// universalrelayreset3,
|
||||
{ user_command::notchingrelaytoggle, {GLFW_KEY_G, ""} },
|
||||
{ user_command::epbrakecontroltoggle, {GLFW_KEY_Z | keymodifier::control, ""} },
|
||||
{ notchingrelaytoggle, {GLFW_KEY_G, ""} },
|
||||
{ epbrakecontroltoggle, {GLFW_KEY_Z | keymodifier::control, ""} },
|
||||
// epbrakecontrolenable
|
||||
// epbrakecontroldisable
|
||||
{ user_command::trainbrakeoperationmodeincrease, {GLFW_KEY_KP_2 | keymodifier::control, ""} },
|
||||
{ user_command::trainbrakeoperationmodedecrease, {GLFW_KEY_KP_8 | keymodifier::control, ""} },
|
||||
{ user_command::brakeactingspeedincrease, {GLFW_KEY_B | keymodifier::shift, ""} },
|
||||
{ user_command::brakeactingspeeddecrease, {GLFW_KEY_B, ""} },
|
||||
{ trainbrakeoperationmodeincrease, {GLFW_KEY_KP_2 | keymodifier::control, ""} },
|
||||
{ trainbrakeoperationmodedecrease, {GLFW_KEY_KP_8 | keymodifier::control, ""} },
|
||||
{ brakeactingspeedincrease, {GLFW_KEY_B | keymodifier::shift, ""} },
|
||||
{ brakeactingspeeddecrease, {GLFW_KEY_B, ""} },
|
||||
// brakeactingspeedsetcargo,
|
||||
// brakeactingspeedsetpassenger,
|
||||
// brakeactingspeedsetrapid,
|
||||
{ user_command::brakeloadcompensationincrease, {GLFW_KEY_H | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ user_command::brakeloadcompensationdecrease, {GLFW_KEY_H | keymodifier::control, ""} },
|
||||
{ user_command::mubrakingindicatortoggle, {GLFW_KEY_L | keymodifier::shift, ""} },
|
||||
{ user_command::alerteracknowledge, {GLFW_KEY_SPACE, ""} },
|
||||
{ user_command::hornlowactivate, {GLFW_KEY_A, ""} },
|
||||
{ user_command::hornhighactivate, {GLFW_KEY_S, ""} },
|
||||
{ user_command::whistleactivate, {GLFW_KEY_Z, ""} },
|
||||
{ user_command::radiotoggle, {GLFW_KEY_R | keymodifier::control, ""} },
|
||||
{ brakeloadcompensationincrease, {GLFW_KEY_H | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ brakeloadcompensationdecrease, {GLFW_KEY_H | keymodifier::control, ""} },
|
||||
{ mubrakingindicatortoggle, {GLFW_KEY_L | keymodifier::shift, ""} },
|
||||
{ alerteracknowledge, {GLFW_KEY_SPACE, ""} },
|
||||
{ hornlowactivate, {GLFW_KEY_A, ""} },
|
||||
{ hornhighactivate, {GLFW_KEY_S, ""} },
|
||||
{ whistleactivate, {GLFW_KEY_Z, ""} },
|
||||
{ radiotoggle, {GLFW_KEY_R | keymodifier::control, ""} },
|
||||
// radioenable
|
||||
// radiodisable
|
||||
{ user_command::radiochannelincrease, {GLFW_KEY_EQUAL, ""} },
|
||||
{ user_command::radiochanneldecrease, {GLFW_KEY_MINUS, ""} },
|
||||
{ radiochannelincrease, {GLFW_KEY_EQUAL, ""} },
|
||||
{ radiochanneldecrease, {GLFW_KEY_MINUS, ""} },
|
||||
// radiochannelset
|
||||
{ user_command::radiostopsend, {GLFW_KEY_PAUSE | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ 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, ""} },
|
||||
{ radiostoptest, {GLFW_KEY_R | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ radiocall3send, {GLFW_KEY_BACKSPACE, ""} },
|
||||
// radiovolumeincrease,
|
||||
// radiovolumedecrease,
|
||||
// radiovolumeset,
|
||||
{ user_command::cabchangeforward, {GLFW_KEY_HOME, ""} },
|
||||
{ user_command::cabchangebackward, {GLFW_KEY_END, ""} },
|
||||
{ cabchangeforward, {GLFW_KEY_HOME, ""} },
|
||||
{ cabchangebackward, {GLFW_KEY_END, ""} },
|
||||
// viewturn,
|
||||
// movehorizontal,
|
||||
// movehorizontalfast,
|
||||
// movevertical,
|
||||
// moveverticalfast,
|
||||
{ user_command::moveleft, {GLFW_KEY_LEFT, "Move left"} },
|
||||
{ user_command::moveright, {GLFW_KEY_RIGHT, "Move right"} },
|
||||
{ user_command::moveforward, {GLFW_KEY_UP, "Move forwards"} },
|
||||
{ user_command::moveback, {GLFW_KEY_DOWN, "Move backwards"} },
|
||||
{ user_command::moveup, {GLFW_KEY_PAGE_UP, "Move up"} },
|
||||
{ user_command::movedown, {GLFW_KEY_PAGE_DOWN, "Move down"} },
|
||||
{ user_command::nearestcarcouplingincrease, {GLFW_KEY_INSERT, ""} },
|
||||
{ user_command::nearestcarcouplingdisconnect, {GLFW_KEY_DELETE, ""} },
|
||||
{ user_command::nearestcarcoupleradapterattach, {GLFW_KEY_INSERT | keymodifier::control, ""} },
|
||||
{ user_command::nearestcarcoupleradapterremove, {GLFW_KEY_DELETE | keymodifier::control, ""} },
|
||||
{ user_command::occupiedcarcouplingdisconnect, {GLFW_KEY_DELETE | keymodifier::shift, ""} },
|
||||
{ user_command::doortoggleleft, {GLFW_KEY_COMMA, ""} },
|
||||
{ user_command::doortoggleright, {GLFW_KEY_PERIOD, ""} },
|
||||
{ user_command::doorpermitleft, {GLFW_KEY_COMMA | keymodifier::shift, ""} },
|
||||
{ user_command::doorpermitright, {GLFW_KEY_PERIOD | keymodifier::shift, ""} },
|
||||
{ user_command::doorpermitpresetactivatenext, {GLFW_KEY_PERIOD | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ user_command::doorpermitpresetactivateprevious, {GLFW_KEY_COMMA | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ moveleft, {GLFW_KEY_LEFT, "Move left"} },
|
||||
{ moveright, {GLFW_KEY_RIGHT, "Move right"} },
|
||||
{ moveforward, {GLFW_KEY_UP, "Move forwards"} },
|
||||
{ moveback, {GLFW_KEY_DOWN, "Move backwards"} },
|
||||
{ moveup, {GLFW_KEY_PAGE_UP, "Move up"} },
|
||||
{ movedown, {GLFW_KEY_PAGE_DOWN, "Move down"} },
|
||||
{ nearestcarcouplingincrease, {GLFW_KEY_INSERT, ""} },
|
||||
{ nearestcarcouplingdisconnect, {GLFW_KEY_DELETE, ""} },
|
||||
{ nearestcarcoupleradapterattach, {GLFW_KEY_INSERT | keymodifier::control, ""} },
|
||||
{ nearestcarcoupleradapterremove, {GLFW_KEY_DELETE | keymodifier::control, ""} },
|
||||
{ occupiedcarcouplingdisconnect, {GLFW_KEY_DELETE | keymodifier::shift, ""} },
|
||||
{ doortoggleleft, {GLFW_KEY_COMMA, ""} },
|
||||
{ doortoggleright, {GLFW_KEY_PERIOD, ""} },
|
||||
{ doorpermitleft, {GLFW_KEY_COMMA | keymodifier::shift, ""} },
|
||||
{ doorpermitright, {GLFW_KEY_PERIOD | keymodifier::shift, ""} },
|
||||
{ doorpermitpresetactivatenext, {GLFW_KEY_PERIOD | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ doorpermitpresetactivateprevious, {GLFW_KEY_COMMA | keymodifier::shift | keymodifier::control, ""} },
|
||||
// dooropenleft,
|
||||
// dooropenright,
|
||||
{ user_command::dooropenall, {GLFW_KEY_SLASH | keymodifier::shift, ""} },
|
||||
{ dooropenall, {GLFW_KEY_SLASH | keymodifier::shift, ""} },
|
||||
// doorcloseleft,
|
||||
// doorcloseright,
|
||||
{ user_command::doorcloseall, {GLFW_KEY_SLASH | keymodifier::control, ""} },
|
||||
{ doorcloseall, {GLFW_KEY_SLASH | keymodifier::control, ""} },
|
||||
// doorsteptoggle,
|
||||
{ user_command::doormodetoggle, {GLFW_KEY_SLASH | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ doormodetoggle, {GLFW_KEY_SLASH | keymodifier::shift | keymodifier::control, ""} },
|
||||
// mirrorstoggle,
|
||||
{ user_command::departureannounce, {GLFW_KEY_SLASH, ""} },
|
||||
{ user_command::doorlocktoggle, {GLFW_KEY_S | keymodifier::control, ""} },
|
||||
{ user_command::pantographcompressorvalvetoggle, {GLFW_KEY_V | keymodifier::control, ""} },
|
||||
{ departureannounce, {GLFW_KEY_SLASH, ""} },
|
||||
{ doorlocktoggle, {GLFW_KEY_S | keymodifier::control, ""} },
|
||||
{ pantographcompressorvalvetoggle, {GLFW_KEY_V | keymodifier::control, ""} },
|
||||
// pantographcompressorvalveenable,
|
||||
// pantographcompressorvalvedisable,
|
||||
{ user_command::pantographcompressoractivate, {GLFW_KEY_V | keymodifier::shift, ""} },
|
||||
{ user_command::pantographtogglefront, {GLFW_KEY_P, ""} },
|
||||
{ user_command::pantographtogglerear, {GLFW_KEY_O, ""} },
|
||||
{ pantographcompressoractivate, {GLFW_KEY_V | keymodifier::shift, ""} },
|
||||
{ pantographtogglefront, {GLFW_KEY_P, ""} },
|
||||
{ pantographtogglerear, {GLFW_KEY_O, ""} },
|
||||
// pantographraisefront,
|
||||
// pantographraiserear,
|
||||
// pantographlowerfront,
|
||||
// pantographlowerrear,
|
||||
{ user_command::pantographlowerall, {GLFW_KEY_P | keymodifier::control, ""} },
|
||||
{ user_command::pantographselectnext, {GLFW_KEY_P | keymodifier::shift, ""} },
|
||||
{ user_command::pantographselectprevious, {GLFW_KEY_O | keymodifier::shift, ""} },
|
||||
{ user_command::pantographtoggleselected, {GLFW_KEY_O | keymodifier::shift | keymodifier::control, ""} },
|
||||
{ pantographlowerall, {GLFW_KEY_P | keymodifier::control, ""} },
|
||||
{ pantographselectnext, {GLFW_KEY_P | keymodifier::shift, ""} },
|
||||
{ pantographselectprevious, {GLFW_KEY_O | keymodifier::shift, ""} },
|
||||
{ pantographtoggleselected, {GLFW_KEY_O | keymodifier::shift | keymodifier::control, ""} },
|
||||
// pantographraiseselected,
|
||||
// pantographlowerselected,
|
||||
// pantographvalvesupdate,
|
||||
// pantographvalvesoff,
|
||||
{ user_command::heatingtoggle, {GLFW_KEY_H, ""} },
|
||||
{ heatingtoggle, {GLFW_KEY_H, ""} },
|
||||
// heatingenable,
|
||||
// heatingdisable,
|
||||
{ user_command::lightspresetactivatenext, {GLFW_KEY_T | keymodifier::shift, ""} },
|
||||
{ user_command::lightspresetactivateprevious, {GLFW_KEY_T, ""} },
|
||||
{ user_command::headlighttoggleleft, {GLFW_KEY_Y, ""} },
|
||||
{ lightspresetactivatenext, {GLFW_KEY_T | keymodifier::shift, ""} },
|
||||
{ lightspresetactivateprevious, {GLFW_KEY_T, ""} },
|
||||
{ headlighttoggleleft, {GLFW_KEY_Y, ""} },
|
||||
// headlightenableleft,
|
||||
// headlightdisableleft,
|
||||
{ user_command::headlighttoggleright, {GLFW_KEY_I, ""} },
|
||||
{ headlighttoggleright, {GLFW_KEY_I, ""} },
|
||||
// headlightenableright,
|
||||
// headlightdisableright,
|
||||
{ user_command::headlighttoggleupper, {GLFW_KEY_U, ""} },
|
||||
{ headlighttoggleupper, {GLFW_KEY_U, ""} },
|
||||
// headlightenableupper,
|
||||
// headlightdisableupper,
|
||||
{ user_command::redmarkertoggleleft, {GLFW_KEY_Y | keymodifier::shift, ""} },
|
||||
{ redmarkertoggleleft, {GLFW_KEY_Y | keymodifier::shift, ""} },
|
||||
// redmarkerenableleft,
|
||||
// redmarkerdisableleft,
|
||||
{ user_command::redmarkertoggleright, {GLFW_KEY_I | keymodifier::shift, ""} },
|
||||
{ redmarkertoggleright, {GLFW_KEY_I | keymodifier::shift, ""} },
|
||||
// redmarkerenableright,
|
||||
// redmarkerdisableright,
|
||||
{ user_command::headlighttogglerearleft, {GLFW_KEY_Y | keymodifier::control, ""} },
|
||||
{ headlighttogglerearleft, {GLFW_KEY_Y | keymodifier::control, ""} },
|
||||
// headlightenablerearleft
|
||||
// headlightdisablerearleft
|
||||
{ user_command::headlighttogglerearright, {GLFW_KEY_I | keymodifier::control, ""} },
|
||||
{ headlighttogglerearright, {GLFW_KEY_I | keymodifier::control, ""} },
|
||||
// headlightenablerearright
|
||||
// headlightdisablerearright
|
||||
{ user_command::headlighttogglerearupper, {GLFW_KEY_U | keymodifier::control, ""} },
|
||||
{ headlighttogglerearupper, {GLFW_KEY_U | keymodifier::control, ""} },
|
||||
// headlightenablerearupper
|
||||
// headlightdisablerearupper
|
||||
{ user_command::redmarkertogglerearleft, {GLFW_KEY_Y | keymodifier::control | keymodifier::shift, ""} },
|
||||
{ redmarkertogglerearleft, {GLFW_KEY_Y | keymodifier::control | keymodifier::shift, ""} },
|
||||
// redmarkerenablerearleft
|
||||
// redmarkerdisablerearleft
|
||||
{ user_command::redmarkertogglerearright, {GLFW_KEY_I | keymodifier::control | keymodifier::shift, ""} },
|
||||
{ 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, ""} },
|
||||
{ redmarkerstoggle, {GLFW_KEY_E | keymodifier::shift, ""} },
|
||||
{ endsignalstoggle, {GLFW_KEY_E, ""} },
|
||||
{ headlightsdimtoggle, {GLFW_KEY_L | keymodifier::control, ""} },
|
||||
// headlightsdimenable,
|
||||
// headlightsdimdisable,
|
||||
{ user_command::motorconnectorsopen, {GLFW_KEY_L, ""} },
|
||||
{ motorconnectorsopen, {GLFW_KEY_L, ""} },
|
||||
// motorconnectorsclose,
|
||||
{ user_command::motordisconnect, {GLFW_KEY_E | keymodifier::control, ""} },
|
||||
{ user_command::interiorlighttoggle, {GLFW_KEY_APOSTROPHE, ""} },
|
||||
{ motordisconnect, {GLFW_KEY_E | keymodifier::control, ""} },
|
||||
{ interiorlighttoggle, {GLFW_KEY_APOSTROPHE, ""} },
|
||||
// interiorlightenable,
|
||||
// interiorlightdisable,
|
||||
{ user_command::interiorlightdimtoggle, {GLFW_KEY_APOSTROPHE | keymodifier::control, ""} },
|
||||
{ interiorlightdimtoggle, {GLFW_KEY_APOSTROPHE | keymodifier::control, ""} },
|
||||
// interiorlightdimenable,
|
||||
// interiorlightdimdisable,
|
||||
// compartmentlightstoggle,
|
||||
// compartmentlightsenable,
|
||||
// compartmentlightsdisable,
|
||||
{ user_command::instrumentlighttoggle, {GLFW_KEY_SEMICOLON, ""} },
|
||||
{ instrumentlighttoggle, {GLFW_KEY_SEMICOLON, ""} },
|
||||
// instrumentlightenable,
|
||||
// instrumentlightdisable,
|
||||
{ user_command::dashboardlighttoggle, {GLFW_KEY_SEMICOLON | keymodifier::shift, ""} },
|
||||
{ dashboardlighttoggle, {GLFW_KEY_SEMICOLON | keymodifier::shift, ""} },
|
||||
// dashboardlightenable
|
||||
// dashboardlightdisable
|
||||
{ user_command::timetablelighttoggle, {GLFW_KEY_APOSTROPHE | keymodifier::shift, ""} },
|
||||
{ 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, ""} },
|
||||
{ user_command::generictoggle3, {GLFW_KEY_3, ""} },
|
||||
{ user_command::generictoggle4, {GLFW_KEY_4, ""} },
|
||||
{ user_command::generictoggle5, {GLFW_KEY_5, ""} },
|
||||
{ user_command::generictoggle6, {GLFW_KEY_6, ""} },
|
||||
{ user_command::generictoggle7, {GLFW_KEY_7, ""} },
|
||||
{ user_command::generictoggle8, {GLFW_KEY_8, ""} },
|
||||
{ user_command::generictoggle9, {GLFW_KEY_9, ""} },
|
||||
{ user_command::batterytoggle, {GLFW_KEY_J, ""} },
|
||||
{ generictoggle0, {GLFW_KEY_0, ""} },
|
||||
{ generictoggle1, {GLFW_KEY_1, ""} },
|
||||
{ generictoggle2, {GLFW_KEY_2, ""} },
|
||||
{ generictoggle3, {GLFW_KEY_3, ""} },
|
||||
{ generictoggle4, {GLFW_KEY_4, ""} },
|
||||
{ generictoggle5, {GLFW_KEY_5, ""} },
|
||||
{ generictoggle6, {GLFW_KEY_6, ""} },
|
||||
{ generictoggle7, {GLFW_KEY_7, ""} },
|
||||
{ generictoggle8, {GLFW_KEY_8, ""} },
|
||||
{ generictoggle9, {GLFW_KEY_9, ""} },
|
||||
{ batterytoggle, {GLFW_KEY_J, ""} },
|
||||
// batteryenable,
|
||||
// batterydisable,
|
||||
// cabactivationtoggle,
|
||||
// cabactivationenable,
|
||||
// cabactivationdisable,
|
||||
{ user_command::motorblowerstogglefront, {GLFW_KEY_N | keymodifier::shift, ""} },
|
||||
{ user_command::motorblowerstogglerear, {GLFW_KEY_M | keymodifier::shift, ""} },
|
||||
{ user_command::motorblowersdisableall, {GLFW_KEY_M | keymodifier::control, ""} },
|
||||
{ motorblowerstogglefront, {GLFW_KEY_N | keymodifier::shift, ""} },
|
||||
{ motorblowerstogglerear, {GLFW_KEY_M | keymodifier::shift, ""} },
|
||||
{ motorblowersdisableall, {GLFW_KEY_M | keymodifier::control, ""} },
|
||||
// coolingfanstoggle,
|
||||
// tempomattoggle,
|
||||
// springbraketoggle,
|
||||
@@ -317,14 +318,14 @@ driverkeyboard_input::default_bindings() {
|
||||
// speedcontrolbutton8,
|
||||
// speedcontrolbutton9,
|
||||
// admin_timejump,
|
||||
{ user_command::timejumplarge, {GLFW_KEY_F1 | keymodifier::control, "Big time jump (Debug Mode only)"} },
|
||||
{ user_command::timejumpsmall, {GLFW_KEY_F1 | keymodifier::shift, "Small time jump (Debug Mode only)"} },
|
||||
{ timejumplarge, {GLFW_KEY_F1 | keymodifier::control, "Big time jump (Debug Mode only)"} },
|
||||
{ timejumpsmall, {GLFW_KEY_F1 | keymodifier::shift, "Small time jump (Debug Mode only)"} },
|
||||
// admin_vehiclemove,
|
||||
{ user_command::vehiclemoveforwards, {GLFW_KEY_LEFT_BRACKET | keymodifier::control, "Move the train forwards (Debug Mode only)"} },
|
||||
{ user_command::vehiclemovebackwards, {GLFW_KEY_RIGHT_BRACKET | keymodifier::control, "Move the train backwards (Debug Mode only)"} },
|
||||
{ user_command::vehicleboost, {GLFW_KEY_TAB | keymodifier::control, "Boost the train (Debug Mode only)"} },
|
||||
{ user_command::debugtoggle, {GLFW_KEY_F12 | keymodifier::control | keymodifier::shift, "Toggle Debug Mode"} },
|
||||
{ user_command::pausetoggle, {GLFW_KEY_ESCAPE, "Pause the game"} }
|
||||
{ vehiclemoveforwards, {GLFW_KEY_LEFT_BRACKET | keymodifier::control, "Move the train forwards (Debug Mode only)"} },
|
||||
{ vehiclemovebackwards, {GLFW_KEY_RIGHT_BRACKET | keymodifier::control, "Move the train backwards (Debug Mode only)"} },
|
||||
{ vehicleboost, {GLFW_KEY_TAB | keymodifier::control, "Boost the train (Debug Mode only)"} },
|
||||
{ debugtoggle, {GLFW_KEY_F12 | keymodifier::control | keymodifier::shift, "Toggle Debug Mode"} },
|
||||
{ pausetoggle, {GLFW_KEY_ESCAPE, "Pause the game"} }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
protected:
|
||||
// methods
|
||||
void
|
||||
default_bindings();
|
||||
default_bindings() override;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -84,14 +84,14 @@ private:
|
||||
user_command down;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<std::string, button_bindings> buttonbindings_map;
|
||||
using buttonbindings_map = std::unordered_map<std::string, button_bindings>;
|
||||
|
||||
// methods
|
||||
void
|
||||
default_bindings();
|
||||
// potentially replaces supplied command with a more relevant one
|
||||
user_command
|
||||
adjust_command( user_command Command );
|
||||
adjust_command( user_command Command ) const;
|
||||
|
||||
// members
|
||||
command_relay m_relay;
|
||||
|
||||
@@ -31,25 +31,26 @@ editorkeyboard_input::apply_scheme() {
|
||||
|
||||
void
|
||||
editorkeyboard_input::default_bindings() {
|
||||
using enum user_command;
|
||||
|
||||
if (EditorSettings.movement() == editorSettings::movement_scheme::legacy) {
|
||||
m_bindingsetups = {
|
||||
{ user_command::moveleft, {GLFW_KEY_LEFT, "Move left"} },
|
||||
{ user_command::moveright, {GLFW_KEY_RIGHT, "Move right"} },
|
||||
{ user_command::moveforward, {GLFW_KEY_UP, "Move forwards"} },
|
||||
{ user_command::moveback, {GLFW_KEY_DOWN, "Move backwards"} },
|
||||
{ user_command::moveup, {GLFW_KEY_PAGE_UP, "Move up"} },
|
||||
{ user_command::movedown, {GLFW_KEY_PAGE_DOWN, "Move down"} },
|
||||
{ moveleft, {GLFW_KEY_LEFT, "Move left"} },
|
||||
{ moveright, {GLFW_KEY_RIGHT, "Move right"} },
|
||||
{ moveforward, {GLFW_KEY_UP, "Move forwards"} },
|
||||
{ moveback, {GLFW_KEY_DOWN, "Move backwards"} },
|
||||
{ moveup, {GLFW_KEY_PAGE_UP, "Move up"} },
|
||||
{ movedown, {GLFW_KEY_PAGE_DOWN, "Move down"} },
|
||||
};
|
||||
}
|
||||
else {
|
||||
m_bindingsetups = {
|
||||
{ user_command::moveleft, {GLFW_KEY_A, "Move left"} },
|
||||
{ user_command::moveright, {GLFW_KEY_D, "Move right"} },
|
||||
{ user_command::moveforward, {GLFW_KEY_W, "Move forwards"} },
|
||||
{ user_command::moveback, {GLFW_KEY_S, "Move backwards"} },
|
||||
{ user_command::moveup, {GLFW_KEY_E, "Move up"} },
|
||||
{ user_command::movedown, {GLFW_KEY_Q, "Move down"} },
|
||||
{ moveleft, {GLFW_KEY_A, "Move left"} },
|
||||
{ moveright, {GLFW_KEY_D, "Move right"} },
|
||||
{ moveforward, {GLFW_KEY_W, "Move forwards"} },
|
||||
{ moveback, {GLFW_KEY_S, "Move backwards"} },
|
||||
{ moveup, {GLFW_KEY_E, "Move up"} },
|
||||
{ movedown, {GLFW_KEY_Q, "Move down"} },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ gamepad_input::init() {
|
||||
m_inputbuttons.clear();
|
||||
// NOTE: we're only checking for joystick_1 and rely for it to stay connected throughout.
|
||||
// not exactly flexible, but for quick hack it'll do
|
||||
auto const name = glfwGetJoystickName( GLFW_JOYSTICK_1 );
|
||||
if( name != nullptr ) {
|
||||
if( auto const name = glfwGetJoystickName( GLFW_JOYSTICK_1 ); name != nullptr ) {
|
||||
WriteLog( "Connected gamepad: " + std::string( name ) );
|
||||
m_deviceid = GLFW_JOYSTICK_1;
|
||||
}
|
||||
@@ -94,7 +93,7 @@ gamepad_input::poll() {
|
||||
if( button.state != buttons[ idx ] ) {
|
||||
// button pressed or released, both are important
|
||||
on_button(
|
||||
idx,
|
||||
static_cast<int>(idx),
|
||||
buttons[idx] == 1 ? GLFW_PRESS : GLFW_RELEASE);
|
||||
}
|
||||
else {
|
||||
@@ -102,7 +101,7 @@ gamepad_input::poll() {
|
||||
if( button.state == GLFW_PRESS ) {
|
||||
|
||||
on_button(
|
||||
idx,
|
||||
static_cast<int>(idx),
|
||||
GLFW_REPEAT );
|
||||
}
|
||||
}
|
||||
@@ -125,9 +124,9 @@ gamepad_input::poll() {
|
||||
}
|
||||
|
||||
void
|
||||
gamepad_input::bind( std::vector< std::reference_wrapper<user_command> > &Targets, cParser &Input, std::unordered_map<std::string, user_command> const &Translator, std::string const Point ) {
|
||||
gamepad_input::bind( std::vector< std::reference_wrapper<user_command> > const &Targets, cParser &Input, std::unordered_map<std::string, user_command> const &Translator, std::string const &Point ) const {
|
||||
|
||||
for( auto &bindingtarget : Targets ) {
|
||||
for( auto const &bindingtarget : Targets ) {
|
||||
// grab command(s) associated with the input pin
|
||||
auto const bindingcommandname{ Input.getToken<std::string>() };
|
||||
if( true == bindingcommandname.empty() ) {
|
||||
@@ -154,12 +153,11 @@ bool
|
||||
gamepad_input::recall_bindings() {
|
||||
std::string filePath = "eu07_input-gamepad.ini";
|
||||
|
||||
fs::path appPath = user_config_path("eu07_input-gamepad.ini");
|
||||
if (!appPath.empty() && fs::exists(appPath))
|
||||
if (fs::path appPath = user_config_path("eu07_input-gamepad.ini"); !appPath.empty() && fs::exists(appPath))
|
||||
filePath = appPath.string();
|
||||
|
||||
// bindingparser tworzony zawsze, z wybran<61> <20>cie<69>k<EFBFBD>
|
||||
cParser bindingparser(filePath.c_str(), cParser::buffer_FILE);
|
||||
cParser bindingparser(filePath, cParser::buffer_FILE);
|
||||
|
||||
if( false == bindingparser.ok() ) {
|
||||
return false;
|
||||
@@ -169,7 +167,7 @@ gamepad_input::recall_bindings() {
|
||||
std::unordered_map<std::string, user_command> nametocommandmap;
|
||||
std::size_t commandid = 0;
|
||||
for( auto const &description : simulation::Commands_descriptions ) {
|
||||
nametocommandmap.emplace(
|
||||
nametocommandmap.try_emplace(
|
||||
description.name,
|
||||
static_cast<user_command>( commandid ) );
|
||||
++commandid;
|
||||
@@ -191,16 +189,16 @@ gamepad_input::recall_bindings() {
|
||||
|
||||
std::string bindingpoint {};
|
||||
entryparser >> bindingpoint;
|
||||
auto const splitbindingpoint { split_string_and_number( bindingpoint ) };
|
||||
auto const [pointtype, pointindex]{ split_string_and_number( bindingpoint ) };
|
||||
|
||||
if( splitbindingpoint.first == "axis" ) {
|
||||
if( pointtype == "axis" ) {
|
||||
// one or more sets of: [modeIDX] input type, parameters
|
||||
// [optional] modeIDX associates the set with control mode IDX
|
||||
// input types:
|
||||
// -- range commandname IDX; axis value is passed as paramIDX of commandname
|
||||
// -- 3state commandname commandname; positive axis value issues first commandname, negative value issues second commandname
|
||||
|
||||
auto const axisindex { splitbindingpoint.second };
|
||||
auto const axisindex { pointindex };
|
||||
// sanity check, connected gamepad isn't guaranteed to have that many axes
|
||||
if( axisindex >= m_inputaxes.size() ) { continue; }
|
||||
|
||||
@@ -211,8 +209,7 @@ gamepad_input::recall_bindings() {
|
||||
std::string key {};
|
||||
entryparser >> key;
|
||||
// check for potential mode indicator
|
||||
auto const splitkey { split_string_and_number( key ) };
|
||||
if( splitkey.first == "mode" ) {
|
||||
if( auto const splitkey { split_string_and_number( key ) }; splitkey.first == "mode" ) {
|
||||
// indicate we'll be processing specified mode
|
||||
controlmode = splitkey.second;
|
||||
continue;
|
||||
@@ -231,12 +228,13 @@ gamepad_input::recall_bindings() {
|
||||
std::get<0>( m_inputaxes[ axisindex ].bindings[ controlmode ] ) = bindingtype;
|
||||
// retrieve regular commands associated with the axis and mode
|
||||
switch( bindingtype ) {
|
||||
case input_type::value:
|
||||
case input_type::value_invert: {
|
||||
using enum gamepad_input::input_type;
|
||||
case value:
|
||||
case value_invert: {
|
||||
bindingtargets.emplace_back( std::ref( std::get<1>( m_inputaxes[ axisindex ].bindings[ controlmode ] ) ) );
|
||||
break;
|
||||
}
|
||||
case input_type::threestate: {
|
||||
case threestate: {
|
||||
bindingtargets.emplace_back( std::ref( std::get<1>( m_inputaxes[ axisindex ].bindings[ controlmode ] ) ) );
|
||||
bindingtargets.emplace_back( std::ref( std::get<2>( m_inputaxes[ axisindex ].bindings[ controlmode ] ) ) );
|
||||
break;
|
||||
@@ -267,9 +265,9 @@ gamepad_input::recall_bindings() {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( splitbindingpoint.first == "button" ) {
|
||||
else if( pointtype == "button" ) {
|
||||
|
||||
auto const buttonindex { splitbindingpoint.second };
|
||||
auto const buttonindex { pointindex };
|
||||
// sanity check, connected gamepad isn't guaranteed to have that many buttons
|
||||
if( buttonindex >= m_inputbuttons.size() ) { continue; }
|
||||
|
||||
@@ -345,7 +343,8 @@ void
|
||||
gamepad_input::process_axes() {
|
||||
|
||||
input_type inputtype;
|
||||
user_command boundcommand1, boundcommand2;
|
||||
user_command boundcommand1;
|
||||
user_command boundcommand2;
|
||||
auto binding { std::tie( inputtype, boundcommand1, boundcommand2 ) };
|
||||
|
||||
// since some commands can potentially collect values from two different axes we can't post them directly
|
||||
@@ -369,20 +368,18 @@ gamepad_input::process_axes() {
|
||||
auto const deltatime { Timer::GetDeltaTime() * 15.0 };
|
||||
if( axis.state >= 0.0f ) {
|
||||
// first bound command selected
|
||||
if( axis.accumulator < 0.0f ) {
|
||||
// we were issuing the other command, post notification that's no longer the case
|
||||
if( boundcommand2 != user_command::none ) {
|
||||
m_relay.post(
|
||||
boundcommand2,
|
||||
0, 0,
|
||||
GLFW_RELEASE,
|
||||
0 );
|
||||
axis.accumulator = 0.0f;
|
||||
}
|
||||
// we were issuing the other command, post notification that's no longer the case
|
||||
if (axis.accumulator < 0.0f && boundcommand2 != user_command::none) {
|
||||
m_relay.post(
|
||||
boundcommand2,
|
||||
0, 0,
|
||||
GLFW_RELEASE,
|
||||
0 );
|
||||
axis.accumulator = 0.0f;
|
||||
}
|
||||
if( boundcommand1 != user_command::none ) {
|
||||
if( axis.state > m_deadzone ) {
|
||||
axis.accumulator += ( axis.state - m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime;
|
||||
axis.accumulator += static_cast<float>(( axis.state - m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime);
|
||||
// we're making sure there's always a positive charge left in the accumulator,
|
||||
// to more reliably decect when the stick goes from active to dead zone, below
|
||||
while( axis.accumulator > 1.0f ) {
|
||||
@@ -409,20 +406,18 @@ gamepad_input::process_axes() {
|
||||
}
|
||||
else {
|
||||
// second bound command selected
|
||||
if( axis.accumulator > 0.0f ) {
|
||||
// we were issuing the other command, post notification that's no longer the case
|
||||
if( boundcommand1 != user_command::none ) {
|
||||
m_relay.post(
|
||||
boundcommand1,
|
||||
0, 0,
|
||||
GLFW_RELEASE,
|
||||
0 );
|
||||
axis.accumulator = 0.0f;
|
||||
}
|
||||
// we were issuing the other command, post notification that's no longer the case
|
||||
if (axis.accumulator > 0.0f && boundcommand1 != user_command::none) {
|
||||
m_relay.post(
|
||||
boundcommand1,
|
||||
0, 0,
|
||||
GLFW_RELEASE,
|
||||
0 );
|
||||
axis.accumulator = 0.0f;
|
||||
}
|
||||
if( boundcommand1 != user_command::none ) {
|
||||
if( axis.state < -m_deadzone ) {
|
||||
axis.accumulator += ( axis.state + m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime;
|
||||
axis.accumulator += static_cast<float>(( axis.state + m_deadzone ) / ( 1.0 - m_deadzone ) * deltatime);
|
||||
// we're making sure there's always a positive charge left in the accumulator,
|
||||
// to more reliably decect when the stick goes from active to dead zone, below
|
||||
while( axis.accumulator < -1.0f ) {
|
||||
@@ -464,19 +459,18 @@ gamepad_input::process_axes() {
|
||||
else {
|
||||
param = param > 0.0 ? (param - m_deadzone) / (1.0 - m_deadzone) : (param + m_deadzone) / (1.0 - m_deadzone);
|
||||
}
|
||||
if( param != 0.0 ) {
|
||||
if( inputtype == input_type::value_invert ) {
|
||||
param *= -1.0;
|
||||
}
|
||||
if (param != 0.0 && inputtype == input_type::value_invert) {
|
||||
param *= -1.0;
|
||||
}
|
||||
// scale passed value according to command type
|
||||
switch( boundcommand1 ) {
|
||||
case user_command::viewturn: {
|
||||
using enum user_command;
|
||||
case viewturn: {
|
||||
param *= 10.0 * ( Timer::GetDeltaRenderTime() * 60.0 );
|
||||
break;
|
||||
}
|
||||
case user_command::movehorizontal:
|
||||
case user_command::movehorizontalfast: {
|
||||
case movehorizontal:
|
||||
case movehorizontalfast: {
|
||||
// these expect value in -1:1 range
|
||||
break;
|
||||
}
|
||||
@@ -494,17 +488,17 @@ gamepad_input::process_axes() {
|
||||
}
|
||||
}
|
||||
// issue remaining, assembled commands
|
||||
for( auto const &command : commands ) {
|
||||
auto const param1 { std::get<0>( command.second ) };
|
||||
auto const param2 { std::get<1>( command.second ) };
|
||||
auto &lastparams { m_lastcommandparams[ command.first ] };
|
||||
for( auto const &[commandid, commandparams] : commands ) {
|
||||
auto const param1 { std::get<0>( commandparams ) };
|
||||
auto const param2 { std::get<1>( commandparams ) };
|
||||
auto &lastparams { m_lastcommandparams[ commandid ] };
|
||||
if( param1 != 0.0 || std::get<0>(lastparams) != 0.0
|
||||
|| param2 != 0.0 || std::get<1>(lastparams) != 0.0 ) {
|
||||
m_relay.post(
|
||||
command.first,
|
||||
commandid,
|
||||
param1,
|
||||
param2,
|
||||
std::get<2>( command.second ),
|
||||
std::get<2>( commandparams ),
|
||||
// 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
|
||||
0 );
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
using inputaxis_sequence = std::vector<input_axis>;
|
||||
// methods
|
||||
bool recall_bindings();
|
||||
void bind( std::vector< std::reference_wrapper<user_command> > &Targets, cParser &Input, std::unordered_map<std::string, user_command> const &Translator, std::string const Point );
|
||||
void bind( std::vector< std::reference_wrapper<user_command> > const &Targets, cParser &Input, std::unordered_map<std::string, user_command> const &Translator, std::string const &Point ) const;
|
||||
void on_button( int const Button, int const Action );
|
||||
void process_axes();
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ keyboard_input::recall_bindings() {
|
||||
// Fallback <20> plik w folderze symulatora
|
||||
path = "eu07_input-keyboard.ini";
|
||||
}
|
||||
cParser bindingparser(path.c_str(), cParser::buffer_FILE);
|
||||
cParser bindingparser(path, cParser::buffer_FILE);
|
||||
|
||||
bindingparser.skipComments = false;
|
||||
if( false == bindingparser.ok() ) {
|
||||
@@ -147,7 +147,7 @@ keyboard_input::recall_bindings() {
|
||||
std::unordered_map<std::string, user_command> nametocommandmap;
|
||||
std::size_t commandid = 0;
|
||||
for( auto const &description : simulation::Commands_descriptions ) {
|
||||
nametocommandmap.emplace(
|
||||
nametocommandmap.try_emplace(
|
||||
description.name,
|
||||
static_cast<user_command>( commandid ) );
|
||||
++commandid;
|
||||
@@ -155,7 +155,7 @@ keyboard_input::recall_bindings() {
|
||||
std::unordered_map<std::string, int> nametokeymap;
|
||||
|
||||
for (const std::pair<int, std::string> &key : keytonamemap) {
|
||||
nametokeymap.emplace(key.second, key.first);
|
||||
nametokeymap.try_emplace(key.second, key.first);
|
||||
}
|
||||
|
||||
// NOTE: to simplify things we expect one entry per line, and whole entry in one line
|
||||
@@ -225,7 +225,7 @@ keyboard_input::recall_bindings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void keyboard_input::dump_bindings()
|
||||
void keyboard_input::dump_bindings() const
|
||||
{
|
||||
std::fstream stream("eu07_input-keyboard.ini",
|
||||
std::ios_base::binary | std::ios_base::trunc | std::ios_base::out);
|
||||
@@ -239,8 +239,7 @@ void keyboard_input::dump_bindings()
|
||||
stream << simulation::Commands_descriptions[static_cast<std::size_t>(binding.first)].name << ' ';
|
||||
|
||||
int keycode = std::get<int>(binding.second);
|
||||
auto it = keytonamemap.find(keycode & 0xFFFF);
|
||||
if (it != keytonamemap.end()) {
|
||||
if (auto it = keytonamemap.find(keycode & 0xFFFF); it != keytonamemap.end()) {
|
||||
if (keycode & keymodifier::control)
|
||||
stream << "ctrl ";
|
||||
if (keycode & keymodifier::shift)
|
||||
@@ -284,7 +283,7 @@ keyboard_input::key( int const Key, int const Action ) {
|
||||
if( Key == -1 ) { return false; }
|
||||
|
||||
// store key state
|
||||
input::keys[ Key ] = Action;
|
||||
input::keys[ Key ] = static_cast<char>( Action );
|
||||
|
||||
if( true == is_movement_key( Key ) ) {
|
||||
// if the received key was one of movement keys, it's been handled and we don't need to bother further
|
||||
@@ -298,8 +297,7 @@ keyboard_input::key( int const Key, int const Action ) {
|
||||
| ( modifier ? 0 : input::key_ctrl ? keymodifier::control : 0 );
|
||||
|
||||
if( Action == GLFW_RELEASE ) {
|
||||
auto const stored = m_modsforkeys.find( Key );
|
||||
if( stored != m_modsforkeys.end() ) {
|
||||
if( auto const stored = m_modsforkeys.find( Key ); stored != m_modsforkeys.end() ) {
|
||||
key = stored->second;
|
||||
}
|
||||
m_modsforkeys.erase( Key );
|
||||
@@ -330,28 +328,29 @@ keyboard_input::key( int const Key ) const {
|
||||
|
||||
void
|
||||
keyboard_input::bind() {
|
||||
using enum user_command;
|
||||
m_bindings.clear();
|
||||
|
||||
for( auto const &bindingsetup : m_bindingsetups ) {
|
||||
for( auto const &[setupcommand, setupbinding] : m_bindingsetups ) {
|
||||
|
||||
m_bindings[ std::get<int>(bindingsetup.second) ] = bindingsetup.first;
|
||||
m_bindings[ std::get<int>(setupbinding) ] = setupcommand;
|
||||
}
|
||||
|
||||
// cache movement key bindings
|
||||
m_bindingscache.forward = binding( user_command::moveforward );
|
||||
m_bindingscache.back = binding( user_command::moveback );
|
||||
m_bindingscache.left = binding( user_command::moveleft );
|
||||
m_bindingscache.right = binding( user_command::moveright );
|
||||
m_bindingscache.up = binding( user_command::moveup );
|
||||
m_bindingscache.down = binding( user_command::movedown );
|
||||
m_bindingscache.forward = binding( moveforward );
|
||||
m_bindingscache.back = binding( moveback );
|
||||
m_bindingscache.left = binding( moveleft );
|
||||
m_bindingscache.right = binding( moveright );
|
||||
m_bindingscache.up = binding( moveup );
|
||||
m_bindingscache.down = binding( movedown );
|
||||
}
|
||||
|
||||
int
|
||||
keyboard_input::binding( user_command const Command ) const {
|
||||
|
||||
for( auto const &binding : m_bindings ) {
|
||||
if( binding.second == Command ) {
|
||||
return binding.first;
|
||||
for( auto const &[bindingkey, bindingcommand] : m_bindings ) {
|
||||
if( bindingcommand == Command ) {
|
||||
return bindingkey;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -413,7 +412,7 @@ keyboard_input::poll() {
|
||||
m_movementvertical = movementvertical;
|
||||
}
|
||||
|
||||
std::unordered_map<int, std::string> keytonamemap = {
|
||||
std::unordered_map<int, std::string> const keytonamemap = {
|
||||
{ GLFW_KEY_0, "0" }, { GLFW_KEY_1, "1" }, { GLFW_KEY_2, "2" }, { GLFW_KEY_3, "3" }, { GLFW_KEY_4, "4" },
|
||||
{ GLFW_KEY_5, "5" }, { GLFW_KEY_6, "6" }, { GLFW_KEY_7, "7" }, { GLFW_KEY_8, "8" }, { GLFW_KEY_9, "9" },
|
||||
{ GLFW_KEY_MINUS, "-" }, { GLFW_KEY_EQUAL, "=" },
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
void
|
||||
poll();
|
||||
inline
|
||||
user_command const
|
||||
user_command
|
||||
command() const {
|
||||
return m_command; }
|
||||
bindingsetup_sequence&
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
std::string
|
||||
binding_hint( user_command const Command ) const;
|
||||
void
|
||||
dump_bindings();
|
||||
dump_bindings() const;
|
||||
|
||||
// members
|
||||
static std::unordered_map<int, std::string> keytonamemap;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace multiplayer {
|
||||
std::uint32_t const EU07_MESSAGEHEADER { MAKE_ID4( 'E','U','0','7' ) };
|
||||
|
||||
void
|
||||
Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) {
|
||||
Navigate([[maybe_unused]] std::string const &ClassName, [[maybe_unused]] UINT Msg, [[maybe_unused]] WPARAM wParam, [[maybe_unused]] LPARAM lParam) {
|
||||
#ifdef _WIN32
|
||||
// wysłanie komunikatu do sterującego
|
||||
HWND h = FindWindow(ClassName.c_str(), 0); // można by to zapamiętać
|
||||
@@ -43,7 +43,7 @@ Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) {
|
||||
}
|
||||
|
||||
void
|
||||
OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
OnCommandGet(multiplayer::DaneRozkaz const *pRozkaz)
|
||||
{ // odebranie komunikatu z serwera
|
||||
if (pRozkaz->iSygn == EU07_MESSAGEHEADER )
|
||||
switch (pRozkaz->iComm)
|
||||
@@ -62,15 +62,13 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) + " rcvd" );
|
||||
|
||||
if( Global.iMultiplayer ) {
|
||||
auto *event = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
if( event != nullptr ) {
|
||||
if( typeid(*event) == typeid(multi_event)
|
||||
|| typeid(*event) == typeid(lights_event)
|
||||
|| event->m_sibling != 0 ) {
|
||||
// tylko jawne albo niejawne Multiple
|
||||
command_relay relay;
|
||||
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
|
||||
}
|
||||
auto const *foundevent = simulation::Events.FindEvent( std::string( pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0] ) );
|
||||
if (foundevent != nullptr && (typeid(*foundevent) == typeid(multi_event)
|
||||
|| typeid(*foundevent) == typeid(lights_event)
|
||||
|| foundevent->m_sibling != nullptr)) {
|
||||
// tylko jawne albo niejawne Multiple
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &foundevent->name());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -78,7 +76,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
case 3: // rozkaz dla AI
|
||||
if (Global.iMultiplayer)
|
||||
{
|
||||
int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
|
||||
auto i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
|
||||
CommLog(
|
||||
Now() + " " + std::to_string(pRozkaz->iComm) + " " +
|
||||
std::string(pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[10 + i]) +
|
||||
@@ -110,21 +108,21 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
break;
|
||||
case 5: // ustawienie parametrów
|
||||
{
|
||||
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " params " + std::to_string(*pRozkaz->iPar) + " rcvd");
|
||||
if (*pRozkaz->iPar == 0) // sprawdzenie czasu
|
||||
if (*pRozkaz->iPar & 1) // ustawienie czasu
|
||||
{
|
||||
auto t = pRozkaz->fPar[1];
|
||||
simulation::Time.data().wDay = std::floor(t); // niby nie powinno być dnia, ale...
|
||||
if (Global.fMoveLight >= 0)
|
||||
Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć
|
||||
simulation::Time.data().wHour = std::floor(24 * t) - 24.0 * simulation::Time.data().wDay;
|
||||
simulation::Time.data().wMinute = std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour);
|
||||
simulation::Time.data().wSecond = std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute );
|
||||
}
|
||||
if (*pRozkaz->iPar & 2)
|
||||
CommLog(Now() + " " + std::to_string(pRozkaz->iComm) + " params " + std::to_string(pRozkaz->iPar[0]) + " rcvd");
|
||||
// sprawdzenie czasu
|
||||
if (pRozkaz->iPar[0] == 0 && pRozkaz->iPar[0] & 1) // ustawienie czasu
|
||||
{
|
||||
auto t = pRozkaz->fPar[1];
|
||||
simulation::Time.data().wDay = static_cast<uint16_t>(std::floor(t)); // niby nie powinno być dnia, ale...
|
||||
if (Global.fMoveLight >= 0)
|
||||
Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć
|
||||
simulation::Time.data().wHour = static_cast<uint16_t>(std::floor(24 * t) - 24.0 * simulation::Time.data().wDay);
|
||||
simulation::Time.data().wMinute = static_cast<uint16_t>(std::floor(60 * 24 * t) - 60.0 * (24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour));
|
||||
simulation::Time.data().wSecond = static_cast<uint16_t>(std::floor( 60 * 60 * 24 * t ) - 60.0 * ( 60.0 * ( 24.0 * simulation::Time.data().wDay + simulation::Time.data().wHour ) + simulation::Time.data().wMinute ));
|
||||
}
|
||||
if (pRozkaz->iPar[0] & 2)
|
||||
{ // ustawienie flag zapauzowania
|
||||
Global.iPause = pRozkaz->fPar[2]; // zakładamy, że wysyłający wie, co robi
|
||||
Global.iPause = static_cast<int>(pRozkaz->fPar[2]); // zakładamy, że wysyłający wie, co robi
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -138,7 +136,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
+ " rcvd" );
|
||||
if (pRozkaz->cString[0]) {
|
||||
// jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7
|
||||
auto *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
|
||||
auto const *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
|
||||
if( vehicle != nullptr ) {
|
||||
WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe
|
||||
}
|
||||
@@ -189,7 +187,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
d->Damage( pRozkaz->cString[ 0 ] );
|
||||
d = d->Prev(); // w drugą stronę też
|
||||
}
|
||||
WyslijUszkodzenia( lookup->asName, lookup->MoverParameters->EngDmgFlag ); // zwrot informacji o pojeździe
|
||||
WyslijUszkodzenia( lookup->asName, static_cast<char>(lookup->MoverParameters->EngDmgFlag) ); // zwrot informacji o pojeździe
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -198,7 +196,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|
||||
}
|
||||
|
||||
void
|
||||
WyslijEvent(const std::string &e, const std::string &d)
|
||||
WyslijEvent([[maybe_unused]] const std::string &e, [[maybe_unused]] const std::string &d)
|
||||
{ // Ra: jeszcze do wyczyszczenia
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
@@ -219,7 +217,7 @@ WyslijEvent(const std::string &e, const std::string &d)
|
||||
}
|
||||
|
||||
void
|
||||
WyslijUszkodzenia(const std::string &t, char fl)
|
||||
WyslijUszkodzenia([[maybe_unused]] const std::string &t, [[maybe_unused]] char fl)
|
||||
{ // wysłanie informacji w postaci pojedynczego tekstu
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
@@ -239,7 +237,7 @@ WyslijUszkodzenia(const std::string &t, char fl)
|
||||
}
|
||||
|
||||
void
|
||||
WyslijString(const std::string &t, int n)
|
||||
WyslijString([[maybe_unused]] const std::string &t, [[maybe_unused]] int n)
|
||||
{ // wysłanie informacji w postaci pojedynczego tekstu
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
@@ -264,7 +262,7 @@ WyslijWolny(const std::string &t)
|
||||
}
|
||||
|
||||
void
|
||||
WyslijNamiary(TDynamicObject const *Vehicle)
|
||||
WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle)
|
||||
{ // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
@@ -395,7 +393,7 @@ WyslijObsadzone()
|
||||
}
|
||||
|
||||
void
|
||||
WyslijParam(int nr, int fl)
|
||||
WyslijParam([[maybe_unused]] int nr, [[maybe_unused]] int fl)
|
||||
{ // wysłanie parametrów symulacji w ramce (nr) z flagami (fl)
|
||||
#ifdef _WIN32
|
||||
DaneRozkaz r;
|
||||
|
||||
@@ -38,7 +38,7 @@ struct DaneRozkaz2 { // struktura komunikacji z EU07.EXE
|
||||
|
||||
void Navigate( std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
void OnCommandGet( multiplayer::DaneRozkaz *pRozkaz );
|
||||
void OnCommandGet( multiplayer::DaneRozkaz const *pRozkaz );
|
||||
|
||||
void WyslijEvent( const std::string &e, const std::string &d );
|
||||
void WyslijString( const std::string &t, int n );
|
||||
|
||||
Reference in New Issue
Block a user