]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/android/mouse.cpp
Include the matching header first in .cpp files
[libs/gui.git] / source / input / android / mouse.cpp
index b16b6be2331077f48e57ddc2ee4deadde932ea01..5c6b72a8eb8fe401b8c3ac523f655d3003ff8182 100644 (file)
@@ -1,5 +1,6 @@
-#include <msp/graphics/window_private.h>
 #include "mouse.h"
+#include <msp/graphics/window_private.h>
+#include "keys.h"
 
 namespace Msp {
 namespace Input {
@@ -10,6 +11,10 @@ void Mouse::input_event(const Graphics::Window::Event &event)
        if(type!=AINPUT_EVENT_TYPE_MOTION)
                return;
 
+       int source = AInputEvent_getSource(event.aevent);
+       if(window.get_touch_input() && source!=AINPUT_SOURCE_MOUSE && source!=AINPUT_SOURCE_TOUCHPAD)
+               return;
+
        /* Emulate a mouse with the touch events of a single finger.  If more
        fingers appear while the first one is held down, they are ignored, even if
        the first finger is released. */
@@ -28,8 +33,8 @@ void Mouse::input_event(const Graphics::Window::Event &event)
        {
                float x = AMotionEvent_getX(event.aevent, pointer_zero);
                float y = AMotionEvent_getY(event.aevent, pointer_zero);
-               set_axis_value(0, x*2/window.get_width()-1, true);
-               set_axis_value(1, 1-y*2/window.get_height(), true);
+               set_axis_value(MOUSE_X_AXIS, x*2/window.get_width()-1, true);
+               set_axis_value(MOUSE_Y_AXIS, 1-y*2/window.get_height(), true);
        }
 
        switch(action)
@@ -39,7 +44,7 @@ void Mouse::input_event(const Graphics::Window::Event &event)
        case AMOTION_EVENT_ACTION_POINTER_DOWN:
        case AMOTION_EVENT_ACTION_POINTER_UP:
                if(action_pointer==0)
-                       set_button_state(1, action==AMOTION_EVENT_ACTION_DOWN, true);
+                       set_button_state(MOUSE_LEFT, action==AMOTION_EVENT_ACTION_DOWN, true);
                break;
        default:;
        }