/// <summary> /// Send mouse click event to the streaming PC /// </summary> private void MouseUp(object sender, PointerRoutedEventArgs e) { PointerPoint ptrPt = e.GetCurrentPoint(StreamDisplay); if (e.Pointer.PointerDeviceType != PointerDeviceType.Mouse) { if (!hasMoved) { // We haven't moved so send a click MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Left); // Sleep here because some games do input detection by polling using (EventWaitHandle tmpEvent = new ManualResetEvent(false)) { tmpEvent.WaitOne(TimeSpan.FromMilliseconds(100)); } // Raise the mouse button MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Left); } } else { // Send changes and update the current state int deltaButtons = mouseButtonFlag ^ GetButtonFlags(ptrPt); if ((deltaButtons & MOUSE_BUTTON_LEFT) != 0) { MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Left); } if ((deltaButtons & MOUSE_BUTTON_MIDDLE) != 0) { MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Middle); } if ((deltaButtons & MOUSE_BUTTON_RIGHT) != 0) { MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Right); } mouseButtonFlag = GetButtonFlags(ptrPt); } e.Handled = true; }
/// <summary> /// Send mouse down event to the streaming PC /// </summary> private void MouseDown(object sender, PointerRoutedEventArgs e) { Pointer ptr = e.Pointer; PointerPoint ptrPt = e.GetCurrentPoint(StreamDisplay); // If using a mouse, then get the correct button if (ptr.PointerDeviceType == PointerDeviceType.Mouse) { // Send changes and update the current state int deltaButtons = mouseButtonFlag ^ GetButtonFlags(ptrPt); if ((deltaButtons & MOUSE_BUTTON_LEFT) != 0) { MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Left); } if ((deltaButtons & MOUSE_BUTTON_MIDDLE) != 0) { MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Middle); } if ((deltaButtons & MOUSE_BUTTON_RIGHT) != 0) { MoonlightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Right); } mouseButtonFlag = GetButtonFlags(ptrPt); } else { // We haven't moved yet hasMoved = false; lastX = (short)ptrPt.Position.X; lastY = (short)ptrPt.Position.Y; } e.Handled = true; }