From 65be786140bf0f59fae96a918b91a9a3e0244904 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Fri, 3 Nov 2023 02:47:08 +0200 Subject: [PATCH] * Fix SDL related touch issues. --- platforms/sdl/AppPlatform_sdlbase.hpp | 2 ++ platforms/sdl/main.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/platforms/sdl/AppPlatform_sdlbase.hpp b/platforms/sdl/AppPlatform_sdlbase.hpp index 1d6423e..6a0b494 100644 --- a/platforms/sdl/AppPlatform_sdlbase.hpp +++ b/platforms/sdl/AppPlatform_sdlbase.hpp @@ -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); diff --git a/platforms/sdl/main.cpp b/platforms/sdl/main.cpp index 1099339..62cbec0 100644 --- a/platforms/sdl/main.cpp +++ b/platforms/sdl/main.cpp @@ -14,6 +14,7 @@ typedef AppPlatform_sdl UsedAppPlatform; #endif #include "client/app/NinecraftApp.hpp" +#include "client/player/input/Multitouch.hpp" #ifdef __EMSCRIPTEN__ #include @@ -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; }