From c7d151e9f80f3ec36ff4255dff174f1ec1a95db9 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Sun, 1 Dec 2013 12:31:22 -0800 Subject: [PATCH] Multitouch fix --- project/include/platform/tizen/TizenStage.h | 3 ++ .../src/platform/tizen/TizenApplication.cpp | 38 ++++++++++++++++--- project/src/platform/tizen/TizenStage.cpp | 21 ++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/project/include/platform/tizen/TizenStage.h b/project/include/platform/tizen/TizenStage.h index 4402929e3..097409c09 100644 --- a/project/include/platform/tizen/TizenStage.h +++ b/project/include/platform/tizen/TizenStage.h @@ -19,8 +19,11 @@ namespace lime { void Flip (); void GetMouse (); + bool getMultitouchSupported (); + bool getMultitouchActive (); void Resize (const int inWidth, const int inHeight); void SetCursor (Cursor inCursor); + void setMultitouchActive (bool inActive); Surface *GetPrimarySurface () { return mPrimarySurface; } bool isOpenGL () const { return true; } diff --git a/project/src/platform/tizen/TizenApplication.cpp b/project/src/platform/tizen/TizenApplication.cpp index 2b485fe46..c5580fcb9 100644 --- a/project/src/platform/tizen/TizenApplication.cpp +++ b/project/src/platform/tizen/TizenApplication.cpp @@ -8,6 +8,7 @@ namespace lime { int gFixedOrientation = -1; + int mSingleTouchID; FrameCreationCallback sgCallback; unsigned int sgFlags; int sgHeight; @@ -15,6 +16,8 @@ namespace lime { TizenFrame *sgTizenFrame; int sgWidth; + enum { NO_TOUCH = -1 }; + void CreateMainFrame (FrameCreationCallback inOnFrame, int inWidth, int inHeight, unsigned int inFlags, const char *inTitle, Surface *inIcon) { @@ -24,6 +27,8 @@ namespace lime { sgFlags = inFlags; sgTitle = inTitle; + mSingleTouchID = NO_TOUCH; + //if (sgWidth == 0 && sgHeight == 0) { // Hard-code screen size for now @@ -233,9 +238,14 @@ namespace lime { void TizenApplication::OnTouchMoved (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo) { - Event mouse (etMouseMove, currentPosition.x, currentPosition.y); + Event mouse (etTouchMove, currentPosition.x, currentPosition.y); mouse.value = touchInfo.GetPointId (); - mouse.flags |= efLeftDown; + + if (mSingleTouchID == NO_TOUCH || mouse.value == mSingleTouchID) { + + mouse.flags |= efPrimaryTouch; + + } sgTizenFrame->HandleEvent (mouse); @@ -244,9 +254,14 @@ namespace lime { void TizenApplication::OnTouchPressed (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo) { - Event mouse (etMouseDown, currentPosition.x, currentPosition.y); + Event mouse (etTouchBegin, currentPosition.x, currentPosition.y); mouse.value = touchInfo.GetPointId (); - mouse.flags |= efLeftDown; + + if (mSingleTouchID == NO_TOUCH || mouse.value == mSingleTouchID) { + + mouse.flags |= efPrimaryTouch; + + } sgTizenFrame->HandleEvent (mouse); @@ -255,9 +270,20 @@ namespace lime { void TizenApplication::OnTouchReleased (const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo) { - Event mouse (etMouseUp, currentPosition.x, currentPosition.y); + Event mouse (etTouchEnd, currentPosition.x, currentPosition.y); mouse.value = touchInfo.GetPointId (); - mouse.flags |= efLeftDown; + + if (mSingleTouchID == NO_TOUCH || mouse.value == mSingleTouchID) { + + mouse.flags |= efPrimaryTouch; + + } + + if (mSingleTouchID == mouse.value) { + + mSingleTouchID = NO_TOUCH; + + } sgTizenFrame->HandleEvent (mouse); diff --git a/project/src/platform/tizen/TizenStage.cpp b/project/src/platform/tizen/TizenStage.cpp index 81eead284..f2d48ff5b 100644 --- a/project/src/platform/tizen/TizenStage.cpp +++ b/project/src/platform/tizen/TizenStage.cpp @@ -64,6 +64,20 @@ namespace lime { void TizenStage::GetMouse () {} + bool TizenStage::getMultitouchSupported () { + + return true; + } + + + bool TizenStage::getMultitouchActive () { + + //return mMultiTouch; + return true; + + } + + void TizenStage::Resize (const int inWidth, const int inHeight) { AppLog ("Resize: %d x %d\n", inWidth, inHeight); @@ -109,6 +123,13 @@ namespace lime { } + void TizenStage::setMultitouchActive (bool inActive) { + + //mMultiTouch = inActive; + + } + + /*#define TIZEN_TRANS(x) case TIZEN_KEY_##x: return key##x;