mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 23:49:19 +02:00
AnimModel.cpp reaches cParser through the simulation core, not a direct import, so the previous pass missed it; the propagation now follows the whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call Console:: inside _WIN32 guards without importing eu07.console - invisible on Linux, where those blocks are skipped.
137 lines
2.7 KiB
C++
137 lines
2.7 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/.
|
|
*/
|
|
module;
|
|
#include <chrono>
|
|
#include <cstddef>
|
|
#include <limits>
|
|
#include <mutex>
|
|
#include <ostream>
|
|
#include <sstream>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include <deque>
|
|
#include <tuple>
|
|
#include <unordered_map>
|
|
#include <array>
|
|
#include <GLFW/glfw3.h>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
export module eu07.input.keyboardinput;
|
|
import eu07.glm;
|
|
import eu07.application.uitranscripts;
|
|
import eu07.input.command;
|
|
|
|
export {
|
|
|
|
|
|
|
|
namespace input {
|
|
|
|
extern std::array<char, GLFW_KEY_LAST + 1> keys;
|
|
extern bool key_alt;
|
|
extern bool key_ctrl;
|
|
extern bool key_shift;
|
|
|
|
}
|
|
|
|
class keyboard_input {
|
|
|
|
public:
|
|
// types
|
|
using bindingsetup_sequence = std::map<user_command, std::tuple<int, std::string>>;
|
|
|
|
enum keymodifier : int {
|
|
|
|
shift = 0x10000,
|
|
control = 0x20000
|
|
};
|
|
|
|
// constructors
|
|
keyboard_input() = default;
|
|
|
|
// destructor
|
|
virtual ~keyboard_input() = default;
|
|
|
|
// methods
|
|
virtual
|
|
bool
|
|
init() { return true; }
|
|
bool
|
|
key( int const Key, int const Action );
|
|
int
|
|
key( int const Key ) const;
|
|
void
|
|
poll();
|
|
inline
|
|
user_command const
|
|
command() const {
|
|
return m_command; }
|
|
bindingsetup_sequence&
|
|
bindings() {
|
|
return m_bindingsetups; }
|
|
int
|
|
binding( user_command const Command ) const;
|
|
std::string
|
|
binding_hint( user_command const Command ) const;
|
|
void
|
|
dump_bindings();
|
|
|
|
// members
|
|
static std::unordered_map<int, std::string> keytonamemap;
|
|
|
|
protected:
|
|
// methods
|
|
virtual
|
|
void
|
|
default_bindings() = 0;
|
|
bool
|
|
recall_bindings();
|
|
public:
|
|
// the keymapper widget rebinds keys through this
|
|
void
|
|
bind();
|
|
protected:
|
|
|
|
// members
|
|
bindingsetup_sequence m_bindingsetups;
|
|
|
|
private:
|
|
// types
|
|
using usercommand_map = std::unordered_map<int, user_command>;
|
|
|
|
struct bindings_cache {
|
|
|
|
int forward { -1 };
|
|
int back { -1 };
|
|
int left { -1 };
|
|
int right { -1 };
|
|
int up { -1 };
|
|
int down { -1 };
|
|
};
|
|
|
|
// methods
|
|
bool
|
|
is_movement_key( int const Key ) const;
|
|
|
|
// members
|
|
user_command m_command { user_command::none }; // last, if any, issued command
|
|
usercommand_map m_bindings;
|
|
std::unordered_map<int, int> m_modsforkeys; // modifiers that were used with the active keys
|
|
command_relay m_relay;
|
|
bindings_cache m_bindingscache;
|
|
glm::vec2 m_movementhorizontal { 0.f };
|
|
float m_movementvertical { 0.f };
|
|
};
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
} // export
|