/** ** Called if the mouse is moved ** ** @param callbacks Callback structure for events. ** @param ticks Denotes time-stamp of video-system ** @param x X movement ** @param y Y movement */ void InputMouseMove(const EventCallback &callbacks, unsigned ticks, int x, int y) { // Don't reset the mouse state unless we really moved #ifdef USE_TOUCHSCREEN const int buff = 32; if (((x - buff) <= MouseX && MouseX <= (x + buff)) == 0 || ((y - buff) <= MouseY && MouseY <= (y + buff)) == 0) { MouseState = InitialMouseState; LastMouseTicks = ticks; } if (MouseX != x || MouseY != y) { MouseX = x; MouseY = y; } #else if (MouseX != x || MouseY != y) { MouseState = InitialMouseState; LastMouseTicks = ticks; MouseX = x; MouseY = y; } #endif const PixelPos pos(x, y); callbacks.MouseMoved(pos); }
/** ** Called if the mouse is moved ** ** @param callbacks Callback structure for events. ** @param ticks Denotes time-stamp of video-system ** @param x X movement ** @param y Y movement */ void InputMouseMove(const EventCallback &callbacks, unsigned ticks, int x, int y) { PixelPos mousePos(x, y); // Don't reset the mouse state unless we really moved #ifdef USE_TOUCHSCREEN const int buff = 32; const PixelDiff diff = LastMousePos - mousePos; if (abs(diff.x) > buff || abs(diff.y) > buff) { MouseState = InitialMouseState; LastMouseTicks = ticks; // Reset rectangle select cursor state if we moved by a lot // - rectangle select should be a drag, not a tap if (CursorState == CursorStateRectangle && (abs(diff.x) > 2 * buff || abs(diff.y) > 2 * buff)) { CursorState = CursorStatePoint; } } LastMousePos = mousePos; #else if (LastMousePos != mousePos) { MouseState = InitialMouseState; LastMouseTicks = ticks; LastMousePos = mousePos; } #endif callbacks.MouseMoved(mousePos); }