AntiMicroX
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
UInputEventHandler Class Reference

Input event handler class using uinput files. More...

#include <uinputeventhandler.h>

Inheritance diagram for UInputEventHandler:
[legend]
Collaboration diagram for UInputEventHandler:
[legend]

Public Member Functions

 UInputEventHandler (QObject *parent=nullptr)
 
 ~UInputEventHandler ()
 
virtual bool init () override
 Initialize keyboard and mouse virtual devices. Each device will use its own file handle with various codes set to distinquish the two devices. More...
 
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
 Move cursor to selected relative location (deltax delaty) More...
 
virtual void sendMouseAbsEvent (int xDis, int yDis, int screen) override
 Move cursor to selected absolute location (x, y) on selected display. More...
 
virtual void sendMouseSpringEvent (int xDis, int yDis, int width, int height) override
 Do nothing by default. Useful for child classes to define behavior. More...
 
virtual QString getName () override
 
virtual QString getIdentifier () override
 
virtual void printPostMessages () override
 Print extra help messages to stdout. More...
 
virtual void sendTextEntryEvent (QString maintext) override
 
int getKeyboardFileHandler ()
 
int getMouseFileHandler ()
 
int getSpringMouseFileHandler ()
 
const QString getUinputDeviceLocation ()
 
- Public Member Functions inherited from BaseEventHandler
 BaseEventHandler (QObject *parent=nullptr)
 
virtual ~BaseEventHandler ()
 
QString getErrorString ()
 

Protected Member Functions

int openUInputHandle ()
 
void setKeyboardEvents (int filehandle)
 
void setRelMouseEvents (int filehandle)
 
void setSpringMouseEvents (int filehandle)
 
void populateKeyCodes (int filehandle)
 
void createUInputKeyboardDevice (int filehandle)
 
void createUInputMouseDevice (int filehandle)
 
void createUInputSpringMouseDevice (int filehandle)
 
void closeUInputDevice (int filehandle)
 
void write_uinput_event (int filehandle, int type, int code, int value, bool syn=true)
 Write uinput event to selected file uinput file. More...
 

Private Member Functions

bool cleanupUinputEvHand ()
 
void testAndAppend (bool tested, QList< unsigned int > &tempList, unsigned int key)
 
void initDevice (int &device, QString name, bool &result)
 

Private Attributes

int keyboardFileHandler
 
int mouseFileHandler
 
int springMouseFileHandler
 
QString uinputDeviceLocation
 

Additional Inherited Members

- Protected Attributes inherited from BaseEventHandler
QString lastErrorString
 

Detailed Description

Input event handler class using uinput files.

Proper udev rule may be needed for usage General info https://kernel.org/doc/html/v5.15/input/uinput.html Event types https://www.kernel.org/doc/html/v5.15/input/event-codes.html

Constructor & Destructor Documentation

◆ UInputEventHandler()

UInputEventHandler::UInputEventHandler ( QObject *  parent = nullptr)
explicit

◆ ~UInputEventHandler()

UInputEventHandler::~UInputEventHandler ( )
Here is the call graph for this function:

Member Function Documentation

◆ cleanup()

bool UInputEventHandler::cleanup ( )
overridevirtual

Implements BaseEventHandler.

Here is the call graph for this function:

◆ cleanupUinputEvHand()

bool UInputEventHandler::cleanupUinputEvHand ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeUInputDevice()

void UInputEventHandler::closeUInputDevice ( int  filehandle)
protected
Here is the caller graph for this function:

◆ createUInputKeyboardDevice()

void UInputEventHandler::createUInputKeyboardDevice ( int  filehandle)
protected
Here is the caller graph for this function:

◆ createUInputMouseDevice()

void UInputEventHandler::createUInputMouseDevice ( int  filehandle)
protected
Here is the caller graph for this function:

◆ createUInputSpringMouseDevice()

void UInputEventHandler::createUInputSpringMouseDevice ( int  filehandle)
protected
Here is the caller graph for this function:

◆ getIdentifier()

QString UInputEventHandler::getIdentifier ( )
overridevirtual

Implements BaseEventHandler.

Here is the call graph for this function:

◆ getKeyboardFileHandler()

int UInputEventHandler::getKeyboardFileHandler ( )

◆ getMouseFileHandler()

int UInputEventHandler::getMouseFileHandler ( )

◆ getName()

QString UInputEventHandler::getName ( )
overridevirtual

