Merge pull request #509 from ChancellorIkseew/window-update
input minor refactoring
This commit is contained in:
commit
8a21bd212c
@ -186,13 +186,12 @@ public:
|
|||||||
pressedKeys.clear();
|
pressedKeys.clear();
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
for (auto& entry : bindings.getAll()) {
|
for (auto& [_, binding] : bindings.getAll()) {
|
||||||
auto& binding = entry.second;
|
|
||||||
if (!binding.enabled) {
|
if (!binding.enabled) {
|
||||||
binding.state = false;
|
binding.state = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
binding.justChange = false;
|
binding.justChanged = false;
|
||||||
|
|
||||||
bool newstate = false;
|
bool newstate = false;
|
||||||
switch (binding.type) {
|
switch (binding.type) {
|
||||||
@ -207,13 +206,13 @@ public:
|
|||||||
if (newstate) {
|
if (newstate) {
|
||||||
if (!binding.state) {
|
if (!binding.state) {
|
||||||
binding.state = true;
|
binding.state = true;
|
||||||
binding.justChange = true;
|
binding.justChanged = true;
|
||||||
binding.onactived.notify();
|
binding.onactived.notify();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (binding.state) {
|
if (binding.state) {
|
||||||
binding.state = false;
|
binding.state = false;
|
||||||
binding.justChange = true;
|
binding.justChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ static std::unordered_map<int, std::string> keynames {};
|
|||||||
static std::unordered_map<int, std::string> buttonsnames{};
|
static std::unordered_map<int, std::string> buttonsnames{};
|
||||||
|
|
||||||
std::string input_util::get_name(Mousecode code) {
|
std::string input_util::get_name(Mousecode code) {
|
||||||
auto found = buttonsnames.find(static_cast<int>(code));
|
const auto found = buttonsnames.find(static_cast<int>(code));
|
||||||
if (found == buttonsnames.end()) {
|
if (found == buttonsnames.end()) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ std::string input_util::get_name(Mousecode code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string input_util::get_name(Keycode code) {
|
std::string input_util::get_name(Keycode code) {
|
||||||
auto found = keynames.find(static_cast<int>(code));
|
const auto found = keynames.find(static_cast<int>(code));
|
||||||
if (found == keynames.end()) {
|
if (found == keynames.end()) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -158,7 +158,7 @@ struct Binding {
|
|||||||
InputType type;
|
InputType type;
|
||||||
int code;
|
int code;
|
||||||
bool state = false;
|
bool state = false;
|
||||||
bool justChange = false;
|
bool justChanged = false;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
|
||||||
Binding() = default;
|
Binding() = default;
|
||||||
@ -170,7 +170,7 @@ struct Binding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool jactive() const {
|
bool jactive() const {
|
||||||
return state && justChange;
|
return state && justChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(InputType, int);
|
void reset(InputType, int);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user