Browse Source

desktop compatibility: redirect touch to Button::Left

pull/518/head
mgood7123 5 years ago
parent
commit
333e7a7a57
  1. 38
      src/Magnum/Platform/WindowlessAndroidApplication.h

38
src/Magnum/Platform/WindowlessAndroidApplication.h

@ -680,16 +680,10 @@ class WindowlessAndroidApplication::MouseEvent: public InputEvent {
None = 0, None = 0,
/** /**
* Left mouse button. Note that this button is not set if only * Left mouse button. Note that this button is set for
* touch or stylus event occured. * compatibility with Desktop
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/ */
#if defined(DOXYGEN_GENERATING_OUTPUT) || __ANDROID_API__ >= 14
Left = MotionEventSerializer::MOTION_EVENT_BUTTON_PRIMARY, Left = MotionEventSerializer::MOTION_EVENT_BUTTON_PRIMARY,
#else
Left = 1 << 0,
#endif
/** /**
* Middle mouse button or second stylus button * Middle mouse button or second stylus button
@ -716,11 +710,10 @@ class WindowlessAndroidApplication::MouseEvent: public InputEvent {
/** @brief Button */ /** @brief Button */
Button button() { Button button() {
#if __ANDROID_API__ >= 14 // redirect touch events to button left
return Button(button_state); // for compatibility with desktop
#else // button_state 0 is a touch on the touchscreen
return Button::None; return button_state == 0 ? Button::Left : Button(button_state);
#endif
} }
/** @brief Position */ /** @brief Position */
@ -751,16 +744,10 @@ class WindowlessAndroidApplication::MouseMoveEvent: public InputEvent {
*/ */
enum class Button: std::int32_t { enum class Button: std::int32_t {
/** /**
* Left mouse button. Note that this button is not set if only * Left mouse button. Note that this button set for
* touch or stylus event occured. * compatibility with desktop
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/ */
#if defined(DOXYGEN_GENERATING_OUTPUT) || __ANDROID_API__ >= 14
Left = MotionEventSerializer::MOTION_EVENT_BUTTON_PRIMARY, Left = MotionEventSerializer::MOTION_EVENT_BUTTON_PRIMARY,
#else
Left = 1 << 0,
#endif
/** /**
* Middle mouse button or second stylus button * Middle mouse button or second stylus button
@ -810,11 +797,10 @@ class WindowlessAndroidApplication::MouseMoveEvent: public InputEvent {
/** @brief Mouse buttons */ /** @brief Mouse buttons */
Buttons buttons() const { Buttons buttons() const {
#if __ANDROID_API__ >= 14 // redirect touch events to button left
return Button(button_state); // for compatibility with desktop
#else // button_state 0 is a touch on the touchscreen
return {}; return button_state == 0 ? Button::Left : Button(button_state);
#endif
} }
private: private:

Loading…
Cancel
Save