fix: Key presses not always unlocking frame rate correctly
This commit is contained in:
parent
62ecfb0e0e
commit
d10f033439
@ -61,7 +61,7 @@ namespace hex {
|
|||||||
std::list<std::string> m_popupsToOpen;
|
std::list<std::string> m_popupsToOpen;
|
||||||
std::vector<int> m_pressedKeys;
|
std::vector<int> m_pressedKeys;
|
||||||
|
|
||||||
bool m_mouseButtonDown = false;
|
bool m_buttonDown = false;
|
||||||
|
|
||||||
bool m_hadEvent = false;
|
bool m_hadEvent = false;
|
||||||
bool m_frameRateTemporarilyUnlocked = false;
|
bool m_frameRateTemporarilyUnlocked = false;
|
||||||
|
@ -170,7 +170,7 @@ namespace hex {
|
|||||||
bool frameRateUnlocked =
|
bool frameRateUnlocked =
|
||||||
ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId) ||
|
ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId) ||
|
||||||
TaskManager::getRunningTaskCount() > 0 ||
|
TaskManager::getRunningTaskCount() > 0 ||
|
||||||
this->m_mouseButtonDown ||
|
this->m_buttonDown ||
|
||||||
this->m_hadEvent ||
|
this->m_hadEvent ||
|
||||||
!this->m_pressedKeys.empty();
|
!this->m_pressedKeys.empty();
|
||||||
|
|
||||||
@ -830,9 +830,9 @@ namespace hex {
|
|||||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||||
|
|
||||||
if (action == GLFW_PRESS)
|
if (action == GLFW_PRESS)
|
||||||
win->m_mouseButtonDown = true;
|
win->m_buttonDown = true;
|
||||||
else if (action == GLFW_RELEASE)
|
else if (action == GLFW_RELEASE)
|
||||||
win->m_mouseButtonDown = false;
|
win->m_buttonDown = false;
|
||||||
win->processEvent();
|
win->processEvent();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -848,17 +848,24 @@ namespace hex {
|
|||||||
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
||||||
hex::unused(mods);
|
hex::unused(mods);
|
||||||
|
|
||||||
|
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||||
|
|
||||||
|
if (action == GLFW_RELEASE) {
|
||||||
|
win->m_buttonDown = false;
|
||||||
|
} else {
|
||||||
|
win->m_buttonDown = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (key == GLFW_KEY_UNKNOWN) return;
|
if (key == GLFW_KEY_UNKNOWN) return;
|
||||||
|
|
||||||
auto keyName = glfwGetKeyName(key, scancode);
|
auto keyName = glfwGetKeyName(key, scancode);
|
||||||
if (keyName != nullptr)
|
if (keyName != nullptr)
|
||||||
key = std::toupper(keyName[0]);
|
key = std::toupper(keyName[0]);
|
||||||
|
|
||||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
|
||||||
|
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
||||||
win->m_pressedKeys.push_back(key);
|
win->m_pressedKeys.push_back(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
win->processEvent();
|
win->processEvent();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user