Update legoinputmanager.cpp

This commit is contained in:
Christian Semmler 2025-07-16 00:09:38 +02:00 committed by GitHub
parent 797aac1410
commit bf354523ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -617,25 +617,25 @@ MxBool LegoInputManager::HandleTouchEvent(SDL_Event* p_event, TouchScheme p_touc
} }
break; break;
case e_gamepad: { case e_gamepad: {
static SDL_FingerID finger = (SDL_FingerID) 0; static SDL_FingerID g_finger = (SDL_FingerID) 0;
switch (p_event->type) { switch (p_event->type) {
case SDL_EVENT_FINGER_DOWN: case SDL_EVENT_FINGER_DOWN:
if (!finger) { if (!g_finger) {
finger = event.fingerID; g_finger = event.fingerID;
m_touchVirtualThumb = {0, 0}; m_touchVirtualThumb = {0, 0};
m_touchVirtualThumbOrigin = {event.x, event.y}; m_touchVirtualThumbOrigin = {event.x, event.y};
} }
break; break;
case SDL_EVENT_FINGER_UP: case SDL_EVENT_FINGER_UP:
if (event.fingerID == finger) { if (event.fingerID == g_finger) {
finger = 0; g_finger = 0;
m_touchVirtualThumb = {0, 0}; m_touchVirtualThumb = {0, 0};
m_touchVirtualThumbOrigin = {0, 0}; m_touchVirtualThumbOrigin = {0, 0};
} }
break; break;
case SDL_EVENT_FINGER_MOTION: case SDL_EVENT_FINGER_MOTION:
if (event.fingerID == finger) { if (event.fingerID == g_finger) {
const float thumbstickRadius = 0.25f; const float thumbstickRadius = 0.25f;
const float deltaX = const float deltaX =
SDL_clamp(event.x - m_touchVirtualThumbOrigin.x, -thumbstickRadius, thumbstickRadius); SDL_clamp(event.x - m_touchVirtualThumbOrigin.x, -thumbstickRadius, thumbstickRadius);