From cecf5f80601ef8bb40844b18853b664f0ee8b359 Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Tue, 21 Feb 2012 12:53:11 +0000 Subject: [PATCH] fixed Android issues with new onscreen buttons. fixed some stability issue with the deck viewer. --- JGE/src/SDLmain.cpp | 13 ++++++++----- .../mtg/Android/src/org/libsdl/app/SDLActivity.java | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/JGE/src/SDLmain.cpp b/JGE/src/SDLmain.cpp index f7e4d6090..d3323890d 100644 --- a/JGE/src/SDLmain.cpp +++ b/JGE/src/SDLmain.cpp @@ -239,6 +239,7 @@ public: case SDL_FINGERMOTION: case SDL_FINGERDOWN: case SDL_FINGERUP: + DebugTrace("Finger Up/Down/Motion detected:" ); OnTouchEvent(Event->tfinger); break; @@ -581,11 +582,6 @@ void SdlApp::OnTouchEvent(const SDL_TouchFingerEvent& event) int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth(); int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight(); - g_engine->LeftClicked( - ((event.x - viewPort.x) * SCREEN_WIDTH) / actualWidth, - ((event.y - viewPort.y) * SCREEN_HEIGHT) / actualHeight); - - Uint32 eventTime = SDL_GetTicks(); if (event.type == SDL_FINGERDOWN) { @@ -595,6 +591,7 @@ void SdlApp::OnTouchEvent(const SDL_TouchFingerEvent& event) lastFingerDownTime = eventTime; } + #if (defined ANDROID) || (defined IOS) if (event.type == SDL_FINGERUP) { @@ -603,11 +600,17 @@ void SdlApp::OnTouchEvent(const SDL_TouchFingerEvent& event) // treat an up finger within 50 pixels of the down finger coords as a double click event if (abs(mMouseDownX - event.x) < kHitzonePliancy && abs(mMouseDownY - event.y) < kHitzonePliancy) { + DebugTrace("Pressing OK BUtton"); g_engine->HoldKey_NoRepeat(JGE_BTN_OK); } } } + else #endif + g_engine->LeftClicked( + ((event.x - viewPort.x) * SCREEN_WIDTH) / actualWidth, + ((event.y - viewPort.y) * SCREEN_HEIGHT) / actualHeight); + } } } diff --git a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java index 0172ae619..6f306c1f4 100644 --- a/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java +++ b/projects/mtg/Android/src/org/libsdl/app/SDLActivity.java @@ -801,8 +801,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, // calc velocity mVelocityTracker.computeCurrentVelocity(1000); - - SDLActivity.onNativeFlickGesture(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); + float xVelocity = mVelocityTracker.getXVelocity(0); + float yVelocity = mVelocityTracker.getYVelocity(0); + if ( Math.abs(xVelocity) > 300 || Math.abs(yVelocity) > 300) + SDLActivity.onNativeFlickGesture(xVelocity, yVelocity); mVelocityTracker.recycle(); }