mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
Touchscreen improvements
This commit is contained in:
@@ -207,7 +207,7 @@ bool GpSystemServices_Android::IsTouchscreen() const
|
||||
|
||||
bool GpSystemServices_Android::IsUsingMouseAsTouch() const
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsTextInputObstructive() const
|
||||
|
@@ -704,7 +704,7 @@ public:
|
||||
|
||||
bool Init();
|
||||
|
||||
static void TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY, bool obstructiveTextInput);
|
||||
void TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY, bool obstructiveTextInput);
|
||||
|
||||
void Run() override;
|
||||
void Shutdown() override;
|
||||
@@ -1100,6 +1100,9 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
|
||||
m_bgColor[2] = 0.f;
|
||||
m_bgColor[3] = 1.f;
|
||||
|
||||
// Stupid hack to detect mobile...
|
||||
m_isFullScreenDesired = m_properties.m_systemServices->IsTouchscreen();
|
||||
|
||||
const intmax_t periodNum = std::chrono::high_resolution_clock::period::num;
|
||||
const intmax_t periodDen = std::chrono::high_resolution_clock::period::den;
|
||||
|
||||
@@ -1207,7 +1210,6 @@ bool GpDisplayDriver_SDL_GL2::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void PostMouseEvent(IGpVOSEventQueue *eventQueue, GpMouseEventType_t eventType, GpMouseButton_t button, int32_t x, int32_t y, float pixelScaleX, float pixelScaleY)
|
||||
{
|
||||
if (GpVOSEvent *evt = eventQueue->QueueEvent())
|
||||
@@ -1228,6 +1230,21 @@ static void PostMouseEvent(IGpVOSEventQueue *eventQueue, GpMouseEventType_t even
|
||||
}
|
||||
}
|
||||
|
||||
static void PostTouchEvent(IGpVOSEventQueue *eventQueue, GpTouchEventType_t eventType, int32_t x, int32_t y, int64_t deviceID, int64_t fingerID)
|
||||
{
|
||||
if (GpVOSEvent *evt = eventQueue->QueueEvent())
|
||||
{
|
||||
evt->m_eventType = GpVOSEventTypes::kTouchInput;
|
||||
|
||||
GpTouchInputEvent &tEvent = evt->m_event.m_touchInputEvent;
|
||||
tEvent.m_deviceID = deviceID;
|
||||
tEvent.m_fingerID = fingerID;
|
||||
tEvent.m_x = x;
|
||||
tEvent.m_y = y;
|
||||
tEvent.m_eventType = eventType;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IdentifyVKey(const SDL_KeyboardEvent *keyEvt, GpKeyIDSubset_t &outSubset, GpKeyboardInputEvent::KeyUnion &outKey)
|
||||
{
|
||||
SDL_KeyCode keyCode = static_cast<SDL_KeyCode>(keyEvt->keysym.sym);
|
||||
@@ -1555,7 +1572,6 @@ void GpDisplayDriver_SDL_GL2::TranslateSDLMessage(const SDL_Event *msg, IGpVOSEv
|
||||
PostMouseEvent(eventQueue, GpMouseEventTypes::kMove, GpMouseButtons::kNone, mouseEvt->x, mouseEvt->y, pixelScaleX, pixelScaleY);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
@@ -1586,6 +1602,28 @@ void GpDisplayDriver_SDL_GL2::TranslateSDLMessage(const SDL_Event *msg, IGpVOSEv
|
||||
PostMouseEvent(eventQueue, evtType, mouseButton, mouseEvt->x, mouseEvt->y, pixelScaleX, pixelScaleY);
|
||||
}
|
||||
break;
|
||||
case SDL_FINGERUP:
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERMOTION:
|
||||
{
|
||||
const SDL_TouchFingerEvent *fingerEvt = reinterpret_cast<const SDL_TouchFingerEvent *>(msg);
|
||||
GpTouchEventType_t evtType = GpTouchEventTypes::kDown;
|
||||
|
||||
if (fingerEvt->type == SDL_FINGERUP)
|
||||
evtType = GpTouchEventTypes::kUp;
|
||||
else if (fingerEvt->type == SDL_FINGERDOWN)
|
||||
evtType = GpTouchEventTypes::kDown;
|
||||
else if (fingerEvt->type == SDL_FINGERMOTION)
|
||||
evtType = GpTouchEventTypes::kMove;
|
||||
else
|
||||
break;
|
||||
|
||||
float unnormalizedX = static_cast<float>(m_windowWidthVirtual) * fingerEvt->x;
|
||||
float unnormalizedY = static_cast<float>(m_windowHeightVirtual) * fingerEvt->y;
|
||||
|
||||
PostTouchEvent(eventQueue, evtType, static_cast<int32_t>(unnormalizedX), static_cast<int32_t>(unnormalizedY), fingerEvt->touchId, fingerEvt->fingerId);
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
const SDL_KeyboardEvent *keyEvt = reinterpret_cast<const SDL_KeyboardEvent *>(msg);
|
||||
|
@@ -366,25 +366,59 @@ namespace TouchScreenCtrlIDs
|
||||
{
|
||||
enum TouchScreenCtrlID
|
||||
{
|
||||
None,
|
||||
|
||||
MoveLeft,
|
||||
MoveRight,
|
||||
Flip,
|
||||
Bands,
|
||||
BatteryHelium,
|
||||
Movement,
|
||||
|
||||
Count,
|
||||
|
||||
Invalid,
|
||||
};
|
||||
};
|
||||
|
||||
typedef TouchScreenCtrlIDs::TouchScreenCtrlID TouchScreenCtrlID_t;
|
||||
|
||||
struct touchScreenFingerID
|
||||
{
|
||||
int64_t m_deviceID;
|
||||
int64_t m_fingerID;
|
||||
|
||||
touchScreenFingerID();
|
||||
touchScreenFingerID(int64_t deviceID, int64_t fingerID);
|
||||
|
||||
bool operator ==(const touchScreenFingerID &other) const;
|
||||
bool operator !=(const touchScreenFingerID &other) const;
|
||||
};
|
||||
|
||||
inline touchScreenFingerID::touchScreenFingerID()
|
||||
: m_fingerID(0)
|
||||
, m_deviceID(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline touchScreenFingerID::touchScreenFingerID(int64_t deviceID, int64_t fingerID)
|
||||
: m_fingerID(fingerID)
|
||||
, m_deviceID(deviceID)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool touchScreenFingerID::operator==(const touchScreenFingerID &other) const
|
||||
{
|
||||
return this->m_fingerID == other.m_fingerID && this->m_deviceID == other.m_deviceID;
|
||||
}
|
||||
|
||||
inline bool touchScreenFingerID::operator!=(const touchScreenFingerID &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fingerID;
|
||||
touchScreenFingerID tfingerID;
|
||||
Point point;
|
||||
TouchScreenCtrlID_t capturingControl;
|
||||
bool active;
|
||||
} touchScreenFingerState;
|
||||
|
||||
typedef struct
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "PLDialogs.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "DialogManager.h"
|
||||
#include "Environ.h"
|
||||
#include "Externs.h"
|
||||
#include "InputManager.h"
|
||||
#include "MainWindow.h"
|
||||
@@ -39,6 +40,8 @@ Boolean isEscPauseKey, paused, batteryWasEngaged;
|
||||
extern long gameFrame;
|
||||
extern short otherPlayerEscaped;
|
||||
extern Boolean quitting, playing, onePlayerLeft, twoPlayerGame, demoGoing;
|
||||
extern touchScreenControlState touchScreen;
|
||||
extern macEnviron thisMac;
|
||||
|
||||
|
||||
//============================================================== Functions
|
||||
@@ -320,6 +323,8 @@ void GetInput (gliderPtr thisGlider)
|
||||
bool holdFlipState = false;
|
||||
bool leftState = false;
|
||||
bool rightState = false;
|
||||
bool bandsState = false;
|
||||
bool batteryState = false;
|
||||
|
||||
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||
|
||||
@@ -337,6 +342,56 @@ void GetInput (gliderPtr thisGlider)
|
||||
else
|
||||
thisGlider->tipped = false;
|
||||
|
||||
if (thisMac.isTouchscreen)
|
||||
{
|
||||
for (int fi = 0; fi < touchScreenControlState::kMaxFingers; fi++)
|
||||
{
|
||||
const touchScreenFingerState &fstate = touchScreen.fingers[fi];
|
||||
if (!fstate.active)
|
||||
continue;
|
||||
|
||||
const Point touchScreenPoint = touchScreen.fingers[fi].point;
|
||||
|
||||
if (!touchScreen.controls[fstate.capturingControl].touchRect.Contains(touchScreenPoint))
|
||||
continue;
|
||||
|
||||
switch (fstate.capturingControl)
|
||||
{
|
||||
case TouchScreenCtrlIDs::Movement:
|
||||
{
|
||||
int32_t screenWidth = mainWindowRect.Width();
|
||||
const bool touchLeftState = (touchScreenPoint.h * 2 <= screenWidth);
|
||||
const bool touchRightState = (touchScreenPoint.h * 2 - screenWidth >= 0);
|
||||
|
||||
if (touchLeftState)
|
||||
{
|
||||
if (touchRightState)
|
||||
continuousFlipState = true;
|
||||
else
|
||||
leftState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (touchRightState)
|
||||
rightState = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TouchScreenCtrlIDs::Flip:
|
||||
holdFlipState = true;
|
||||
break;
|
||||
case TouchScreenCtrlIDs::Bands:
|
||||
bandsState = true;
|
||||
break;
|
||||
case TouchScreenCtrlIDs::BatteryHelium:
|
||||
batteryState = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (theKeys->IsSet(thisGlider->gamepadRightKey))
|
||||
rightState = true;
|
||||
|
||||
@@ -407,7 +462,7 @@ void GetInput (gliderPtr thisGlider)
|
||||
if (!leftState && !rightState)
|
||||
thisGlider->tipped = false;
|
||||
|
||||
if ((theKeys->IsSet(thisGlider->battKey) || theKeys->IsSet(thisGlider->gamepadBattKey)) && (batteryTotal != 0) &&
|
||||
if ((theKeys->IsSet(thisGlider->battKey) || theKeys->IsSet(thisGlider->gamepadBattKey) || batteryState) && (batteryTotal != 0) &&
|
||||
(thisGlider->mode == kGliderNormal))
|
||||
{
|
||||
#ifdef CREATEDEMODATA
|
||||
@@ -421,7 +476,7 @@ void GetInput (gliderPtr thisGlider)
|
||||
else
|
||||
batteryWasEngaged = false;
|
||||
|
||||
if ((theKeys->IsSet(thisGlider->bandKey) || theKeys->IsSet(thisGlider->gamepadBandKey)) && (bandsTotal > 0) &&
|
||||
if ((theKeys->IsSet(thisGlider->bandKey) || theKeys->IsSet(thisGlider->gamepadBandKey) || bandsState) && (bandsTotal > 0) &&
|
||||
(thisGlider->mode == kGliderNormal))
|
||||
{
|
||||
#ifdef CREATEDEMODATA
|
||||
|
@@ -390,14 +390,16 @@ void HandleGameResolutionChange(void)
|
||||
|
||||
//-------------------------------------------------------------- HandleTouchUp
|
||||
|
||||
void HandleTouchUp(int fingerID)
|
||||
void HandleTouchUp(touchScreenFingerID fingerID)
|
||||
{
|
||||
for (int i = 0; i < touchScreenControlState::kMaxFingers; i++)
|
||||
{
|
||||
if (touchScreen.fingers[i].fingerID == fingerID)
|
||||
touchScreenFingerState &fstate = touchScreen.fingers[i];
|
||||
if (fstate.active && fstate.tfingerID == fingerID)
|
||||
{
|
||||
touchScreen.fingers[i].fingerID = -1;
|
||||
touchScreen.fingers[i].capturingControl = TouchScreenCtrlIDs::None;
|
||||
fstate.active = false;
|
||||
fstate.tfingerID = touchScreenFingerID();
|
||||
fstate.capturingControl = TouchScreenCtrlIDs::Invalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -405,13 +407,15 @@ void HandleTouchUp(int fingerID)
|
||||
|
||||
//-------------------------------------------------------------- HandleTouchMove
|
||||
|
||||
void HandleTouchMove(int fingerID, const Point &pt)
|
||||
void HandleTouchMove(touchScreenFingerID fingerID, const Point &pt)
|
||||
{
|
||||
for (int i = 0; i < touchScreenControlState::kMaxFingers; i++)
|
||||
{
|
||||
if (touchScreen.fingers[i].fingerID == fingerID)
|
||||
touchScreenFingerState &fstate = touchScreen.fingers[i];
|
||||
|
||||
if (fstate.active && fstate.tfingerID == fingerID)
|
||||
{
|
||||
touchScreen.fingers[i].point = pt;
|
||||
fstate.point = pt;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -419,19 +423,21 @@ void HandleTouchMove(int fingerID, const Point &pt)
|
||||
|
||||
//-------------------------------------------------------------- HandleTouchDown
|
||||
|
||||
void HandleTouchDown(int fingerID, const Point &pt)
|
||||
void HandleTouchDown(touchScreenFingerID fingerID, const Point &pt)
|
||||
{
|
||||
int freeFingerIndex = -1;
|
||||
|
||||
for (int i = 0; i < touchScreenControlState::kMaxFingers; i++)
|
||||
{
|
||||
if (touchScreen.fingers[i].fingerID == fingerID)
|
||||
touchScreenFingerState &fstate = touchScreen.fingers[i];
|
||||
|
||||
if (fstate.active && fstate.tfingerID == fingerID)
|
||||
{
|
||||
// Finger is already considered down, something weird happened
|
||||
HandleTouchMove(fingerID, pt);
|
||||
return;
|
||||
}
|
||||
else if (touchScreen.fingers[i].fingerID < 0)
|
||||
else if (!fstate.active)
|
||||
freeFingerIndex = i;
|
||||
}
|
||||
|
||||
@@ -446,7 +452,8 @@ void HandleTouchDown(int fingerID, const Point &pt)
|
||||
{
|
||||
if (touchScreen.controls[j].touchRect.Contains(pt))
|
||||
{
|
||||
fingerState.fingerID = fingerID;
|
||||
fingerState.tfingerID = fingerID;
|
||||
fingerState.active = true;
|
||||
fingerState.capturingControl = static_cast<TouchScreenCtrlID_t>(j);
|
||||
fingerState.point = pt;
|
||||
return;
|
||||
@@ -458,14 +465,17 @@ void HandleTouchDown(int fingerID, const Point &pt)
|
||||
|
||||
//-------------------------------------------------------------- HandleTouchLeave
|
||||
|
||||
void HandleTouchLeave(int fingerID)
|
||||
void HandleTouchLeave(touchScreenFingerID fingerID)
|
||||
{
|
||||
for (int i = 0; i < touchScreenControlState::kMaxFingers; i++)
|
||||
{
|
||||
if (touchScreen.fingers[i].fingerID == fingerID)
|
||||
touchScreenFingerState &fstate = touchScreen.fingers[i];
|
||||
|
||||
if (fstate.active && fstate.tfingerID == fingerID)
|
||||
{
|
||||
touchScreen.fingers[i].fingerID = -1;
|
||||
touchScreen.fingers[i].capturingControl = TouchScreenCtrlIDs::None;
|
||||
fstate.tfingerID = touchScreenFingerID();
|
||||
fstate.active = false;
|
||||
fstate.capturingControl = TouchScreenCtrlIDs::Invalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -492,17 +502,43 @@ void HandleInGameEvents(void)
|
||||
{
|
||||
case GpMouseEventTypes::kDown:
|
||||
if (mouseInput.m_button == GpMouseButtons::kLeft)
|
||||
HandleTouchDown(0, mousePt);
|
||||
HandleTouchDown(touchScreenFingerID(), mousePt);
|
||||
break;
|
||||
case GpMouseEventTypes::kLeave:
|
||||
HandleTouchLeave(0);
|
||||
HandleTouchLeave(touchScreenFingerID());
|
||||
break;
|
||||
case GpMouseEventTypes::kUp:
|
||||
HandleTouchMove(0, mousePt);
|
||||
HandleTouchUp(0);
|
||||
HandleTouchMove(touchScreenFingerID(), mousePt);
|
||||
HandleTouchUp(touchScreenFingerID());
|
||||
break;
|
||||
case GpMouseEventTypes::kMove:
|
||||
HandleTouchMove(0, mousePt);
|
||||
HandleTouchMove(touchScreenFingerID(), mousePt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
if (!thisMac.isMouseTouchscreen && evt.m_vosEvent.m_eventType == GpVOSEventTypes::kTouchInput)
|
||||
{
|
||||
const GpTouchInputEvent &touchInput = evt.m_vosEvent.m_event.m_touchInputEvent;
|
||||
|
||||
const Point touchPt = mainWindow->TouchToLocal(touchInput);
|
||||
|
||||
switch (touchInput.m_eventType)
|
||||
{
|
||||
case GpTouchEventTypes::kDown:
|
||||
HandleTouchDown(touchScreenFingerID(touchInput.m_deviceID, touchInput.m_fingerID), touchPt);
|
||||
break;
|
||||
case GpTouchEventTypes::kLeave:
|
||||
HandleTouchLeave(touchScreenFingerID(touchInput.m_deviceID, touchInput.m_fingerID));
|
||||
break;
|
||||
case GpTouchEventTypes::kUp:
|
||||
HandleTouchMove(touchScreenFingerID(touchInput.m_deviceID, touchInput.m_fingerID), touchPt);
|
||||
HandleTouchUp(touchScreenFingerID(touchInput.m_deviceID, touchInput.m_fingerID));
|
||||
break;
|
||||
case GpTouchEventTypes::kMove:
|
||||
HandleTouchMove(touchScreenFingerID(), touchPt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -530,9 +566,7 @@ void ResetTouchScreenControlBounds (void)
|
||||
Point points[TouchScreenCtrlIDs::Count];
|
||||
Point sizes[TouchScreenCtrlIDs::Count];
|
||||
|
||||
points[TouchScreenCtrlIDs::MoveLeft] = Point::Create(mainWindowRect.left + touchScreenControlEdgeSpacing, mainWindowRect.bottom - touchScreenControlEdgeSpacing - touchScreenControlSize);
|
||||
points[TouchScreenCtrlIDs::MoveRight] = points[TouchScreenCtrlIDs::MoveLeft] + Point::Create(touchScreenControlInterSpacing + touchScreenControlSize, 0);
|
||||
|
||||
points[TouchScreenCtrlIDs::Movement] = Point::Create(mainWindowRect.left, mainWindowRect.top);
|
||||
points[TouchScreenCtrlIDs::BatteryHelium] = Point::Create(mainWindowRect.right - touchScreenControlEdgeSpacing - touchScreenControlSize, mainWindowRect.bottom - touchScreenControlEdgeSpacing - touchScreenControlSize);
|
||||
points[TouchScreenCtrlIDs::Flip] = points[TouchScreenCtrlIDs::BatteryHelium] + Point::Create(0, -touchScreenControlInterSpacing - touchScreenControlSize);
|
||||
points[TouchScreenCtrlIDs::Bands] = points[TouchScreenCtrlIDs::BatteryHelium] + Point::Create(-touchScreenControlInterSpacing - touchScreenControlSize, 0);
|
||||
@@ -540,6 +574,8 @@ void ResetTouchScreenControlBounds (void)
|
||||
for (int i = 0; i < TouchScreenCtrlIDs::Count; i++)
|
||||
sizes[i] = Point::Create(touchScreenControlSize, touchScreenControlSize);
|
||||
|
||||
sizes[TouchScreenCtrlIDs::Movement] = Point::Create(mainWindowRect.Width(), mainWindowRect.Height());
|
||||
|
||||
for (int i = 0; i < TouchScreenCtrlIDs::Count; i++)
|
||||
{
|
||||
Point lowerRight = points[i] + sizes[i];
|
||||
@@ -550,8 +586,9 @@ void ResetTouchScreenControlBounds (void)
|
||||
// Clear all active touches
|
||||
for (int i = 0; i < touchScreenControlState::kMaxFingers; i++)
|
||||
{
|
||||
touchScreen.fingers[i].fingerID = -1;
|
||||
touchScreen.fingers[i].capturingControl = TouchScreenCtrlIDs::None;
|
||||
touchScreen.fingers[i].tfingerID = touchScreenFingerID();
|
||||
touchScreen.fingers[i].active = false;
|
||||
touchScreen.fingers[i].capturingControl = TouchScreenCtrlIDs::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,10 +618,13 @@ void InitTouchScreenControlState(void)
|
||||
|
||||
void PlayGame (void)
|
||||
{
|
||||
const houseType *debugHouse = nullptr;
|
||||
if (thisHouse)
|
||||
debugHouse = *thisHouse;
|
||||
|
||||
InitTouchScreenControlState();
|
||||
|
||||
touchScreen.controls[TouchScreenCtrlIDs::MoveLeft].isEnabled = true;
|
||||
touchScreen.controls[TouchScreenCtrlIDs::MoveRight].isEnabled = true;
|
||||
touchScreen.controls[TouchScreenCtrlIDs::Movement].isEnabled = true;
|
||||
touchScreen.controls[TouchScreenCtrlIDs::Flip].isEnabled = true;
|
||||
touchScreen.controls[TouchScreenCtrlIDs::Bands].isEnabled = true;
|
||||
touchScreen.controls[TouchScreenCtrlIDs::BatteryHelium].isEnabled = true;
|
||||
|
@@ -615,8 +615,7 @@ void RenderTouchScreenControls (void)
|
||||
for (int i = 0; i < TouchScreenCtrlIDs::Count; i++)
|
||||
ctrlGraphics[i] = nullptr;
|
||||
|
||||
ctrlGraphics[TouchScreenCtrlIDs::MoveLeft] = touchScreen.graphics[touchScreenControlGraphics::MoveLeftIdle];
|
||||
ctrlGraphics[TouchScreenCtrlIDs::MoveRight] = touchScreen.graphics[touchScreenControlGraphics::MoveRightIdle];
|
||||
ctrlGraphics[TouchScreenCtrlIDs::Movement] = nullptr;
|
||||
ctrlGraphics[TouchScreenCtrlIDs::Flip] = touchScreen.graphics[touchScreenControlGraphics::FlipIdle];
|
||||
ctrlGraphics[TouchScreenCtrlIDs::Bands] = touchScreen.graphics[touchScreenControlGraphics::BandsDisabled];
|
||||
ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryDisabled];
|
||||
@@ -636,7 +635,7 @@ void RenderTouchScreenControls (void)
|
||||
if (batteryTotal < 0)
|
||||
ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::HeliumActive];
|
||||
else if (batteryTotal > 0)
|
||||
ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BandsActive];
|
||||
ctrlGraphics[TouchScreenCtrlIDs::BatteryHelium] = touchScreen.graphics[touchScreenControlGraphics::BatteryActive];
|
||||
}
|
||||
else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Bands)
|
||||
{
|
||||
@@ -645,10 +644,6 @@ void RenderTouchScreenControls (void)
|
||||
}
|
||||
else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::Flip)
|
||||
ctrlGraphics[TouchScreenCtrlIDs::Flip] = touchScreen.graphics[touchScreenControlGraphics::FlipActive];
|
||||
else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::MoveLeft)
|
||||
ctrlGraphics[TouchScreenCtrlIDs::MoveLeft] = touchScreen.graphics[touchScreenControlGraphics::MoveLeftActive];
|
||||
else if (touchScreen.fingers[i].capturingControl == TouchScreenCtrlIDs::MoveRight)
|
||||
ctrlGraphics[TouchScreenCtrlIDs::MoveRight] = touchScreen.graphics[touchScreenControlGraphics::MoveRightActive];
|
||||
}
|
||||
|
||||
for (int i = 0; i < TouchScreenCtrlIDs::Count; i++)
|
||||
|
@@ -237,6 +237,29 @@ struct GpMouseInputEvent
|
||||
GpMouseButton_t m_button;
|
||||
};
|
||||
|
||||
|
||||
namespace GpTouchEventTypes
|
||||
{
|
||||
enum GpTouchEventType
|
||||
{
|
||||
kUp,
|
||||
kDown,
|
||||
kMove,
|
||||
kLeave,
|
||||
};
|
||||
}
|
||||
|
||||
typedef GpTouchEventTypes::GpTouchEventType GpTouchEventType_t;
|
||||
|
||||
struct GpTouchInputEvent
|
||||
{
|
||||
int32_t m_x;
|
||||
int32_t m_y;
|
||||
int64_t m_deviceID;
|
||||
int64_t m_fingerID;
|
||||
GpTouchEventType_t m_eventType;
|
||||
};
|
||||
|
||||
struct GpVideoResolutionChangedEvent
|
||||
{
|
||||
uint32_t m_prevWidth;
|
||||
@@ -251,6 +274,7 @@ namespace GpVOSEventTypes
|
||||
{
|
||||
kKeyboardInput,
|
||||
kMouseInput,
|
||||
kTouchInput,
|
||||
kGamepadInput,
|
||||
kVideoResolutionChanged,
|
||||
kQuit
|
||||
@@ -265,6 +289,7 @@ struct GpVOSEvent
|
||||
{
|
||||
GpKeyboardInputEvent m_keyboardInputEvent;
|
||||
GpMouseInputEvent m_mouseInputEvent;
|
||||
GpTouchInputEvent m_touchInputEvent;
|
||||
GpGamepadInputEvent m_gamepadInputEvent;
|
||||
GpVideoResolutionChangedEvent m_resolutionChangedEvent;
|
||||
};
|
||||
|
@@ -679,6 +679,11 @@ DrawSurface *Window::GetDrawSurface() const
|
||||
return const_cast<DrawSurface*>(&m_surface);
|
||||
}
|
||||
|
||||
Point Window::TouchToLocal(const GpTouchInputEvent &evt) const
|
||||
{
|
||||
return Point::Create(evt.m_x - m_wmX, evt.m_y - m_wmY);
|
||||
}
|
||||
|
||||
Point Window::MouseToLocal(const GpMouseInputEvent &evt) const
|
||||
{
|
||||
return Point::Create(evt.m_x - m_wmX, evt.m_y - m_wmY);
|
||||
|
@@ -19,6 +19,7 @@ struct IGpCursor;
|
||||
class GpIOStream;
|
||||
struct GpVOSEvent;
|
||||
struct GpMouseInputEvent;
|
||||
struct GpTouchInputEvent;
|
||||
struct TimeTaggedVOSEvent;
|
||||
|
||||
|
||||
@@ -95,6 +96,8 @@ struct Window
|
||||
// Convenience method to convert a mouse event to local point
|
||||
Point MouseToLocal(const GpMouseInputEvent &evt) const;
|
||||
|
||||
Point TouchToLocal(const GpTouchInputEvent &evt) const;
|
||||
|
||||
// Convenience method that returns a 16-bit precision X/Y
|
||||
Point GetTopLeftCoord() const;
|
||||
|
||||
|
@@ -42,6 +42,12 @@ static void TranslateMouseInputEvent(const GpVOSEvent &vosEventBase, uint32_t ti
|
||||
inputManager->ApplyMouseEvent(vosEvent);
|
||||
}
|
||||
|
||||
static void TranslateTouchInputEvent(const GpVOSEvent &vosEventBase, uint32_t timestamp, PortabilityLayer::EventQueue *queue)
|
||||
{
|
||||
if (TimeTaggedVOSEvent *evt = queue->Enqueue())
|
||||
*evt = TimeTaggedVOSEvent::Create(vosEventBase, timestamp);
|
||||
}
|
||||
|
||||
static void TranslateGamepadInputEvent(const GpGamepadInputEvent &vosEvent, PortabilityLayer::EventQueue *queue)
|
||||
{
|
||||
PortabilityLayer::InputManager *inputManager = PortabilityLayer::InputManager::GetInstance();
|
||||
@@ -127,6 +133,9 @@ static void TranslateVOSEvent(const GpVOSEvent *vosEvent, uint32_t timestamp, Po
|
||||
case GpVOSEventTypes::kMouseInput:
|
||||
TranslateMouseInputEvent(*vosEvent, timestamp, queue);
|
||||
break;
|
||||
case GpVOSEventTypes::kTouchInput:
|
||||
TranslateTouchInputEvent(*vosEvent, timestamp, queue);
|
||||
break;
|
||||
case GpVOSEventTypes::kKeyboardInput:
|
||||
TranslateKeyboardInputEvent(*vosEvent, timestamp, queue);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user