/// <summary> /// Press mouse's button. /// </summary> /// <param name="button"> Button to press.</param> /// <see cref="SerialSymbols.MouseButton"/> /// <seealso cref="MouseReleaseButton"/> /// <seealso cref="MouseReleaseAllButtons"/> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task MousePressButton(SerialSymbols.MouseButton button) { CheckMouseButton(button); SerialCommandFrame frame = SerialCommandFrame.OfKeyType(SerialSymbols.FrameType.MousePress, (byte)button); return(_sender.SendFrame(frame)); }
/// <summary> /// Scroll the wheel /// </summary> /// <param name="value">Wheel delta</param> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task MouseScroll(sbyte value) { SerialCommandFrame frame = SerialCommandFrame.OfKeyType(SerialSymbols.FrameType.MouseScroll, (byte)value); return(_sender.SendFrame(frame)); }
/// <summary> /// Release the specific key. /// </summary> /// <param name="key">The HID usage id combined with modifiers.</param> /// <seealso cref="KeyboardPress"/> /// <seealso cref="KeyboardReleaseAll"/> /// <seealso cref="HidHelper.GetHidUsageFromPs2Set1"/> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task KeyboardRelease(byte key) { SerialCommandFrame frame = SerialCommandFrame.OfKeyType(SerialSymbols.FrameType.KeyboardRelease, key); return(_sender.SendFrame(frame).ContinueWith(task => _keyboardKeyStates[key] = false)); }
/// <summary> /// Release all keys. /// </summary> /// <seealso cref="KeyboardPress"/> /// <seealso cref="KeyboardRelease"/> /// <seealso cref="HidHelper.GetHidUsageFromPs2Set1"/> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task KeyboardReleaseAll() { SerialCommandFrame frame = SerialCommandFrame.OfKeyType(SerialSymbols.FrameType.KeyboardRelease, SerialSymbols.ReleaseAllKeys); return(_sender.SendFrame(frame).ContinueWith(task => Array.Fill(_keyboardKeyStates, false))); }
/// <summary> /// Release all mouse's buttons. /// </summary> /// <see cref="SerialSymbols.MouseButton"/> /// <seealso cref="MousePressButton"/> /// <seealso cref="MouseReleaseButton"/> /// <exception cref="SerialDeviceException">If command failed.</exception> public Task MouseReleaseAllButtons() { SerialCommandFrame frame = SerialCommandFrame.OfKeyType(SerialSymbols.FrameType.MouseRelease, SerialSymbols.ReleaseAllKeys); return(_sender.SendFrame(frame)); }