瀏覽代碼

2 finger rclick block adwmap scrolling and disable for iOS

Andrii Danylchenko 2 年之前
父節點
當前提交
c24b89fe06
共有 3 個文件被更改,包括 12 次插入11 次删除
  1. 10 10
      client/gui/CGuiHandler.cpp
  2. 1 0
      client/gui/CGuiHandler.h
  3. 1 1
      client/windows/CAdvmapInterface.cpp

+ 10 - 10
client/gui/CGuiHandler.cpp

@@ -206,9 +206,6 @@ void CGuiHandler::handleEvents()
 	}
 }
 
-bool multifinger = false;
-int lastFingerCount;
-
 void convertTouch(SDL_Event * current)
 {
 	int rLogicalWidth, rLogicalHeight;
@@ -358,7 +355,7 @@ void CGuiHandler::handleCurrentEvent()
 	}
 	else if(current->type == SDL_MOUSEBUTTONUP)
 	{
-		if(!multifinger || lastFingerCount < 1)
+		if(!multifinger)
 		{
 			switch(current->button.button)
 			{
@@ -374,13 +371,14 @@ void CGuiHandler::handleCurrentEvent()
 			}
 		}
 	}
+#ifndef VCMI_IOS
 	else if(current->type == SDL_FINGERDOWN)
 	{
-		lastFingerCount = SDL_GetNumTouchFingers(current->tfinger.touchId);
+		auto fingerCount = SDL_GetNumTouchFingers(current->tfinger.touchId);
 
-		multifinger = lastFingerCount > 1;
+		multifinger = fingerCount > 1;
 
-		if(lastFingerCount == 2)
+		if(fingerCount == 2)
 		{
 			convertTouch(current);
 			handleMouseMotion();
@@ -389,16 +387,17 @@ void CGuiHandler::handleCurrentEvent()
 	}
 	else if(current->type == SDL_FINGERUP)
 	{
-		lastFingerCount = SDL_GetNumTouchFingers(current->tfinger.touchId);
+		auto fingerCount = SDL_GetNumTouchFingers(current->tfinger.touchId);
 
 		if(multifinger)
 		{
-			multifinger = false;
 			convertTouch(current);
 			handleMouseMotion();
 			handleMouseButtonClick(rclickable, EIntObjMouseBtnType::RIGHT, false);
+			multifinger = fingerCount != 0;
 		}
 	}
+#endif //VCMI_IOS
 
 	current = nullptr;
 } //event end
@@ -527,7 +526,8 @@ void CGuiHandler::renderFrame()
 
 
 CGuiHandler::CGuiHandler()
-	: lastClick(-500, -500),lastClickTime(0), defActionsDef(0), captureChildren(false)
+	: lastClick(-500, -500),lastClickTime(0), defActionsDef(0), captureChildren(false),
+    multifinger(false)
 {
 	continueEventHandling = true;
 	curInt = nullptr;

+ 1 - 0
client/gui/CGuiHandler.h

@@ -101,6 +101,7 @@ public:
 
 	Point lastClick;
 	unsigned lastClickTime;
+	bool multifinger;
 
 	ui8 defActionsDef; //default auto actions
 	bool captureChildren; //all newly created objects will get their parents from stack and will be added to parents children list

+ 1 - 1
client/windows/CAdvmapInterface.cpp

@@ -180,7 +180,7 @@ void CTerrainRect::mouseMoved(const SDL_MouseMotionEvent & sEvent)
 void CTerrainRect::handleSwipeMove(const SDL_MouseMotionEvent & sEvent)
 {
 #if defined(VCMI_ANDROID) || defined(VCMI_IOS)
-	if(sEvent.state == 0) // any "button" is enough on mobile
+	if(sEvent.state == 0 || GH.multifinger) // any "button" is enough on mobile
 #else
 	if((sEvent.state & SDL_BUTTON_MMASK) == 0) // swipe only works with middle mouse on other platforms
 #endif