Browse Source

multi touch could be disabled

dmuratshin 9 years ago
parent
commit
62097f9d38
2 changed files with 18 additions and 1 deletions
  1. 13 0
      oxygine/src/Input.cpp
  2. 5 1
      oxygine/src/Input.h

+ 13 - 0
oxygine/src/Input.cpp

@@ -17,6 +17,9 @@ namespace oxygine
 
     void Input::sendPointerButtonEvent(spStage stage, MouseButton button, float x, float y, float pressure, int type, PointerState* ps)
     {
+        if (!_multiTouch && ps->getIndex() != 1 && ps != &_pointerMouse)
+            return;
+        
         Vector2 p(x, y);
 
         TouchEvent me(type, true, p);
@@ -43,6 +46,10 @@ namespace oxygine
 
     void Input::sendPointerMotionEvent(spStage stage, float x, float y, float pressure, PointerState* ps)
     {
+        
+        if (!_multiTouch && ps->getIndex() != 1 && ps != &_pointerMouse)
+            return;
+        
         TouchEvent me(TouchEvent::MOVE, true, Vector2(x, y));
         me.index = ps->getIndex();
         me.pressure = pressure;
@@ -69,6 +76,7 @@ namespace oxygine
         for (int i = 0; i < MAX_TOUCHES; ++i)
             _pointers[i].init(i + 1);
         memset(_ids, 0, sizeof(_ids));
+        _multiTouch = true;
     }
 
     Input::~Input()
@@ -79,6 +87,11 @@ namespace oxygine
     void Input::cleanup()
     {
     }
+    
+    void Input::multiTouchEnabled(bool en)
+    {
+        _multiTouch = en;
+    }
 
     PointerState* Input::getTouchByIndex(int index)
     {

+ 5 - 1
oxygine/src/Input.h

@@ -21,6 +21,8 @@ namespace oxygine
         ~Input();
 
         void cleanup();
+        
+        void multiTouchEnabled(bool en);
 
         /**id should be in range [1, MAX_TOUCHES]*/
         PointerState* getTouchByIndex(int index);
@@ -41,5 +43,7 @@ namespace oxygine
         void sendPointerButtonEvent(spStage, MouseButton button, float x, float y, float pressure, int type, PointerState*);
         void sendPointerMotionEvent(spStage, float x, float y, float pressure, PointerState*);
         void sendPointerWheelEvent(spStage, int scroll, PointerState*);
+        
+        bool _multiTouch;
     };
-}
+}