From 635bc389c413e6f724fabad8493759c9e0a59070 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 19 Jan 2015 21:45:50 +0200 Subject: [PATCH] SDL: Fixed blend coefficient for diagonal presses on screen joystick --- .../video/android/SDL_touchscreenkeyboard.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c index 8f8d7875b..2730bb97f 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c @@ -283,22 +283,24 @@ static void drawTouchscreenKeyboardLegacy() if( arrowImages[8].id == 0 ) // No diagonal arrow images { - blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) + - ( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) + - ( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) + - ( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 ); + blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 4 : 0 ) + + ( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 4 : 0 ) + + ( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 4 : 0 ) + + ( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 4 : 0 ); + if (blendFactor >= 8) + blendFactor = 7; if( blendFactor == 0 || SDL_ANDROID_joysticksAmount >= 1 ) drawCharTex( &arrowImages[0], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency ); else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ) - drawCharTex( &arrowImages[1], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency / blendFactor ); + drawCharTex( &arrowImages[1], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency * 4 / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ) - drawCharTex( &arrowImages[2], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency / blendFactor ); + drawCharTex( &arrowImages[2], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency * 4 / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ) - drawCharTex( &arrowImages[3], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency / blendFactor ); + drawCharTex( &arrowImages[3], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency * 4 / blendFactor ); if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ) - drawCharTex( &arrowImages[4], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency / blendFactor ); + drawCharTex( &arrowImages[4], NULL, &arrowsDraw[0], 1.0f, 1.0f, 1.0f, transparency * 4 / blendFactor ); } } else // Diagonal arrow images present