Cleaned up mouse events implementation - should fix problems with double-clicking with left-click emulation set to "normal"
This commit is contained in:
@@ -115,6 +115,7 @@ int relativeMovementY = 0;
|
||||
unsigned int relativeMovementTime = 0;
|
||||
int oldMouseX = 0;
|
||||
int oldMouseY = 0;
|
||||
int oldMouseButtons = 0;
|
||||
|
||||
static inline int InsideRect(const SDL_Rect * r, int x, int y)
|
||||
{
|
||||
@@ -510,10 +511,9 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
|
||||
{
|
||||
int button = (leftClickMethod == LEFT_CLICK_WITH_PRESSURE) ? 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)) )
|
||||
if( button == SDL_BUTTON_RIGHT )
|
||||
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
|
||||
if( ( (SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(button)) != 0 ) != buttonState )
|
||||
SDL_ANDROID_MainThreadPushMouseButton( buttonState ? SDL_PRESSED : SDL_RELEASED, button );
|
||||
SDL_ANDROID_MainThreadPushMouseButton( buttonState ? SDL_PRESSED : SDL_RELEASED, button );
|
||||
}
|
||||
if( mouseInitialX >= 0 && mouseInitialY >= 0 && (
|
||||
leftClickMethod == LEFT_CLICK_WITH_TIMEOUT || leftClickMethod == LEFT_CLICK_WITH_TAP ||
|
||||
@@ -559,8 +559,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
|
||||
}
|
||||
else if( rightClickMethod == RIGHT_CLICK_WITH_MULTITOUCH )
|
||||
{
|
||||
if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) )
|
||||
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
|
||||
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
|
||||
SDL_ANDROID_MainThreadPushMouseButton( (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
|
||||
}
|
||||
}
|
||||
@@ -1155,7 +1154,11 @@ extern void SDL_ANDROID_PumpEvents()
|
||||
SDL_SendMouseMotion(NULL, 0, ev->motion.x, ev->motion.y);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
SDL_SendMouseButton( NULL, ev->button.state, ev->button.button );
|
||||
if( ((oldMouseButtons & SDL_BUTTON(ev->button.button)) != 0) != ev->button.state )
|
||||
{
|
||||
oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev->button.button)) | (ev->button.state ? SDL_BUTTON(ev->button.button) : 0);
|
||||
SDL_SendMouseButton( NULL, ev->button.state, ev->button.button );
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state);
|
||||
|
||||
Reference in New Issue
Block a user