Skip to content

Commit

Permalink
fix: Broken spring mouse Event on Windows #518
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk authored Aug 18, 2022
2 parents 786bb79 + 907c2e8 commit 850d5c6
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 37 deletions.
11 changes: 0 additions & 11 deletions src/eventhandlers/baseeventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,4 @@ void BaseEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int h
Q_UNUSED(height);
}

/**
* @brief Do nothing by default. Useful for child classes to define behavior.
* @param Displacement of X coordinate
* @param Displacement of Y coordinate
*/
void BaseEventHandler::sendMouseSpringEvent(int xDis, int yDis)
{
Q_UNUSED(xDis);
Q_UNUSED(yDis);
}

void BaseEventHandler::sendTextEntryEvent(QString maintext) { Q_UNUSED(maintext); }
7 changes: 6 additions & 1 deletion src/eventhandlers/baseeventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

class JoyButtonSlot;

/**
* @brief Base class for input event handlers
*
* It manages mouse movements and keyboard strokes
*
*/
class BaseEventHandler : public QObject
{
Q_OBJECT
Expand All @@ -40,7 +46,6 @@ class BaseEventHandler : public QObject
virtual void sendMouseAbsEvent(int xDis, int yDis, int screen);

virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height);
virtual void sendMouseSpringEvent(int xDis, int yDis);

virtual void sendTextEntryEvent(QString maintext);

Expand Down
10 changes: 0 additions & 10 deletions src/eventhandlers/uinputeventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,6 @@ void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int
}
}

void UInputEventHandler::sendMouseSpringEvent(int xDis, int yDis)
{
if ((xDis >= -1.0) && (xDis <= 1.0) && (yDis >= -1.0) && (yDis <= 1.0))
{
int fx = ceil(32767 * xDis);
int fy = ceil(32767 * yDis);
sendMouseAbsEvent(fx, fy, -1);
}
}

int UInputEventHandler::openUInputHandle()
{
int filehandle = -1;
Expand Down
7 changes: 6 additions & 1 deletion src/eventhandlers/uinputeventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@

#include "baseeventhandler.h"

/**
* @brief Input event handler class using uinput files
*
* Proper udev rule may be needed for usage
*
*/
class UInputEventHandler : public BaseEventHandler
{
Q_OBJECT
Expand All @@ -37,7 +43,6 @@ class UInputEventHandler : public BaseEventHandler
virtual void sendMouseAbsEvent(int xDis, int yDis, int screen) override;

virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override;
virtual void sendMouseSpringEvent(int xDis, int yDis) override;

virtual QString getName() override;
virtual QString getIdentifier() override;
Expand Down
3 changes: 1 addition & 2 deletions src/eventhandlers/winsendinputeventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ QString WinSendInputEventHandler::getName() { return QString("SendInput"); }

QString WinSendInputEventHandler::getIdentifier() { return QString("sendinput"); }

void WinSendInputEventHandler::sendMouseSpringEvent(unsigned int xDis, unsigned int yDis, unsigned int width,
unsigned int height)
void WinSendInputEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int height)
{
if (width > 0 && height > 0)
{
Expand Down
24 changes: 15 additions & 9 deletions src/eventhandlers/winsendinputeventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@

#include <joybuttonslot.h>

/**
* @brief Input event handler class for Windows
*
* It utilizes SendInput functions
*
*/
class WinSendInputEventHandler : public BaseEventHandler
{
Q_OBJECT
public:
explicit WinSendInputEventHandler(QObject *parent = 0);

virtual bool init();
virtual bool cleanup();
virtual void sendKeyboardEvent(JoyButtonSlot *slot, bool pressed);
virtual void sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed);
virtual void sendMouseEvent(int xDis, int yDis);
virtual void sendMouseSpringEvent(unsigned int xDis, unsigned int yDis, unsigned int width, unsigned int height);
virtual void sendTextEntryEvent(QString maintext);
virtual bool init() override;
virtual bool cleanup() override;
virtual void sendKeyboardEvent(JoyButtonSlot *slot, bool pressed) override;
virtual void sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed) override;
virtual void sendMouseEvent(int xDis, int yDis) override;
virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override;
virtual void sendTextEntryEvent(QString maintext) override;

virtual QString getName();
virtual QString getIdentifier();
virtual QString getName() override;
virtual QString getIdentifier() override;

signals:

Expand Down
2 changes: 0 additions & 2 deletions src/eventhandlers/xtesteventhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,4 @@ void XTestEventHandler::sendMouseSpringEvent(int xDis, int yDis, int width, int
Q_UNUSED(height);
}

void XTestEventHandler::sendMouseSpringEvent(int, int) {}

void XTestEventHandler::printPostMessages() {}
1 change: 0 additions & 1 deletion src/eventhandlers/xtesteventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class XTestEventHandler : public BaseEventHandler
void sendMouseAbsEvent(int xDis, int yDis, int screen) override;

void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override;
void sendMouseSpringEvent(int xDis, int yDis) override;

void sendTextEntryEvent(QString maintext) override;

Expand Down

0 comments on commit 850d5c6

Please sign in to comment.