Fixing scaled mouse movement

This commit is contained in:
r4m0n 2018-05-28 12:27:15 -03:00 committed by Geoffrey McRae
parent f715034fc4
commit 8cb25792ba

View File

@ -58,6 +58,7 @@ struct AppState
bool cursorVisible;
bool haveCursorPos;
float scaleX, scaleY;
float accX, accY;
const LG_Renderer * lgr ;
void * lgrData;
@ -487,6 +488,7 @@ int eventFilter(void * userdata, SDL_Event * event)
x -= state.cursor.x;
y -= state.cursor.y;
realignGuest = false;
state.accX = state.accY = 0;
if (!spice_mouse_motion(x, y))
DEBUG_ERROR("SDL_MOUSEMOTION: failed to send message");
@ -499,8 +501,12 @@ int eventFilter(void * userdata, SDL_Event * event)
{
if (params.scaleMouseInput)
{
x = (float)x * state.scaleX;
y = (float)y * state.scaleY;
state.accX += (float)x * state.scaleX;
state.accY += (float)y * state.scaleY;
x = floor(state.accX);
y = floor(state.accY);
state.accX -= x;
state.accY -= y;
}
if (!spice_mouse_motion(x, y))
{
@ -1530,4 +1536,4 @@ int main(int argc, char * argv[])
}
return ret;
}
}