Separate option for mouse click via DPAD center/trackball, fixed moving mouse via cursor keys
This commit is contained in:
@@ -63,7 +63,6 @@ class Globals {
|
||||
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
|
||||
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
|
||||
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
|
||||
public static final int LEFT_CLICK_WITH_DPAD_CENTER = 4;
|
||||
public static int LeftClickMethod = LEFT_CLICK_NORMAL;
|
||||
public static final int RIGHT_CLICK_NONE = 0;
|
||||
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
|
||||
@@ -71,6 +70,7 @@ class Globals {
|
||||
public static final int RIGHT_CLICK_WITH_MENU_BUTTON = 3;
|
||||
public static int RightClickMethod = RIGHT_CLICK_NONE;
|
||||
public static boolean MoveMouseWithJoystick = false;
|
||||
public static boolean ClickMouseWithDpad = false;
|
||||
public static boolean ShowScreenUnderFinger = false;
|
||||
public static boolean KeepAspectRatio = false;
|
||||
public static int ClickScreenPressure = 0;
|
||||
|
||||
@@ -53,6 +53,7 @@ class Settings
|
||||
out.writeBoolean(Globals.ShowScreenUnderFinger);
|
||||
out.writeInt(Globals.LeftClickMethod);
|
||||
out.writeBoolean(Globals.MoveMouseWithJoystick);
|
||||
out.writeBoolean(Globals.ClickMouseWithDpad);
|
||||
out.writeInt(Globals.ClickScreenPressure);
|
||||
out.writeInt(Globals.ClickScreenTouchspotSize);
|
||||
out.writeBoolean(Globals.KeepAspectRatio);
|
||||
@@ -92,6 +93,7 @@ class Settings
|
||||
Globals.ShowScreenUnderFinger = settingsFile.readBoolean();
|
||||
Globals.LeftClickMethod = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystick = settingsFile.readBoolean();
|
||||
Globals.ClickMouseWithDpad = settingsFile.readBoolean();
|
||||
Globals.ClickScreenPressure = settingsFile.readInt();
|
||||
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
|
||||
Globals.KeepAspectRatio = settingsFile.readBoolean();
|
||||
@@ -221,7 +223,8 @@ class Settings
|
||||
p.getResources().getString(R.string.controls_accelnav),
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
|
||||
p.getResources().getString(R.string.pointandclick_joystickmouse)
|
||||
p.getResources().getString(R.string.pointandclick_joystickmouse),
|
||||
p.getResources().getString(R.string.leftclick_dpadcenter)
|
||||
};
|
||||
|
||||
final boolean defaults[] = {
|
||||
@@ -229,7 +232,8 @@ class Settings
|
||||
Globals.UseAccelerometerAsArrowKeys,
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.ShowScreenUnderFinger,
|
||||
Globals.MoveMouseWithJoystick
|
||||
Globals.MoveMouseWithJoystick,
|
||||
Globals.ClickMouseWithDpad
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
@@ -248,6 +252,8 @@ class Settings
|
||||
Globals.ShowScreenUnderFinger = isChecked;
|
||||
if( item == 4 )
|
||||
Globals.MoveMouseWithJoystick = isChecked;
|
||||
if( item == 5 )
|
||||
Globals.ClickMouseWithDpad = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
@@ -432,8 +438,7 @@ class Settings
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
|
||||
p.getResources().getString(R.string.leftclick_near_cursor),
|
||||
p.getResources().getString(R.string.leftclick_multitouch),
|
||||
p.getResources().getString(R.string.leftclick_pressure),
|
||||
p.getResources().getString(R.string.leftclick_dpadcenter) };
|
||||
p.getResources().getString(R.string.leftclick_pressure) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_question);
|
||||
@@ -681,7 +686,7 @@ class Settings
|
||||
private static native void nativeSetTrackballUsed();
|
||||
private static native void nativeSetTrackballDampening(int value);
|
||||
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
|
||||
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod, int MoveMouseWithJoystick, int MaxForce, int MaxRadius);
|
||||
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod, int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius);
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
|
||||
@@ -114,10 +114,15 @@ int SDL_ANDROID_sFakeWindowHeight = 480;
|
||||
static int sdl_opengl = 0;
|
||||
static SDL_Window *SDL_VideoWindow = NULL;
|
||||
SDL_Surface *SDL_CurrentVideoSurface = NULL;
|
||||
static Uint32 SDL_VideoThreadID = 0;
|
||||
static int HwSurfaceCount = 0;
|
||||
static SDL_Surface ** HwSurfaceList = NULL;
|
||||
|
||||
static Uint32 SDL_VideoThreadID = 0;
|
||||
int SDL_ANDROID_InsideVideoThread()
|
||||
{
|
||||
return SDL_VideoThreadID == SDL_ThreadID();
|
||||
}
|
||||
|
||||
|
||||
static void SdlGlRenderInit();
|
||||
|
||||
@@ -262,7 +267,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
int bpp1;
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d", width, height);
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( ! SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return NULL;
|
||||
@@ -357,7 +362,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
*/
|
||||
void ANDROID_VideoQuit(_THIS)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
@@ -406,7 +411,7 @@ void ANDROID_PumpEvents(_THIS)
|
||||
|
||||
static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
@@ -485,7 +490,7 @@ static void ANDROID_FreeHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
@@ -517,7 +522,7 @@ static void ANDROID_FreeHWSurface(_THIS, SDL_Surface *surface)
|
||||
|
||||
static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
@@ -599,7 +604,7 @@ static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
||||
int bpp;
|
||||
SDL_Surface * converted = NULL;
|
||||
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
@@ -696,7 +701,7 @@ static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
||||
// We're only blitting HW surface to screen, no other options provided (and if you need them your app designed wrong)
|
||||
int ANDROID_HWBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
@@ -733,7 +738,7 @@ static int ANDROID_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 co
|
||||
{
|
||||
Uint8 r, g, b, a;
|
||||
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
@@ -757,7 +762,7 @@ static int ANDROID_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
|
||||
SDL_PixelFormat format;
|
||||
SDL_Surface * converted = NULL;
|
||||
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
@@ -779,7 +784,7 @@ static int ANDROID_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
|
||||
|
||||
static int ANDROID_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
@@ -800,7 +805,7 @@ static int ANDROID_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
|
||||
|
||||
static void ANDROID_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
/*
|
||||
// Crash to get stack trace and determine culprit thread
|
||||
@@ -826,7 +831,7 @@ static void ANDROID_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
||||
|
||||
static int ANDROID_FlipHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
@@ -887,7 +892,7 @@ static int ANDROID_FlipHWSurface(_THIS, SDL_Surface *surface)
|
||||
|
||||
void ANDROID_GL_SwapBuffers(_THIS)
|
||||
{
|
||||
if( SDL_VideoThreadID != SDL_ThreadID() )
|
||||
if( !SDL_ANDROID_InsideVideoThread() )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
|
||||
@@ -57,14 +57,16 @@ static int isTrackballUsed = 0;
|
||||
static int isMouseUsed = 0;
|
||||
|
||||
enum { RIGHT_CLICK_NONE = 0, RIGHT_CLICK_WITH_MULTITOUCH = 1, RIGHT_CLICK_WITH_PRESSURE = 2, RIGHT_CLICK_WITH_MENU_BUTTON = 3 };
|
||||
enum { LEFT_CLICK_NORMAL = 0, LEFT_CLICK_NEAR_CURSOR = 1, LEFT_CLICK_WITH_MULTITOUCH = 2, LEFT_CLICK_WITH_PRESSURE = 3, LEFT_CLICK_WITH_DPAD_CENTER = 4 };
|
||||
enum { LEFT_CLICK_NORMAL = 0, LEFT_CLICK_NEAR_CURSOR = 1, LEFT_CLICK_WITH_MULTITOUCH = 2, LEFT_CLICK_WITH_PRESSURE = 3 };
|
||||
static int leftClickMethod = LEFT_CLICK_NORMAL;
|
||||
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 moveMouseWithArrowKeys = 0;
|
||||
static int clickDoesNotMoveMouseX = -1, clickDoesNotMoveMouseY = -1;
|
||||
static int clickDoesNotMoveMouseXspeed = 0, clickDoesNotMoveMouseYspeed = 0;
|
||||
static int clickMouseWithDpadCenter = 0;
|
||||
static int moveMouseWithKbX = -1, moveMouseWithKbY = -1;
|
||||
static int moveMouseWithKbXspeed = 0, moveMouseWithKbYspeed = 0;
|
||||
static int moveMouseWithKbUpdateSpeedX = 0, moveMouseWithKbUpdateSpeedY = 0;
|
||||
static int maxForce = 0;
|
||||
static int maxRadius = 0;
|
||||
int SDL_ANDROID_isJoystickUsed = 0;
|
||||
@@ -208,24 +210,24 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
|
||||
if( SDL_ANDROID_ShowScreenUnderFinger )
|
||||
{
|
||||
// Move mouse by 1 pixel so it will force screen update and mouse-under-finger window will be removed
|
||||
if( clickDoesNotMoveMouseX >= 0 )
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(clickDoesNotMoveMouseX > 0 ? clickDoesNotMoveMouseX-1 : 0, clickDoesNotMoveMouseY);
|
||||
if( moveMouseWithKbX >= 0 )
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX > 0 ? moveMouseWithKbX-1 : 0, moveMouseWithKbY);
|
||||
else
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(x > 0 ? x-1 : 0, y);
|
||||
}
|
||||
clickDoesNotMoveMouseX = -1;
|
||||
clickDoesNotMoveMouseY = -1;
|
||||
clickDoesNotMoveMouseXspeed = 0;
|
||||
clickDoesNotMoveMouseYspeed = 0;
|
||||
moveMouseWithKbX = -1;
|
||||
moveMouseWithKbY = -1;
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbYspeed = 0;
|
||||
}
|
||||
if( action == MOUSE_DOWN )
|
||||
{
|
||||
if( (clickDoesNotMoveMouseX >= 0 || leftClickMethod == LEFT_CLICK_NEAR_CURSOR) &&
|
||||
if( (moveMouseWithKbX >= 0 || leftClickMethod == LEFT_CLICK_NEAR_CURSOR) &&
|
||||
abs(oldX - x) < SDL_ANDROID_sFakeWindowWidth / 4 && abs(oldY - y) < SDL_ANDROID_sFakeWindowHeight / 4 )
|
||||
{
|
||||
SDL_ANDROID_MainThreadPushMouseButton( SDL_PRESSED, SDL_BUTTON_LEFT );
|
||||
clickDoesNotMoveMouseX = oldX;
|
||||
clickDoesNotMoveMouseY = oldY;
|
||||
moveMouseWithKbX = oldX;
|
||||
moveMouseWithKbY = oldY;
|
||||
action == MOUSE_MOVE;
|
||||
}
|
||||
else
|
||||
@@ -243,31 +245,31 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
|
||||
}
|
||||
if( action == MOUSE_MOVE )
|
||||
{
|
||||
if( clickDoesNotMoveMouseX >= 0 )
|
||||
if( moveMouseWithKbX >= 0 )
|
||||
{
|
||||
if( abs(clickDoesNotMoveMouseX - x) > SDL_ANDROID_sFakeWindowWidth / 10 )
|
||||
clickDoesNotMoveMouseXspeed += clickDoesNotMoveMouseX > x ? -1 : 1;
|
||||
if( abs(moveMouseWithKbX - x) > SDL_ANDROID_sFakeWindowWidth / 10 )
|
||||
moveMouseWithKbXspeed += moveMouseWithKbX > x ? -1 : 1;
|
||||
else
|
||||
clickDoesNotMoveMouseXspeed = clickDoesNotMoveMouseXspeed * 2 / 3;
|
||||
if( abs(clickDoesNotMoveMouseY - y) > SDL_ANDROID_sFakeWindowHeight / 10 )
|
||||
clickDoesNotMoveMouseYspeed += clickDoesNotMoveMouseY > y ? -1 : 1;
|
||||
moveMouseWithKbXspeed = moveMouseWithKbXspeed * 2 / 3;
|
||||
if( abs(moveMouseWithKbY - y) > SDL_ANDROID_sFakeWindowHeight / 10 )
|
||||
moveMouseWithKbYspeed += moveMouseWithKbY > y ? -1 : 1;
|
||||
else
|
||||
clickDoesNotMoveMouseYspeed = clickDoesNotMoveMouseYspeed * 2 / 3;
|
||||
moveMouseWithKbYspeed = moveMouseWithKbYspeed * 2 / 3;
|
||||
|
||||
clickDoesNotMoveMouseX += clickDoesNotMoveMouseXspeed;
|
||||
clickDoesNotMoveMouseY += clickDoesNotMoveMouseYspeed;
|
||||
moveMouseWithKbX += moveMouseWithKbXspeed;
|
||||
moveMouseWithKbY += moveMouseWithKbYspeed;
|
||||
|
||||
if( abs(clickDoesNotMoveMouseX - x) > SDL_ANDROID_sFakeWindowWidth / 5 ||
|
||||
abs(clickDoesNotMoveMouseY - y) > SDL_ANDROID_sFakeWindowHeight / 5 )
|
||||
if( abs(moveMouseWithKbX - x) > SDL_ANDROID_sFakeWindowWidth / 5 ||
|
||||
abs(moveMouseWithKbY - y) > SDL_ANDROID_sFakeWindowHeight / 5 )
|
||||
{
|
||||
clickDoesNotMoveMouseX = -1;
|
||||
clickDoesNotMoveMouseY = -1;
|
||||
clickDoesNotMoveMouseXspeed = 0;
|
||||
clickDoesNotMoveMouseYspeed = 0;
|
||||
moveMouseWithKbX = -1;
|
||||
moveMouseWithKbY = -1;
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbYspeed = 0;
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
|
||||
}
|
||||
else
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(clickDoesNotMoveMouseX, clickDoesNotMoveMouseY);
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
|
||||
}
|
||||
else
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
|
||||
@@ -317,7 +319,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint
|
||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
|
||||
return;
|
||||
}
|
||||
if( key == KEYCODE_DPAD_CENTER && leftClickMethod == LEFT_CLICK_WITH_DPAD_CENTER )
|
||||
if( key == KEYCODE_DPAD_CENTER && clickMouseWithDpadCenter )
|
||||
{
|
||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
|
||||
return;
|
||||
@@ -374,12 +376,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetTrackballUsed) ( JNIEnv* env, jobject thiz)
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz, jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickMethod, jint MoveMouseWithJoystick, jint MaxForce, jint MaxRadius)
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||
jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickMethod,
|
||||
jint MoveMouseWithJoystick, jint ClickMouseWithDpad,
|
||||
jint MaxForce, jint MaxRadius)
|
||||
{
|
||||
isMouseUsed = 1;
|
||||
rightClickMethod = RightClickMethod;
|
||||
SDL_ANDROID_ShowScreenUnderFinger = ShowScreenUnderFinger;
|
||||
moveMouseWithArrowKeys = MoveMouseWithJoystick;
|
||||
clickMouseWithDpadCenter = ClickMouseWithDpad;
|
||||
leftClickMethod = LeftClickMethod;
|
||||
maxForce = MaxForce;
|
||||
maxRadius = MaxRadius;
|
||||
@@ -1010,7 +1016,10 @@ static int getNextEvent()
|
||||
while( nextEvent == BufferedEventsStart )
|
||||
{
|
||||
SDL_mutexV(BufferedEventsMutex);
|
||||
SDL_Delay(100);
|
||||
if( SDL_ANDROID_InsideVideoThread() )
|
||||
SDL_ANDROID_PumpEvents();
|
||||
else
|
||||
SDL_Delay(100);
|
||||
SDL_mutexP(BufferedEventsMutex);
|
||||
nextEvent = BufferedEventsEnd;
|
||||
nextEvent++;
|
||||
@@ -1064,45 +1073,61 @@ extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
|
||||
key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
|
||||
key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
|
||||
{
|
||||
if( clickDoesNotMoveMouseX < 0 )
|
||||
SDL_GetMouseState( &clickDoesNotMoveMouseX, &clickDoesNotMoveMouseY );
|
||||
if( moveMouseWithKbX < 0 )
|
||||
SDL_GetMouseState( &moveMouseWithKbX, &moveMouseWithKbY );
|
||||
|
||||
if( key == SDL_KEY(LEFT) )
|
||||
if( pressed )
|
||||
{
|
||||
if( clickDoesNotMoveMouseXspeed > 0 )
|
||||
clickDoesNotMoveMouseXspeed = 0;
|
||||
clickDoesNotMoveMouseXspeed --;
|
||||
}
|
||||
else if( key == SDL_KEY(RIGHT) )
|
||||
{
|
||||
if( clickDoesNotMoveMouseXspeed < 0 )
|
||||
clickDoesNotMoveMouseXspeed = 0;
|
||||
clickDoesNotMoveMouseXspeed ++;
|
||||
if( key == SDL_KEY(LEFT) )
|
||||
{
|
||||
if( moveMouseWithKbXspeed > 0 )
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbXspeed --;
|
||||
moveMouseWithKbUpdateSpeedX = -1;
|
||||
}
|
||||
else if( key == SDL_KEY(RIGHT) )
|
||||
{
|
||||
if( moveMouseWithKbXspeed < 0 )
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbXspeed ++;
|
||||
moveMouseWithKbUpdateSpeedX = 1;
|
||||
}
|
||||
|
||||
if( key == SDL_KEY(UP) )
|
||||
{
|
||||
if( moveMouseWithKbYspeed > 0 )
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbYspeed --;
|
||||
moveMouseWithKbUpdateSpeedY = -1;
|
||||
}
|
||||
else if( key == SDL_KEY(DOWN) )
|
||||
{
|
||||
if( moveMouseWithKbYspeed < 0 )
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbYspeed ++;
|
||||
moveMouseWithKbUpdateSpeedY = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
clickDoesNotMoveMouseXspeed = 0;
|
||||
|
||||
if( key == SDL_KEY(UP) )
|
||||
{
|
||||
if( clickDoesNotMoveMouseYspeed > 0 )
|
||||
clickDoesNotMoveMouseYspeed = 0;
|
||||
clickDoesNotMoveMouseYspeed --;
|
||||
if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
|
||||
{
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbUpdateSpeedX = 0;
|
||||
}
|
||||
if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
|
||||
{
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbUpdateSpeedY = 0;
|
||||
}
|
||||
}
|
||||
else if( key == SDL_KEY(DOWN) )
|
||||
{
|
||||
if( clickDoesNotMoveMouseYspeed < 0 )
|
||||
clickDoesNotMoveMouseYspeed = 0;
|
||||
clickDoesNotMoveMouseYspeed ++;
|
||||
}
|
||||
else
|
||||
clickDoesNotMoveMouseYspeed = 0;
|
||||
|
||||
clickDoesNotMoveMouseX += clickDoesNotMoveMouseXspeed;
|
||||
clickDoesNotMoveMouseY += clickDoesNotMoveMouseYspeed;
|
||||
moveMouseWithKbX += moveMouseWithKbXspeed;
|
||||
moveMouseWithKbY += moveMouseWithKbYspeed;
|
||||
|
||||
SDL_mutexV(BufferedEventsMutex);
|
||||
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(clickDoesNotMoveMouseX, clickDoesNotMoveMouseY);
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1121,6 +1146,7 @@ extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
|
||||
BufferedEventsEnd = nextEvent;
|
||||
SDL_mutexV(BufferedEventsMutex);
|
||||
};
|
||||
|
||||
extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
|
||||
{
|
||||
if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
|
||||
@@ -1245,3 +1271,15 @@ extern void SDL_ANDROID_MainThreadPushText( int scancode, int unicode )
|
||||
SDL_mutexV(BufferedEventsMutex);
|
||||
};
|
||||
|
||||
void SDL_ANDROID_processMoveMouseWithKeyboard()
|
||||
{
|
||||
moveMouseWithKbXspeed += moveMouseWithKbUpdateSpeedX;
|
||||
moveMouseWithKbYspeed += moveMouseWithKbUpdateSpeedY;
|
||||
|
||||
if( moveMouseWithKbXspeed != 0 || moveMouseWithKbYspeed != 0)
|
||||
{
|
||||
moveMouseWithKbX += moveMouseWithKbXspeed;
|
||||
moveMouseWithKbY += moveMouseWithKbYspeed;
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,6 +61,11 @@ static void ANDROID_PumpEvents(_THIS);
|
||||
|
||||
static int ANDROID_CreateWindow(_THIS, SDL_Window * window);
|
||||
static void ANDROID_DestroyWindow(_THIS, SDL_Window * window);
|
||||
static Uint32 SDL_VideoThreadID = 0;
|
||||
int SDL_ANDROID_InsideVideoThread()
|
||||
{
|
||||
return SDL_VideoThreadID == SDL_ThreadID();
|
||||
}
|
||||
|
||||
/* ANDROID driver bootstrap functions */
|
||||
|
||||
@@ -134,6 +139,8 @@ int ANDROID_VideoInit(_THIS)
|
||||
display.current_mode = mode;
|
||||
display.driverdata = NULL;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
|
||||
SDL_VideoThreadID = SDL_ThreadID();
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -177,7 +184,8 @@ void ANDROID_PumpEvents(_THIS)
|
||||
|
||||
void ANDROID_GL_SwapBuffers(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_ANDROID_CallJavaSwapBuffers();
|
||||
if( SDL_ANDROID_InsideVideoThread() )
|
||||
SDL_ANDROID_CallJavaSwapBuffers();
|
||||
};
|
||||
|
||||
SDL_GLContext ANDROID_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
|
||||
@@ -82,6 +82,7 @@ int SDL_ANDROID_CallJavaSwapBuffers()
|
||||
{
|
||||
SDL_ANDROID_drawTouchscreenKeyboard();
|
||||
SDL_ANDROID_processAndroidTrackballDampening();
|
||||
SDL_ANDROID_processMoveMouseWithKeyboard();
|
||||
}
|
||||
|
||||
// Clear part of screen not used by SDL - on Android the screen contains garbage after each frame
|
||||
|
||||
@@ -44,6 +44,8 @@ extern int SDL_ANDROID_drawTouchscreenKeyboard();
|
||||
extern void SDL_ANDROID_VideoContextLost();
|
||||
extern void SDL_ANDROID_VideoContextRecreated();
|
||||
extern void SDL_ANDROID_processAndroidTrackballDampening();
|
||||
extern void SDL_ANDROID_processMoveMouseWithKeyboard();
|
||||
extern int SDL_ANDROID_InsideVideoThread();
|
||||
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
Reference in New Issue
Block a user