diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-18 16:35:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-18 16:35:36 +0300 |
commit | 0d5fa0bc658e46269128bf23a9e981dfd9169de6 (patch) | |
tree | 913c8cb105ebfe8c37fa65a1a74b92e160e49364 | |
parent | 03c74387d37cefcc18e59db203d17d78cda40e8e (diff) | |
download | plus-0d5fa0bc658e46269128bf23a9e981dfd9169de6.tar.gz plus-0d5fa0bc658e46269128bf23a9e981dfd9169de6.tar.bz2 plus-0d5fa0bc658e46269128bf23a9e981dfd9169de6.tar.xz plus-0d5fa0bc658e46269128bf23a9e981dfd9169de6.zip |
Use mouseeventtype in mouseinput.
-rw-r--r-- | src/gui/gui.cpp | 10 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 20 | ||||
-rw-r--r-- | src/input/mouseinput.h | 22 | ||||
-rw-r--r-- | src/touchactions.cpp | 2 | ||||
-rw-r--r-- | src/touchmanager.cpp | 4 |
5 files changed, 23 insertions, 35 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index ab4ee5e19..b695b669b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -984,19 +984,19 @@ void Gui::handleMouseInput() #endif switch (mouseInput.getType()) { - case MouseInput::PRESSED: + case MouseEventType::PRESSED: handleMousePressed(mouseInput); break; - case MouseInput::RELEASED: + case MouseEventType::RELEASED: handleMouseReleased(mouseInput); break; - case MouseInput::MOVED: + case MouseEventType::MOVED: handleMouseMoved(mouseInput); break; - case MouseInput::WHEEL_MOVED_DOWN: + case MouseEventType::WHEEL_MOVED_DOWN: handleMouseWheelMovedDown(mouseInput); break; - case MouseInput::WHEEL_MOVED_UP: + case MouseEventType::WHEEL_MOVED_UP: handleMouseWheelMovedUp(mouseInput); break; default: diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index aa8824bbd..846cb34f4 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -166,9 +166,9 @@ void SDLInput::pushInput(const SDL_Event &event) #endif mouseInput.setButton(static_cast<uint32_t>(-1)); if (y > 0) - mouseInput.setType(MouseInput::WHEEL_MOVED_UP); + mouseInput.setType(MouseEventType::WHEEL_MOVED_UP); else - mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } @@ -204,12 +204,12 @@ void SDLInput::pushInput(const SDL_Event &event) #ifndef USE_SDL2 if (event.button.button == SDL_BUTTON_WHEELDOWN) - mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN); else if (event.button.button == SDL_BUTTON_WHEELUP) - mouseInput.setType(MouseInput::WHEEL_MOVED_UP); + mouseInput.setType(MouseEventType::WHEEL_MOVED_UP); else #endif - mouseInput.setType(MouseInput::PRESSED); + mouseInput.setType(MouseEventType::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -231,7 +231,7 @@ void SDLInput::pushInput(const SDL_Event &event) #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); - mouseInput.setType(MouseInput::RELEASED); + mouseInput.setType(MouseEventType::RELEASED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -252,7 +252,7 @@ void SDLInput::pushInput(const SDL_Event &event) #endif #endif mouseInput.setButton(MouseButton::EMPTY); - mouseInput.setType(MouseInput::MOVED); + mouseInput.setType(MouseEventType::MOVED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -272,7 +272,7 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setX(-1); mouseInput.setY(-1); mouseInput.setButton(MouseButton::EMPTY); - mouseInput.setType(MouseInput::MOVED); + mouseInput.setType(MouseEventType::MOVED); mMouseInputQueue.push(mouseInput); } } @@ -531,10 +531,10 @@ void SDLInput::simulateMouseClick(const int x, const int y, mouseInput.setY(y); mouseInput.setReal(x, y); mouseInput.setButton(button); - mouseInput.setType(MouseInput::PRESSED); + mouseInput.setType(MouseEventType::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); - mouseInput.setType(MouseInput::RELEASED); + mouseInput.setType(MouseEventType::RELEASED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h index 3e24543a8..284116db2 100644 --- a/src/input/mouseinput.h +++ b/src/input/mouseinput.h @@ -67,6 +67,7 @@ #include "input/mouseinput.h" #include "events/mousebutton.h" +#include "events/mouseeventtype.h" #include "localconsts.h" @@ -74,7 +75,7 @@ class MouseInput final { public: MouseInput() : - mType(0), + mType(MouseEventType::MOVED), mButton(MouseButton::EMPTY), mTimeStamp(0), mX(0), @@ -86,25 +87,12 @@ class MouseInput final ~MouseInput() { } - /** - * Mouse input event types. This enum partially corresponds - * to the enum with event types in MouseEvent for easy mapping. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP - }; - - void setType(unsigned int type) + void setType(MouseEventType::Type type) { mType = type; } - unsigned int getType() const + MouseEventType::Type getType() const { return mType; } @@ -176,7 +164,7 @@ class MouseInput final /** * Holds the type of the mouse input. */ - unsigned int mType; + MouseEventType::Type mType; /** * Holds the button of the mouse input. diff --git a/src/touchactions.cpp b/src/touchactions.cpp index d4f7d9f6e..17e9591af 100644 --- a/src/touchactions.cpp +++ b/src/touchactions.cpp @@ -109,7 +109,7 @@ impHandler(padClick) impHandler(padEvents) { - if (mouseInput.getType() == MouseInput::MOVED) + if (mouseInput.getType() == MouseEventType::MOVED) { if (padClicked) moveChar(mouseInput.getX(), mouseInput.getY()); diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 6158d1254..dbb1ea9b2 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -283,13 +283,13 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) switch (mouseInput.getType()) { - case MouseInput::PRESSED: + case MouseEventType::PRESSED: if (!item->eventPressed.empty()) executeAction(item->eventPressed); else if (item->funcPressed) item->funcPressed(event); break; - case MouseInput::RELEASED: + case MouseEventType::RELEASED: if (!item->eventReleased.empty()) executeAction(item->eventReleased); else if (item->funcReleased) |