Browse Source

Platform: mouse click count is not available in Emscripten.

pull/158/head
Vladimír Vondruš 10 years ago
parent
commit
93cf86a076
  1. 13
      src/Magnum/Platform/Sdl2Application.cpp
  2. 15
      src/Magnum/Platform/Sdl2Application.h

13
src/Magnum/Platform/Sdl2Application.cpp

@ -374,15 +374,24 @@ void Sdl2Application::mainLoop() {
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: { case SDL_MOUSEBUTTONUP: {
MouseEvent e(static_cast<MouseEvent::Button>(event.button.button), {event.button.x, event.button.y}, event.button.clicks); MouseEvent e(static_cast<MouseEvent::Button>(event.button.button), {event.button.x, event.button.y}
#ifndef CORRADE_TARGET_EMSCRIPTEN
, event.button.clicks
#endif
);
event.type == SDL_MOUSEBUTTONDOWN ? mousePressEvent(e) : mouseReleaseEvent(e); event.type == SDL_MOUSEBUTTONDOWN ? mousePressEvent(e) : mouseReleaseEvent(e);
} break; } break;
case SDL_MOUSEWHEEL: { case SDL_MOUSEWHEEL: {
MouseEvent e(event.wheel.y > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}, 0); MouseEvent e(event.wheel.y > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}
#ifndef CORRADE_TARGET_EMSCRIPTEN
, 0
#endif
);
mousePressEvent(e); mousePressEvent(e);
break; break;
} }
case SDL_MOUSEMOTION: { case SDL_MOUSEMOTION: {
MouseMoveEvent e({event.motion.x, event.motion.y}, {event.motion.xrel, event.motion.yrel}, static_cast<MouseMoveEvent::Button>(event.motion.state)); MouseMoveEvent e({event.motion.x, event.motion.y}, {event.motion.xrel, event.motion.yrel}, static_cast<MouseMoveEvent::Button>(event.motion.state));
mouseMoveEvent(e); mouseMoveEvent(e);

15
src/Magnum/Platform/Sdl2Application.h

@ -1152,12 +1152,15 @@ class Sdl2Application::MouseEvent: public Sdl2Application::InputEvent {
*/ */
constexpr Vector2i position() const { return _position; } constexpr Vector2i position() const { return _position; }
#ifndef CORRADE_TARGET_EMSCRIPTEN
/** /**
* @brief Click count * @brief Click count
* *
* Ignored for wheel events. * Ignored for wheel events.
* @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/ */
constexpr Int clickCount() const { return _clickCount; } constexpr Int clickCount() const { return _clickCount; }
#endif
/** /**
* @brief Modifiers * @brief Modifiers
@ -1167,11 +1170,21 @@ class Sdl2Application::MouseEvent: public Sdl2Application::InputEvent {
Modifiers modifiers(); Modifiers modifiers();
private: private:
constexpr MouseEvent(Button button, const Vector2i& position, Int clickCount): _button{button}, _position{position}, _clickCount{clickCount}, _modifiersLoaded{false} {} constexpr MouseEvent(Button button, const Vector2i& position
#ifndef CORRADE_TARGET_EMSCRIPTEN
, Int clickCount
#endif
): _button{button}, _position{position},
#ifndef CORRADE_TARGET_EMSCRIPTEN
_clickCount{clickCount},
#endif
_modifiersLoaded{false} {}
const Button _button; const Button _button;
const Vector2i _position; const Vector2i _position;
#ifndef CORRADE_TARGET_EMSCRIPTEN
const Int _clickCount; const Int _clickCount;
#endif
bool _modifiersLoaded; bool _modifiersLoaded;
Modifiers _modifiers; Modifiers _modifiers;
}; };

Loading…
Cancel
Save