void UpdateMouse() { POINT p = new POINT(); Functions.GetCursorPos(ref p); mouse.X = p.X; mouse.Y = p.Y; // Note: we cannot poll the mouse wheel mouse[MouseButton.Left] = (Functions.GetAsyncKeyState(VirtualKeys.LBUTTON) >> 8) != 0; mouse[MouseButton.Middle] = (Functions.GetAsyncKeyState(VirtualKeys.RBUTTON) >> 8) != 0; mouse[MouseButton.Right] = (Functions.GetAsyncKeyState(VirtualKeys.MBUTTON) >> 8) != 0; mouse[MouseButton.Button1] = (Functions.GetAsyncKeyState(VirtualKeys.XBUTTON1) >> 8) != 0; mouse[MouseButton.Button2] = (Functions.GetAsyncKeyState(VirtualKeys.XBUTTON2) >> 8) != 0; }
internal static extern BOOL GetCursorPos(ref POINT point);
public static extern HMONITOR MonitorFromPoint(POINT pt, MonitorFrom dwFlags);
public MouseState GetCursorState() { // For simplicity, get hardware state // and simply overwrite its x and y location POINT p = new POINT(); Functions.GetCursorPos(ref p); var state = GetState(); state.X = p.X; state.Y = p.Y; return state; }
private void UpdateMouse() { POINT point = new POINT(); Functions.GetCursorPos(ref point); this.mouse.X = point.X; this.mouse.Y = point.Y; this.mouse[MouseButton.Left] = (int) Functions.GetAsyncKeyState(VirtualKeys.LBUTTON) >> 8 != 0; this.mouse[MouseButton.Middle] = (int) Functions.GetAsyncKeyState(VirtualKeys.RBUTTON) >> 8 != 0; this.mouse[MouseButton.Right] = (int) Functions.GetAsyncKeyState(VirtualKeys.MBUTTON) >> 8 != 0; this.mouse[MouseButton.Button1] = (int) Functions.GetAsyncKeyState(VirtualKeys.XBUTTON1) >> 8 != 0; this.mouse[MouseButton.Button2] = (int) Functions.GetAsyncKeyState(VirtualKeys.XBUTTON2) >> 8 != 0; }
public static IntPtr MonitorFromPoint(POINT pt, MonitorFrom dwFlags);
internal static bool GetCursorPos(ref POINT point);
internal static extern bool GetCursorPos(ref POINT point);