* Fix SDL related touch issues.

This commit is contained in:
iProgramInCpp
2023-11-03 02:47:08 +02:00
parent c5f09f5a1c
commit 65be786140
2 changed files with 5 additions and 0 deletions

View File

@@ -38,6 +38,8 @@ public:
// Also add these to allow proper text input within the game.
bool shiftPressed() override;
void setShiftPressed(bool b, bool isLeft);
bool isTouchscreen() override { return false; }
static MouseButtonType GetMouseButtonType(SDL_Event event);
static bool GetMouseButtonState(SDL_Event event);

View File

@@ -14,6 +14,7 @@ typedef AppPlatform_sdl UsedAppPlatform;
#endif
#include "client/app/NinecraftApp.hpp"
#include "client/player/input/Multitouch.hpp"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
@@ -100,6 +101,7 @@ static void handle_events()
{
const float scale = g_fPointToPixelScale;
Mouse::feed(AppPlatform_sdlbase::GetMouseButtonType(event), AppPlatform_sdlbase::GetMouseButtonState(event), event.button.x * scale, event.button.y * scale);
Multitouch::feed(AppPlatform_sdlbase::GetMouseButtonType(event), AppPlatform_sdlbase::GetMouseButtonState(event), event.button.x * scale, event.button.y * scale, 0);
break;
}
case SDL_MOUSEMOTION:
@@ -108,6 +110,7 @@ static void handle_events()
float x = event.motion.x * scale;
float y = event.motion.y * scale;
Mouse::feed(BUTTON_NONE, false, x, y);
Multitouch::feed(BUTTON_NONE, false, x, y, 0);
g_pAppPlatform->setMouseDiff(event.motion.xrel * scale, event.motion.yrel * scale);
break;
}