Added advanced point-and-click features: right mouse click via several methods, left click configurable, and showing part of screen under finger in small window

This commit is contained in:
pelya
2010-11-09 16:05:39 +02:00
parent d77db689e6
commit 8f6f72b1fb
13 changed files with 260 additions and 74 deletions

View File

@@ -1,5 +1,5 @@
# The application settings for Android libSDL port
AppSettingVersion=12
AppSettingVersion=14
LibSdlVersion=1.2
AppName="Pachi el marciano"
AppFullName=net.sourceforge.dragontech.pachi
@@ -10,7 +10,9 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
NeedDepthBuffer=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=n
AppHandlesJoystickSensitivity=n
AppUsesMultitouch=n

View File

@@ -1,21 +1,23 @@
# The application settings for Android libSDL port
AppSettingVersion=12
AppSettingVersion=14
LibSdlVersion=1.2
AppName="ScummVM"
AppFullName=org.scummvm.sdl
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="Data files size is 3 Mb|https://sites.google.com/site/xpelyax/Home/scummvm-1.2.0-data-1.zip?attredirects=0&d=1^Lure of the Temptress (10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-1.1.zip/download"
AppDataDownloadUrl="Data files size is 3.5 Mb|http://sourceforge.net/projects/libsdl-android/files/ScummVM/scummvm-1.2.0-data.zip/download^Lure of the Temptress (English, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-1.1.zip/download^Lure of the Temptress (German, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-de-1.1.zip/download^Lure of the Temptress (French, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-fr-1.1.zip/download^Lure of the Temptress (Italian, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-it-1.1.zip/download^Lure of the Temptress (Spanish, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Lure%20of%20the%20Temptress/lure-es-1.1.zip/download^Beneath a Steel Sky (CD version, 70 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Beneath%20a%20Steel%20Sky/bass-cd-1.2.zip/download^Beneath a Steel Sky (floppy version, 10 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Beneath%20a%20Steel%20Sky/BASS-Floppy-1.3.zip/download^Flight of the Amazon Queen (23 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Floppy.zip/download^Flight of the Amazon Queen - voice addon (English, 35 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Talkie-1.1.zip/download^Flight of the Amazon Queen - voice addon (German, 80 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Ger_talkie-1.0.zip/download^Flight of the Amazon Queen - voice addon (Hebrew, 70 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Flight%20of%20the%20Amazon%20Queen/FOTAQ_Heb_talkie.zip/download^Drascula: The Vampire Strikes Back (35 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Drascula_%20The%20Vampire%20Strikes%20Back/drascula-1.0.zip/download^Drascula: The Vampire Strikes Back - translations addon (35 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Drascula_%20The%20Vampire%20Strikes%20Back/drascula-int-1.1.zip/download^Drascula: The Vampire Strikes Back - audio addon (40 Mb)|http://sourceforge.net/projects/scummvm/files/extras/Drascula_%20The%20Vampire%20Strikes%20Back/drascula-audio-2.0.zip/download"
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
NeedDepthBuffer=n
AppUsesMouse=y
AppNeedsArrowKeys=y
AppNeedsTwoButtonMouse=y
AppNeedsArrowKeys=n
AppNeedsTextInput=n
AppUsesJoystick=n
AppHandlesJoystickSensitivity=n
AppUsesMultitouch=n
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN LCTRL LALT SPACE"
RedefinedKeys="LALT F7 ESCAPE F11 ESCAPE F11 ESCAPE"
AppTouchscreenKeyboardKeysAmount=0
AppTouchscreenKeyboardKeysAmountAutoFire=0
MultiABI=n

View File

@@ -21,7 +21,7 @@ ln -sf libtremor.a $LOCAL_PATH/../../../obj/local/armeabi/libvorbisidec.a
ln -sf libflac.a $LOCAL_PATH/../../../obj/local/armeabi/libFLAC.a
if [ \! -f scummvm/config.mk ] ; then
../setEnvironment.sh sh -c "cd scummvm && env LIBS='-lflac -ltremor -logg -lmad -lz -lgcc' ./configure --host=androidsdl --enable-zlib --enable-tremor --enable-mad --enable-flac --enable-vkeybd --enable-verbose-build --disable-hq-scalers --disable-readline --disable-nasm --datadir=."
../setEnvironment.sh sh -c "cd scummvm && env LIBS='-lflac -ltremor -logg -lmad -lz -lgcc' ./configure --host=androidsdl --enable-zlib --enable-tremor --enable-mad --enable-flac --enable-vkeybd --enable-keymapper --enable-verbose-build --disable-hq-scalers --disable-readline --disable-nasm --datadir=."
fi
../setEnvironment.sh make -C scummvm -j2
cp -f scummvm/scummvm libapplication.so

View File

@@ -1 +1 @@
sc2
scummvm

View File