Implements BaseEventHandler.

Here is the caller graph for this function:

◆ getSpringMouseFileHandler()

int UInputEventHandler::getSpringMouseFileHandler ( )

◆ getUinputDeviceLocation()

const QString UInputEventHandler::getUinputDeviceLocation ( )

◆ init()

bool UInputEventHandler::init ( )
overridevirtual

Initialize keyboard and mouse virtual devices. Each device will use its own file handle with various codes set to distinquish the two devices.

Returns

Implements BaseEventHandler.

Here is the call graph for this function:

◆ initDevice()

void UInputEventHandler::initDevice ( int &  device,
QString  name,
bool &  result 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ openUInputHandle()

int UInputEventHandler::openUInputHandle ( )
protected
Here is the caller graph for this function:

◆ populateKeyCodes()

void UInputEventHandler::populateKeyCodes ( int  filehandle)
protected
Here is the caller graph for this function:

◆ printPostMessages()

void UInputEventHandler::printPostMessages ( )
overridevirtual

Print extra help messages to stdout.

Reimplemented from BaseEventHandler.

◆ sendKeyboardEvent()

void UInputEventHandler::sendKeyboardEvent ( JoyButtonSlot slot,
bool  pressed 
)
overridevirtual

Implements BaseEventHandler.

Here is the call graph for this function:

◆ sendMouseAbsEvent()

void UInputEventHandler::sendMouseAbsEvent ( int  xDis,
int  yDis,
int  screen 
)
overridevirtual

Move cursor to selected absolute location (x, y) on selected display.

Do nothing by default. Useful for child classes to define behavior.

Parameters
Displacementof X coordinate
Displacementof Y coordinate
Screennumber or -1 to use default

Reimplemented from BaseEventHandler.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendMouseButtonEvent()

void UInputEventHandler::sendMouseButtonEvent ( JoyButtonSlot slot,
bool  pressed 
)
overridevirtual

Implements BaseEventHandler.

Here is the call graph for this function:

◆ sendMouseEvent()

void UInputEventHandler::sendMouseEvent ( int  xDis,
int  yDis 
)
overridevirtual

Move cursor to selected relative location (deltax delaty)

Implements BaseEventHandler.

Here is the call graph for this function:

◆ sendMouseSpringEvent()

void UInputEventHandler::sendMouseSpringEvent ( int  xDis,
int  yDis,
int  width,
int  height 
)
overridevirtual

Do nothing by default. Useful for child classes to define behavior.

Parameters
Displacementof X coordinate
Displacementof Y coordinate
Boundingbox width
Boundingbox height

Reimplemented from BaseEventHandler.

Here is the call graph for this function:

◆ sendTextEntryEvent()

void UInputEventHandler::sendTextEntryEvent ( QString  maintext)
overridevirtual

Reimplemented from BaseEventHandler.

Here is the call graph for this function:

◆ setKeyboardEvents()

void UInputEventHandler::setKeyboardEvents ( int  filehandle)
protected
Here is the caller graph for this function:

◆ setRelMouseEvents()

void UInputEventHandler::setRelMouseEvents ( int  filehandle)
protected
Here is the caller graph for this function:

◆ setSpringMouseEvents()

void UInputEventHandler::setSpringMouseEvents ( int  filehandle)
protected
Here is the caller graph for this function:

◆ testAndAppend()

void UInputEventHandler::testAndAppend ( bool  tested,
QList< unsigned int > &  tempList,
unsigned int  key 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_uinput_event()

void UInputEventHandler::write_uinput_event ( int  filehandle,
int  type,
int  code,
int  value,
bool  syn = true 
)
protected

Write uinput event to selected file uinput file.

Parameters
filehandle- C-style linux file handle obtained by open()
typetype of event described in input-event-codes.h (for example EV_ABS )
codeAdditional code like ABS_X for type EV_ABS
value
synsynchronize after event (emit additional event used for separation of events EV_SYN)
Here is the caller graph for this function:

Field Documentation

◆ keyboardFileHandler

int UInputEventHandler::keyboardFileHandler
private

◆ mouseFileHandler

int UInputEventHandler::mouseFileHandler
private

◆ springMouseFileHandler

int UInputEventHandler::springMouseFileHandler
private

◆ uinputDeviceLocation

QString UInputEventHandler::uinputDeviceLocation
private

The documentation for this class was generated from the following files: