/** ** Called each frame to handle mouse timeouts. ** ** @param callbacks Callback structure for events. ** @param ticks Denotes time-stamp of video-system */ void InputMouseTimeout(const EventCallback &callbacks, unsigned ticks) { if (MouseButtons & (1 << LastMouseButton)) { if (ticks > StartMouseTicks + DoubleClickDelay) { MouseState = InitialMouseState; } if (ticks > LastMouseTicks + HoldClickDelay) { LastMouseTicks = ticks; MouseButtons |= (1 << LastMouseButton) << MouseHoldShift; callbacks.ButtonPressed(LastMouseButton | (LastMouseButton << MouseHoldShift)); } } }
/** ** Called if any mouse button is pressed down ** ** Handles event conversion to double click, dragging, hold. ** ** FIXME: dragging is not supported. ** ** @param callbacks Callback structure for events. ** @param ticks Denotes time-stamp of video-system ** @param button Mouse button pressed. */ void InputMouseButtonPress(const EventCallback &callbacks, unsigned ticks, unsigned button) { // Button new pressed. if (!(MouseButtons & (1 << button))) { MouseButtons |= (1 << button); // Detect double click if (MouseState == ClickedMouseState && button == LastMouseButton && ticks < StartMouseTicks + DoubleClickDelay) { MouseButtons |= (1 << button) << MouseDoubleShift; button |= button << MouseDoubleShift; } else { MouseState = InitialMouseState; StartMouseTicks = ticks; LastMouseButton = button; } } LastMouseTicks = ticks; callbacks.ButtonPressed(button); }