mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
feat(input): add KeyAction::REPEAT for key repeat events
Add a new REPEAT value to the KeyAction enum and update the input callbacks to map GLFW_REPEAT actions to the new value instead of treating them as press.
This commit is contained in:
@@ -123,5 +123,5 @@ enum class Key {
|
|||||||
NUMPAD_DECIMAL, // .
|
NUMPAD_DECIMAL, // .
|
||||||
NUMPAD_ENTER
|
NUMPAD_ENTER
|
||||||
};
|
};
|
||||||
enum class KeyAction { PRESS, RELEASE };
|
enum class KeyAction { PRESS, RELEASE, REPEAT };
|
||||||
} // namespace Cubed
|
} // namespace Cubed
|
||||||
12
src/app.cpp
12
src/app.cpp
@@ -521,10 +521,12 @@ void App::key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
if (action == GLFW_PRESS) {
|
||||||
act = KeyAction::PRESS;
|
act = KeyAction::PRESS;
|
||||||
} else {
|
} else if (action == GLFW_RELEASE) {
|
||||||
act = KeyAction::RELEASE;
|
act = KeyAction::RELEASE;
|
||||||
|
} else {
|
||||||
|
act = KeyAction::REPEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
app->dispatch_event(KeyEvent{pkey, act});
|
app->dispatch_event(KeyEvent{pkey, act});
|
||||||
@@ -570,10 +572,12 @@ void App::mouse_button_callback(GLFWwindow* window, int button, int action,
|
|||||||
Logger::error("Unknown Mouse Button {}", button);
|
Logger::error("Unknown Mouse Button {}", button);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
if (action == GLFW_PRESS) {
|
||||||
act = KeyAction::PRESS;
|
act = KeyAction::PRESS;
|
||||||
} else {
|
} else if (action == GLFW_RELEASE) {
|
||||||
act = KeyAction::RELEASE;
|
act = KeyAction::RELEASE;
|
||||||
|
} else {
|
||||||
|
act = KeyAction::REPEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
app->dispatch_event(MouseButtonEvent{key, act});
|
app->dispatch_event(MouseButtonEvent{key, act});
|
||||||
|
|||||||
Reference in New Issue
Block a user