Toggle game mode

This commit is contained in:
Matthew McClaskey
2022-05-03 17:30:12 +00:00
parent d829572a9c
commit 774a61ace7
9 changed files with 91 additions and 10 deletions

View File

@@ -239,6 +239,40 @@ void vncPointerMove(int x, int y)
cursorPosY = y;
}
void vncPointerMoveRelative(int x, int y, int absx, int absy)
{
int valuators[2];
#if XORG < 111
int n;
#endif
#if XORG >= 110
ValuatorMask mask;
#endif
// if (cursorPosX == absx && cursorPosY == absy)
// return;
valuators[0] = x;
valuators[1] = y;
#if XORG < 110
n = GetPointerEvents(eventq, vncPointerDev, MotionNotify, 0,
POINTER_RELATIVE, 0, 2, valuators);
enqueueEvents(vncPointerDev, n);
#elif XORG < 111
valuator_mask_set_range(&mask, 0, 2, valuators);
n = GetPointerEvents(eventq, vncPointerDev, MotionNotify, 0,
POINTER_RELATIVE, &mask);
enqueueEvents(vncPointerDev, n);
#else
valuator_mask_set_range(&mask, 0, 2, valuators);
QueuePointerEvents(vncPointerDev, MotionNotify, 0,
POINTER_RELATIVE, &mask);
#endif
cursorPosX = absx;
cursorPosY = absy;
}
void vncScroll(int x, int y) {
ValuatorMask mask;
valuator_mask_zero(&mask);

View File

@@ -36,6 +36,8 @@ void vncInitInputDevice(bool freeKeyMappings);
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
const unsigned char skiprelease);
void vncPointerMove(int x, int y);
void vncPointerMoveRelative(int x, int y, int absx, int absy);
void vncScroll(int x, int y);
void vncGetPointerPos(int *x, int *y);

View File

@@ -461,12 +461,17 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
//
// SDesktop callbacks
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask,
void XserverDesktop::pointerEvent(const Point& pos, const Point& abspos, int buttonMask,
const bool skipClick, const bool skipRelease, int scrollX, int scrollY)
{
if (scrollX == 0 && scrollY == 0) {
vncPointerMove(pos.x + vncGetScreenX(screenIndex), pos.y + vncGetScreenY(screenIndex));
if (pos.equals(abspos)) {
vncPointerMove(pos.x + vncGetScreenX(screenIndex), pos.y + vncGetScreenY(screenIndex));
} else {
vncPointerMoveRelative(pos.x, pos.y,
abspos.x + vncGetScreenX(screenIndex),
abspos.y + vncGetScreenY(screenIndex));
}
vncPointerButtonAction(buttonMask, skipClick, skipRelease);
} else {
vncScroll(scrollX, scrollY);

View File

@@ -93,7 +93,7 @@ public:
const char* rejectMsg=0);
// rfb::SDesktop callbacks
virtual void pointerEvent(const rfb::Point& pos, int buttonMask,
virtual void pointerEvent(const rfb::Point& pos, const rfb::Point& abspos, int buttonMask,
const bool skipClick, const bool skipRelease, int scrollX = 0, int scrollY = 0);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
virtual unsigned int setScreenLayout(int fb_width, int fb_height,