Add mouse button type
This commit is contained in:
parent
9757675513
commit
8aeb9c8435
@ -59,16 +59,18 @@ const std::vector<UserAction> &UserInput::GetActions() {
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
||||
SDL_MouseButtonEvent mouse_event = event.button;
|
||||
if (mouse_event.button == 1) {
|
||||
MouseButton button = static_cast<MouseButton>(mouse_event.button);
|
||||
if (button == MouseButton::LEFT) {
|
||||
LOG_DEBUG("Mouse down: ", mouse_event.x, ", ", mouse_event.y);
|
||||
m_Actions.emplace_back(UserAction::Type::SET_MOVE_TARGET,
|
||||
WindowPos{mouse_event.x, mouse_event.y});
|
||||
} else if (mouse_event.button == 2) {
|
||||
} else if (button == MouseButton::MIDDLE) {
|
||||
mouse_pan = true;
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) {
|
||||
SDL_MouseButtonEvent mouse_event = event.button;
|
||||
if (mouse_event.button == 2) {
|
||||
MouseButton button = static_cast<MouseButton>(mouse_event.button);
|
||||
if (button == MouseButton::MIDDLE) {
|
||||
mouse_pan = false;
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_MOUSE_MOTION) {
|
||||
|
@ -7,6 +7,9 @@
|
||||
#include "log.hpp"
|
||||
#include "math.hpp"
|
||||
|
||||
// Seems like SDL doesn't have named constants for mouse button
|
||||
enum class MouseButton { LEFT = 1, MIDDLE, RIGHT };
|
||||
|
||||
class UserAction {
|
||||
public:
|
||||
enum class Type { NONE, EXIT, SET_MOVE_TARGET, SELECT_PATHFINDER, CAMERA_PAN, CAMERA_ZOOM };
|
||||
|
Loading…
x
Reference in New Issue
Block a user