/// <summary> /// Move the absolute mouse to desired coordinate. /// </summary> /// <param name="x">Coordinate X</param> /// <param name="y">Coordinate Y </param> /// <exception cref="ArgumentException">If supplied with non-positive values or out of resolution range.</exception> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task MoveMouseToCoordinate(int x, int y) { if (x <= 0 || y <= 0 || x > MouseResolutionWidth || y > MouseResolutionHeight) { throw new ArgumentOutOfRangeException($"Mouse Coordinate {x},{y} is out of range {MouseResolutionWidth},{MouseResolutionHeight}!\n"); } SerialCommandFrame frame = SerialCommandFrame.OfCoordinateType(SerialSymbols.FrameType.MouseMove, new Tuple <ushort, ushort>((ushort)x, (ushort)y)); return(_sender.SendFrame(frame)); }
/// <summary> /// Set the absolute mouse's resolution. /// Note that in firmware, it has a limitation of 8K resolution. /// </summary> /// <param name="width">Width of resolution.</param> /// <param name="height">Height of resolution. </param> /// <exception cref="ArgumentException">If supplied with non-positive values</exception> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task SetMouseResolution(int width, int height) { if (width <= 0 || height <= 0) { throw new ArgumentException("Resolution values cannot be negative!"); } MouseResolutionWidth = width; MouseResolutionHeight = height; SerialCommandFrame frame = SerialCommandFrame.OfCoordinateType(SerialSymbols.FrameType.MouseResolution, new Tuple <ushort, ushort>((ushort)width, (ushort)height)); return(_sender.SendFrame(frame)); }