Browse Source

Platform: fix AndroidApplication for Android < 4.0.

pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
733de78b34
  1. 64
      src/Magnum/Platform/AndroidApplication.h

64
src/Magnum/Platform/AndroidApplication.h

@ -433,18 +433,46 @@ class AndroidApplication::MouseEvent: public InputEvent {
/** /**
* Left mouse button. Note that this button is not set if only * Left mouse button. Note that this button is not set if only
* touch or stylus event occured. * touch or stylus event occured.
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/ */
#if __ANDROID_API__ >= 14
Left = AMOTION_EVENT_BUTTON_PRIMARY, Left = AMOTION_EVENT_BUTTON_PRIMARY,
#else
Left = 1 << 0,
#endif
/** Middle mouse button or second stylus button */ /**
* Middle mouse button or second stylus button
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/
#if __ANDROID_API__ >= 14
Middle = AMOTION_EVENT_BUTTON_TERTIARY, Middle = AMOTION_EVENT_BUTTON_TERTIARY,
#else
Middle = 1 << 1,
#endif
/** Right mouse button or first stylus button */ /**
* Right mouse button or first stylus button
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/
#if __ANDROID_API__ >= 14
Right = AMOTION_EVENT_BUTTON_SECONDARY Right = AMOTION_EVENT_BUTTON_SECONDARY
#else
Right = 1 << 2
#endif
}; };
/** @brief Button */ /** @brief Button */
Button button() { return Button(AMotionEvent_getButtonState(_event)); } Button button() {
#if __ANDROID_API__ >= 14
return Button(AMotionEvent_getButtonState(_event));
#else
return Button::None;
#endif
}
/** @brief Position */ /** @brief Position */
Vector2i position() { Vector2i position() {
@ -474,14 +502,36 @@ class AndroidApplication::MouseMoveEvent: public InputEvent {
/** /**
* Left mouse button. Note that this button is not set if only * Left mouse button. Note that this button is not set if only
* touch or stylus event occured. * touch or stylus event occured.
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/ */
#if __ANDROID_API__ >= 14
Left = AMOTION_EVENT_BUTTON_PRIMARY, Left = AMOTION_EVENT_BUTTON_PRIMARY,
#else
Left = 1 << 0,
#endif
/** Middle mouse button or second stylus button */ /**
* Middle mouse button or second stylus button
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/
#if __ANDROID_API__ >= 14
Middle = AMOTION_EVENT_BUTTON_TERTIARY, Middle = AMOTION_EVENT_BUTTON_TERTIARY,
#else
Middle = 1 << 1,
#endif
/** Right mouse button or first stylus button */ /**
* Right mouse button or first stylus button
* @attention Available since Android 4.0 (API level 14), not
* detectable in earlier versions.
*/
#if __ANDROID_API__ >= 14
Right = AMOTION_EVENT_BUTTON_SECONDARY Right = AMOTION_EVENT_BUTTON_SECONDARY
#else
Right = 1 << 2
#endif
}; };
/** /**
@ -499,7 +549,11 @@ class AndroidApplication::MouseMoveEvent: public InputEvent {
/** @brief Mouse buttons */ /** @brief Mouse buttons */
Buttons buttons() const { Buttons buttons() const {
#if __ANDROID_API__ >= 14
return Button(AMotionEvent_getButtonState(_event)); return Button(AMotionEvent_getButtonState(_event));
#else
return {};
#endif
} }
private: private:

Loading…
Cancel
Save