Relative mouse movement implemented, witohut speed/accel though

This commit is contained in:
pelya
2011-02-07 18:42:54 +00:00
parent 0cb701bb24
commit 96ac2819ed
4 changed files with 44 additions and 7 deletions

View File

@@ -87,7 +87,7 @@ class Globals {
public static boolean RelativeMouseMovement = AppNeedsTwoButtonMouse; // Laptop touchpad mode
public static int RelativeMouseMovementSpeed = 0;
public static int RelativeMouseMovementAccel = 1;
public static boolean ShowScreenUnderFinger = AppNeedsTwoButtonMouse;
public static boolean ShowScreenUnderFinger = false;
public static boolean KeepAspectRatio = false;
public static int ClickScreenPressure = 0;
public static int ClickScreenTouchspotSize = 0;

View File

@@ -92,8 +92,11 @@ WMcursor * ANDROID_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h,
int ANDROID_ShowWMCursor(_THIS, WMcursor *cursor) {
return 1;
}
void ANDROID_WarpWMCursor(_THIS, Uint16 x, Uint16 y) { }
void ANDROID_MoveWMCursor(_THIS, int x, int y) { }
void ANDROID_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
SDL_ANDROID_WarpMouse(x, y);
}
//void ANDROID_MoveWMCursor(_THIS, int x, int y) { }
/* etc. */
@@ -185,7 +188,7 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex)
device->FreeWMCursor = ANDROID_FreeWMCursor;
device->CreateWMCursor = ANDROID_CreateWMCursor;
device->ShowWMCursor = ANDROID_ShowWMCursor;
//device->WarpWMCursor = ANDROID_WarpWMCursor;
device->WarpWMCursor = ANDROID_WarpWMCursor;
//device->MoveWMCursor = ANDROID_MoveWMCursor;
glLibraryHandle = dlopen("libGLESv1_CM.so", RTLD_NOW);

View File

@@ -103,13 +103,15 @@ int SDL_ANDROID_TouchscreenCalibrationX = 0;
int SDL_ANDROID_TouchscreenCalibrationY = 0;
int leftClickTimeout = 0;
int rightClickTimeout = 0;
int relativeMovement = 0;
int relativeMovementSpeed = 0;
int relativeMovementAccel = 0;
int mouseInitialX = -1;
int mouseInitialY = -1;
unsigned int mouseInitialTime = 0;
int deferredMouseTap = 0;
int relativeMovement = 0;
int relativeMovementSpeed = 0;
int relativeMovementAccel = 0;
int relativeMovementX = 0;
int relativeMovementY = 0;
static inline int InsideRect(const SDL_Rect * r, int x, int y)
{
@@ -363,6 +365,24 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
{
int oldX, oldY;
SDL_GetMouseState( &oldX, &oldY );
if( relativeMovement )
{
if( action == MOUSE_DOWN )
{
relativeMovementX = oldX - x;
relativeMovementY = oldY - y;
}
x += relativeMovementX;
y += relativeMovementY;
if( x < 0 )
x = 0;
if( x > SDL_ANDROID_sFakeWindowWidth )
x = SDL_ANDROID_sFakeWindowWidth;
if( y < 0 )
y = 0;
if( y > SDL_ANDROID_sFakeWindowHeight )
y = SDL_ANDROID_sFakeWindowHeight;
}
if( action == MOUSE_UP )
{
if( mouseInitialX >= 0 && mouseInitialY >= 0 && (
@@ -541,6 +561,19 @@ void ProcessDeferredMouseTap()
}
}
void SDL_ANDROID_WarpMouse(int x, int y)
{
if(!relativeMovement)
{
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
}
else
{
relativeMovementX = x;
relativeMovementY = y;
}
};
static int processAndroidTrackball(int key, int action);
JNIEXPORT void JNICALL

View File

@@ -54,6 +54,7 @@ extern int SDL_ANDROID_InsideVideoThread();
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
extern void SDL_ANDROID_ProcessDeferredEvents();
extern void SDL_ANDROID_initFakeStdout();
extern void SDL_ANDROID_WarpMouse(int x, int y);
#if SDL_VERSION_ATLEAST(1,3,0)
extern SDL_Window * ANDROID_CurrentWindow;