@@ -744,6 +744,10 @@ static int ANDROID_FlipHWSurface(_THIS, SDL_Surface *surface)
rect.h = SDL_CurrentVideoSurface->h;
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, SDL_CurrentVideoSurface->pixels, SDL_CurrentVideoSurface->pitch);
SDL_RenderCopy((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, &rect);
if( SDL_ANDROID_ShowScreenUnderFinger )
{
SDL_RenderCopy((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &SDL_ANDROID_ShowScreenUnderFingerRectSrc, &SDL_ANDROID_ShowScreenUnderFingerRect);
}
}
SDL_ANDROID_CallJavaSwapBuffers();

View File

@@ -500,10 +500,10 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
data->texw = (GLfloat) texture->w / texture_w;
data->texh = (GLfloat) texture->h / texture_h;
if( renderer->info.max_texture_width < texture_w || renderer->info.max_texture_height < texture_h )
__android_log_print(ANDROID_LOG_WARNING, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than largest possible device texture %dx%d",
__android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than largest possible device texture %dx%d",
texture_w, texture_h, renderer->info.max_texture_width, renderer->info.max_texture_height );
else if( texture_w > 1024 || texture_h > 1024 )
__android_log_print(ANDROID_LOG_WARNING, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than 1024x1024 - this code will not work on HTC G1", texture_w, texture_h );
__android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than 1024x1024 - this code will not work on HTC G1", texture_w, texture_h );
data->format = format;
data->formattype = type;

View File

@@ -46,9 +46,10 @@ SDLKey SDL_android_keymap[KEYCODE_LAST+1];
static int isTrackballUsed = 0;
static int isMouseUsed = 0;
enum { RIGHT_CLICK_WITH_MENU_BUTTON = 0, RIGHT_CLICK_WITH_MULTITOUCH = 1, RIGHT_CLICK_WITH_PRESSURE = 2 };
static int rightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON;
static int showScreenUnderFinger = 0;
enum { RIGHT_CLICK_NONE = 0, RIGHT_CLICK_WITH_MENU_BUTTON = 1, RIGHT_CLICK_WITH_MULTITOUCH = 2, RIGHT_CLICK_WITH_PRESSURE = 3 };
static int rightClickMethod = RIGHT_CLICK_NONE;
int SDL_ANDROID_ShowScreenUnderFinger = 0;
SDL_Rect SDL_ANDROID_ShowScreenUnderFingerRect = {0, 0, 0, 0}, SDL_ANDROID_ShowScreenUnderFingerRectSrc = {0, 0, 0, 0};
static int leftClickUsesPressure = 0;
static int maxForce = 0;
static int maxRadius = 0;
@@ -58,6 +59,58 @@ SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1] = {NULL};
static int TrackballDampening = 0; // in milliseconds
static int lastTrackballAction = 0;
static inline int InsideRect(const SDL_Rect * r, int x, int y)
{
return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h );
}
void UpdateScreenUnderFingerRect(int x, int y)
{
int screenX = 320, screenY = 240;
if( !SDL_ANDROID_ShowScreenUnderFinger )
return;
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_Window * window = SDL_GetFocusWindow();
if( window && window->renderer->window ) {
screenX = window->w;
screenY = window->h;
}
#else
screenX = SDL_ANDROID_sFakeWindowWidth;
screenY = SDL_ANDROID_sFakeWindowHeight;
#endif
SDL_ANDROID_ShowScreenUnderFingerRectSrc.w = screenX / 4;
SDL_ANDROID_ShowScreenUnderFingerRectSrc.h = screenY / 4;
SDL_ANDROID_ShowScreenUnderFingerRectSrc.x = x - SDL_ANDROID_ShowScreenUnderFingerRectSrc.w/2;
SDL_ANDROID_ShowScreenUnderFingerRectSrc.y = y - SDL_ANDROID_ShowScreenUnderFingerRectSrc.h/2;
if( SDL_ANDROID_ShowScreenUnderFingerRectSrc.x < 0 )
SDL_ANDROID_ShowScreenUnderFingerRectSrc.x = 0;
if( SDL_ANDROID_ShowScreenUnderFingerRectSrc.y < 0 )
SDL_ANDROID_ShowScreenUnderFingerRectSrc.y = 0;
if( SDL_ANDROID_ShowScreenUnderFingerRectSrc.x > screenX - SDL_ANDROID_ShowScreenUnderFingerRectSrc.w )
SDL_ANDROID_ShowScreenUnderFingerRectSrc.x = screenX - SDL_ANDROID_ShowScreenUnderFingerRectSrc.w;
if( SDL_ANDROID_ShowScreenUnderFingerRectSrc.y > screenY - SDL_ANDROID_ShowScreenUnderFingerRectSrc.h )
SDL_ANDROID_ShowScreenUnderFingerRectSrc.y = screenY - SDL_ANDROID_ShowScreenUnderFingerRectSrc.h;
SDL_ANDROID_ShowScreenUnderFingerRect.w = SDL_ANDROID_ShowScreenUnderFingerRectSrc.w * 3 / 2;
SDL_ANDROID_ShowScreenUnderFingerRect.h = SDL_ANDROID_ShowScreenUnderFingerRectSrc.h * 3 / 2;
SDL_ANDROID_ShowScreenUnderFingerRect.x = x + SDL_ANDROID_ShowScreenUnderFingerRect.w/10;
SDL_ANDROID_ShowScreenUnderFingerRect.y = y - SDL_ANDROID_ShowScreenUnderFingerRect.h*11/10;
if( SDL_ANDROID_ShowScreenUnderFingerRect.x < 0 )
SDL_ANDROID_ShowScreenUnderFingerRect.x = 0;
if( SDL_ANDROID_ShowScreenUnderFingerRect.y < 0 )
SDL_ANDROID_ShowScreenUnderFingerRect.y = 0;
if( SDL_ANDROID_ShowScreenUnderFingerRect.x + SDL_ANDROID_ShowScreenUnderFingerRect.w > screenX )
SDL_ANDROID_ShowScreenUnderFingerRect.x = screenX - SDL_ANDROID_ShowScreenUnderFingerRect.w;
if( SDL_ANDROID_ShowScreenUnderFingerRect.y + SDL_ANDROID_ShowScreenUnderFingerRect.h > screenY )
SDL_ANDROID_ShowScreenUnderFingerRect.y = screenY - SDL_ANDROID_ShowScreenUnderFingerRect.h;
if( InsideRect(&SDL_ANDROID_ShowScreenUnderFingerRect, x, y) )
SDL_ANDROID_ShowScreenUnderFingerRect.x = x - SDL_ANDROID_ShowScreenUnderFingerRect.w*11/10;
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, jint x, jint y, jint action, jint pointerId, jint force, jint radius )
{
@@ -119,22 +172,51 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
if( !isMouseUsed )
return;
if( action == MOUSE_DOWN || action == MOUSE_UP )
if( pointerId == 0 )
{
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_SendMouseMotion(NULL, 0, x, y);
SDL_SendMouseButton(NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, 1 );
#else
SDL_PrivateMouseMotion(0, 0, x, y);
SDL_PrivateMouseButton( (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, 1, x, y );
#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
#endif
if( action == MOUSE_UP )
{
if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) )
SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT );
if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_RIGHT) )
SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_RIGHT );
SDL_ANDROID_ShowScreenUnderFingerRect.w = SDL_ANDROID_ShowScreenUnderFingerRect.h = 0;
SDL_ANDROID_ShowScreenUnderFingerRectSrc.w = SDL_ANDROID_ShowScreenUnderFingerRectSrc.h = 0;
}
if( action == MOUSE_DOWN )
{
if( !leftClickUsesPressure )
SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
else
action == MOUSE_MOVE;
UpdateScreenUnderFingerRect(x, y);
}
if( action == MOUSE_MOVE )
{
if( rightClickMethod == RIGHT_CLICK_WITH_PRESSURE || leftClickUsesPressure )
{
int button = leftClickUsesPressure ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT;
int buttonState = ( force > maxForce || radius > maxRadius );
if( button == SDL_BUTTON_RIGHT && (SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT)) )
SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT );
if( ( (SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(button)) != 0 ) != buttonState )
SDL_SendMouseButton( NULL, buttonState ? SDL_PRESSED : SDL_RELEASED, button );
}
UpdateScreenUnderFingerRect(x, y);
}
}
if( pointerId == 1 && rightClickMethod == RIGHT_CLICK_WITH_MULTITOUCH && (action == MOUSE_DOWN || action == MOUSE_UP) )
{
if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) )
SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT );
SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
}
if( action == MOUSE_MOVE )
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_SendMouseMotion(NULL, 0, x, y);
#else
SDL_PrivateMouseMotion(0, 0, x, y);
#endif
}
static int processAndroidTrackball(int key, int action);
@@ -145,6 +227,11 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint
if( isTrackballUsed )
if( processAndroidTrackball(key, action) )
return;
if( key == KEYCODE_MENU && rightClickMethod == RIGHT_CLICK_WITH_MENU_BUTTON )
{
SDL_SendMouseButton( NULL, action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
return;
}
SDL_keysym keysym;
SDL_SendKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key ,&keysym) );
}
@@ -209,7 +296,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz, jint
{
isMouseUsed = 1;
rightClickMethod = RightClickMethod;
showScreenUnderFinger = ShowScreenUnderFinger;
SDL_ANDROID_ShowScreenUnderFinger = ShowScreenUnderFinger;
leftClickUsesPressure = LeftClickUsesPressure;
maxForce = MaxForce;
maxRadius = MaxRadius;

View File

@@ -31,6 +31,8 @@ extern int SDL_ANDROID_sWindowWidth;
extern int SDL_ANDROID_sWindowHeight;
extern int SDL_ANDROID_sFakeWindowWidth; // SDL 1.2 only
extern int SDL_ANDROID_sFakeWindowHeight; // SDL 1.2 only
extern int SDL_ANDROID_ShowScreenUnderFinger;
extern SDL_Rect SDL_ANDROID_ShowScreenUnderFingerRect, SDL_ANDROID_ShowScreenUnderFingerRectSrc;
extern int SDL_ANDROID_CallJavaSwapBuffers();
extern void SDL_ANDROID_CallJavaShowScreenKeyboard();
extern int SDL_ANDROID_drawTouchscreenKeyboard();