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