/// <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 LimelightCommonRuntimeComponent.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 LimelightCommonRuntimeComponent.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) { LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Left); } if ((deltaButtons & MOUSE_BUTTON_MIDDLE) != 0) { LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Middle); } if ((deltaButtons & MOUSE_BUTTON_RIGHT) != 0) { LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Right); } mouseButtonFlag = GetButtonFlags(ptrPt); } e.Handled = true; }
/// <summary> /// Send mouse click event to the streaming PC /// </summary> private void MouseUp(object sender, PointerRoutedEventArgs e) { if (!hasMoved) { // We haven't moved so send a click // TODO what even is this pointer crap. How do I send a click? LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Left); // Sleep here because some games do input detection by polling try { // TODO how do we sleep //Thread.Sleep(100); } catch (Exception ex) { Debug.WriteLine("Thread.sleep threw exception " + ex.StackTrace); } // Raise the mouse button LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Release, (int)MouseButton.Left); } }
/// <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) { LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Left); } if ((deltaButtons & MOUSE_BUTTON_MIDDLE) != 0) { LimelightCommonRuntimeComponent.SendMouseButtonEvent((byte)MouseButtonAction.Press, (int)MouseButton.Middle); } if ((deltaButtons & MOUSE_BUTTON_RIGHT) != 0) { LimelightCommonRuntimeComponent.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; }