mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 13:31:49 +00:00
toml parser update + 'toml' module is built-in now
This commit is contained in:
parent
ffdeac5c1f
commit
c94d40ab02
15 changed files with 252 additions and 178 deletions
|
|
@ -32,6 +32,12 @@ static std::unordered_map<std::string, int> keycodes {
|
|||
{"up", GLFW_KEY_UP},
|
||||
};
|
||||
|
||||
static std::unordered_map<std::string, int> mousecodes {
|
||||
{"left", GLFW_MOUSE_BUTTON_1},
|
||||
{"right", GLFW_MOUSE_BUTTON_2},
|
||||
{"middle", GLFW_MOUSE_BUTTON_3},
|
||||
};
|
||||
|
||||
void Binding::reset(inputtype type, int code) {
|
||||
this->type = type;
|
||||
this->code = code;
|
||||
|
|
@ -65,6 +71,14 @@ keycode input_util::keycode_from(const std::string& name) {
|
|||
return static_cast<keycode>(found->second);
|
||||
}
|
||||
|
||||
mousecode input_util::mousecode_from(const std::string& name) {
|
||||
const auto& found = mousecodes.find(name);
|
||||
if (found == mousecodes.end()) {
|
||||
return mousecode::UNKNOWN;
|
||||
}
|
||||
return static_cast<mousecode>(found->second);
|
||||
}
|
||||
|
||||
std::string input_util::to_string(keycode code) {
|
||||
int icode_repr = static_cast<int>(code);
|
||||
#ifdef _WIN32
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ enum class mousecode : int {
|
|||
BUTTON_1 = 0, // Left mouse button
|
||||
BUTTON_2 = 1, // Right mouse button
|
||||
BUTTON_3 = 2, // Middle mouse button
|
||||
UNKNOWN = -1,
|
||||
};
|
||||
|
||||
inline mousecode MOUSECODES_ALL[] {
|
||||
|
|
@ -115,6 +116,8 @@ namespace input_util {
|
|||
void initialize();
|
||||
|
||||
keycode keycode_from(const std::string& name);
|
||||
mousecode mousecode_from(const std::string& name);
|
||||
|
||||
/// @return Key label by keycode
|
||||
std::string to_string(keycode code);
|
||||
/// @return Mouse button label by keycode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue