fixed Android issues with new onscreen buttons.

fixed some stability issue with the deck viewer.
This commit is contained in:
techdragon.nguyen@gmail.com
2012-02-21 12:53:11 +00:00
parent 641c4068d8
commit cecf5f8060
2 changed files with 12 additions and 7 deletions

View File

@@ -239,6 +239,7 @@ public:
case SDL_FINGERMOTION: case SDL_FINGERMOTION:
case SDL_FINGERDOWN: case SDL_FINGERDOWN:
case SDL_FINGERUP: case SDL_FINGERUP:
DebugTrace("Finger Up/Down/Motion detected:" );
OnTouchEvent(Event->tfinger); OnTouchEvent(Event->tfinger);
break; break;
@@ -581,11 +582,6 @@ void SdlApp::OnTouchEvent(const SDL_TouchFingerEvent& event)
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth(); int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
int actualHeight = (int) JRenderer::GetInstance()->GetActualHeight(); 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(); Uint32 eventTime = SDL_GetTicks();
if (event.type == SDL_FINGERDOWN) if (event.type == SDL_FINGERDOWN)
{ {
@@ -595,6 +591,7 @@ void SdlApp::OnTouchEvent(const SDL_TouchFingerEvent& event)
lastFingerDownTime = eventTime; lastFingerDownTime = eventTime;
} }
#if (defined ANDROID) || (defined IOS) #if (defined ANDROID) || (defined IOS)
if (event.type == SDL_FINGERUP) 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 // 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) if (abs(mMouseDownX - event.x) < kHitzonePliancy && abs(mMouseDownY - event.y) < kHitzonePliancy)
{ {
DebugTrace("Pressing OK BUtton");
g_engine->HoldKey_NoRepeat(JGE_BTN_OK); g_engine->HoldKey_NoRepeat(JGE_BTN_OK);
} }
} }
} }
else
#endif #endif
g_engine->LeftClicked(
((event.x - viewPort.x) * SCREEN_WIDTH) / actualWidth,
((event.y - viewPort.y) * SCREEN_HEIGHT) / actualHeight);
} }
} }
} }

View File

@@ -801,8 +801,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
// calc velocity // calc velocity
mVelocityTracker.computeCurrentVelocity(1000); mVelocityTracker.computeCurrentVelocity(1000);
float xVelocity = mVelocityTracker.getXVelocity(0);
SDLActivity.onNativeFlickGesture(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); float yVelocity = mVelocityTracker.getYVelocity(0);
if ( Math.abs(xVelocity) > 300 || Math.abs(yVelocity) > 300)
SDLActivity.onNativeFlickGesture(xVelocity, yVelocity);
mVelocityTracker.recycle(); mVelocityTracker.recycle();
} }