mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-05-02 10:33:57 +00:00
Suppress movement input during 3rd-person camera touch gestures
This commit is contained in:
parent
a5b2ea0ce9
commit
f697524187
@ -632,6 +632,15 @@ void LegoInputManager::RemoveJoystick(SDL_JoystickID p_joystickID)
|
|||||||
|
|
||||||
MxBool LegoInputManager::HandleTouchEvent(SDL_Event* p_event, TouchScheme p_touchScheme)
|
MxBool LegoInputManager::HandleTouchEvent(SDL_Event* p_event, TouchScheme p_touchScheme)
|
||||||
{
|
{
|
||||||
|
static SDL_FingerID g_finger = (SDL_FingerID) 0;
|
||||||
|
|
||||||
|
if (Extension<MultiplayerExt>::Call(IsTouchInputSuppressed).value_or(FALSE)) {
|
||||||
|
g_finger = 0;
|
||||||
|
m_touchVirtualThumb = {0, 0};
|
||||||
|
m_touchFlags.clear();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
const SDL_TouchFingerEvent& event = p_event->tfinger;
|
const SDL_TouchFingerEvent& event = p_event->tfinger;
|
||||||
m_touchScheme = p_touchScheme;
|
m_touchScheme = p_touchScheme;
|
||||||
|
|
||||||
@ -667,8 +676,6 @@ MxBool LegoInputManager::HandleTouchEvent(SDL_Event* p_event, TouchScheme p_touc
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case e_gamepad: {
|
case e_gamepad: {
|
||||||
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 (!g_finger) {
|
if (!g_finger) {
|
||||||
|
|||||||
@ -67,6 +67,10 @@ class MultiplayerExt {
|
|||||||
// Forwards SDL events to the third-person camera for orbit controls.
|
// Forwards SDL events to the third-person camera for orbit controls.
|
||||||
static void HandleSDLEvent(SDL_Event* p_event);
|
static void HandleSDLEvent(SDL_Event* p_event);
|
||||||
|
|
||||||
|
// Returns TRUE when a multi-touch camera gesture is active and touch
|
||||||
|
// movement input should be suppressed.
|
||||||
|
static MxBool IsTouchInputSuppressed();
|
||||||
|
|
||||||
static void SetNetworkManager(Multiplayer::NetworkManager* p_networkManager);
|
static void SetNetworkManager(Multiplayer::NetworkManager* p_networkManager);
|
||||||
static Multiplayer::NetworkManager* GetNetworkManager();
|
static Multiplayer::NetworkManager* GetNetworkManager();
|
||||||
|
|
||||||
@ -93,6 +97,7 @@ constexpr auto HandleBeforeSaveLoad = &MultiplayerExt::HandleBeforeSaveLoad;
|
|||||||
constexpr auto HandleSaveLoaded = &MultiplayerExt::HandleSaveLoaded;
|
constexpr auto HandleSaveLoaded = &MultiplayerExt::HandleSaveLoaded;
|
||||||
constexpr auto CheckRejected = &MultiplayerExt::CheckRejected;
|
constexpr auto CheckRejected = &MultiplayerExt::CheckRejected;
|
||||||
constexpr auto HandleSDLEvent = &MultiplayerExt::HandleSDLEvent;
|
constexpr auto HandleSDLEvent = &MultiplayerExt::HandleSDLEvent;
|
||||||
|
constexpr auto IsTouchInputSuppressed = &MultiplayerExt::IsTouchInputSuppressed;
|
||||||
#else
|
#else
|
||||||
constexpr decltype(&MultiplayerExt::HandleCreate) HandleCreate = nullptr;
|
constexpr decltype(&MultiplayerExt::HandleCreate) HandleCreate = nullptr;
|
||||||
constexpr decltype(&MultiplayerExt::HandleWorldEnable) HandleWorldEnable = nullptr;
|
constexpr decltype(&MultiplayerExt::HandleWorldEnable) HandleWorldEnable = nullptr;
|
||||||
@ -108,6 +113,7 @@ constexpr decltype(&MultiplayerExt::HandleBeforeSaveLoad) HandleBeforeSaveLoad =
|
|||||||
constexpr decltype(&MultiplayerExt::HandleSaveLoaded) HandleSaveLoaded = nullptr;
|
constexpr decltype(&MultiplayerExt::HandleSaveLoaded) HandleSaveLoaded = nullptr;
|
||||||
constexpr decltype(&MultiplayerExt::CheckRejected) CheckRejected = nullptr;
|
constexpr decltype(&MultiplayerExt::CheckRejected) CheckRejected = nullptr;
|
||||||
constexpr decltype(&MultiplayerExt::HandleSDLEvent) HandleSDLEvent = nullptr;
|
constexpr decltype(&MultiplayerExt::HandleSDLEvent) HandleSDLEvent = nullptr;
|
||||||
|
constexpr decltype(&MultiplayerExt::IsTouchInputSuppressed) IsTouchInputSuppressed = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}; // namespace Extensions
|
}; // namespace Extensions
|
||||||
|
|||||||
@ -55,6 +55,7 @@ class ThirdPersonCamera {
|
|||||||
|
|
||||||
// Free camera input handling
|
// Free camera input handling
|
||||||
void HandleSDLEvent(SDL_Event* p_event);
|
void HandleSDLEvent(SDL_Event* p_event);
|
||||||
|
bool IsTouchGestureActive() const { return m_touchGestureActive; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Orbit camera helpers
|
// Orbit camera helpers
|
||||||
@ -96,6 +97,7 @@ class ThirdPersonCamera {
|
|||||||
float m_orbitDistance;
|
float m_orbitDistance;
|
||||||
|
|
||||||
// Touch gesture tracking
|
// Touch gesture tracking
|
||||||
|
bool m_touchGestureActive = false;
|
||||||
struct TouchState {
|
struct TouchState {
|
||||||
SDL_FingerID id[2];
|
SDL_FingerID id[2];
|
||||||
float x[2], y[2];
|
float x[2], y[2];
|
||||||
|
|||||||
@ -308,6 +308,15 @@ void MultiplayerExt::HandleSDLEvent(SDL_Event* p_event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MxBool MultiplayerExt::IsTouchInputSuppressed()
|
||||||
|
{
|
||||||
|
if (s_networkManager && s_networkManager->GetThirdPersonCamera().IsActive()) {
|
||||||
|
return s_networkManager->GetThirdPersonCamera().IsTouchGestureActive() ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
MxBool MultiplayerExt::CheckRejected()
|
MxBool MultiplayerExt::CheckRejected()
|
||||||
{
|
{
|
||||||
if (s_networkManager && s_networkManager->WasRejected()) {
|
if (s_networkManager && s_networkManager->WasRejected()) {
|
||||||
|
|||||||
@ -558,6 +558,7 @@ void ThirdPersonCamera::HandleSDLEvent(SDL_Event* p_event)
|
|||||||
m_touch.count++;
|
m_touch.count++;
|
||||||
|
|
||||||
if (m_touch.count == 2) {
|
if (m_touch.count == 2) {
|
||||||
|
m_touchGestureActive = true;
|
||||||
float dx = m_touch.x[1] - m_touch.x[0];
|
float dx = m_touch.x[1] - m_touch.x[0];
|
||||||
float dy = m_touch.y[1] - m_touch.y[0];
|
float dy = m_touch.y[1] - m_touch.y[0];
|
||||||
m_touch.initialPinchDist = SDL_sqrtf(dx * dx + dy * dy);
|
m_touch.initialPinchDist = SDL_sqrtf(dx * dx + dy * dy);
|
||||||
@ -618,6 +619,9 @@ void ThirdPersonCamera::HandleSDLEvent(SDL_Event* p_event)
|
|||||||
m_touch.y[0] = m_touch.y[1];
|
m_touch.y[0] = m_touch.y[1];
|
||||||
}
|
}
|
||||||
m_touch.count--;
|
m_touch.count--;
|
||||||
|
if (m_touch.count == 0) {
|
||||||
|
m_touchGestureActive = false;
|
||||||
|
}
|
||||||
m_touch.initialPinchDist = 0.0f;
|
m_touch.initialPinchDist = 0.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user