1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Remove not supported method, allow relative mode for iOS

This commit is contained in:
Andrii Danylchenko 2023-01-18 18:15:04 +02:00
parent 6c843bce0b
commit 9a765e5f67
2 changed files with 14 additions and 5 deletions

View File

@ -437,11 +437,13 @@ int main(int argc, char * argv[])
SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1");
#endif
#ifdef SDL_HINT_MOUSE_TOUCH_EVENTS
if(GH.isPointerRelativeMode)
{
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
}
#endif
#ifndef VCMI_NO_THREADED_LOAD
//we can properly play intro only in the main thread, so we have to move loading to the separate thread

View File

@ -268,12 +268,17 @@ void CGuiHandler::fakeMouseButtonEventRelativeMode(bool down, bool right)
sme.x = CCS->curh->xpos;
sme.y = CCS->curh->ypos;
int windowX, windowY;
float xScale, yScale;
int w, h, rLogicalWidth, rLogicalHeight;
SDL_RenderLogicalToWindow(mainRenderer, sme.x, sme.y, &windowX, &windowY);
SDL_GetWindowSize(mainWindow, &w, &h);
SDL_RenderGetLogicalSize(mainRenderer, &rLogicalWidth, &rLogicalHeight);
SDL_RenderGetScale(mainRenderer, &xScale, &yScale);
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_WarpMouse(windowX, windowY);
SDL_WarpMouse(
(int)(sme.x * xScale) + (w - rLogicalWidth * xScale) / 2,
(int)(sme.y * yScale + (h - rLogicalHeight * yScale) / 2));
SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
event.button = sme;
@ -430,7 +435,6 @@ void CGuiHandler::handleCurrentEvent()
}
}
}
#ifndef VCMI_IOS
else if(current->type == SDL_FINGERMOTION)
{
if(isPointerRelativeMode)
@ -453,12 +457,14 @@ void CGuiHandler::handleCurrentEvent()
fakeMouseButtonEventRelativeMode(true, isRightClick);
}
}
#ifndef VCMI_IOS
else if(fingerCount == 2)
{
convertTouchToMouse(current);
handleMouseMotion();
handleMouseButtonClick(rclickable, EIntObjMouseBtnType::RIGHT, true);
}
#endif //VCMI_IOS
}
else if(current->type == SDL_FINGERUP)
{
@ -473,6 +479,7 @@ void CGuiHandler::handleCurrentEvent()
fakeMouseButtonEventRelativeMode(false, isRightClick);
}
}
#ifndef VCMI_IOS
else if(multifinger)
{
convertTouchToMouse(current);
@ -480,8 +487,8 @@ void CGuiHandler::handleCurrentEvent()
handleMouseButtonClick(rclickable, EIntObjMouseBtnType::RIGHT, false);
multifinger = fingerCount != 0;
}
}
#endif //VCMI_IOS
}
current = nullptr;
} //event end