xorg-gtest 0.1
Xorg testing extension to Google Test
xorg::testing::evemu::Device Class Reference

evemu input device for replaying events through the Linux uinput evdev subsystem. More...

#include <xorg/gtest/evemu/xorg-gtest-device.h>

Public Member Functions

 Device (const std::string &path)
 Create a new device context. More...
 
void Play (const std::string &path) const
 Play a evemu recording through the device. More...
 
void PlayOne (int type, int code, int value, bool sync=false)
 Play a single event through the device. More...
 
const std::string & GetDeviceNode (void)
 Return the /dev/input/eventX device node for this device. More...
 
bool HasEvent (int type, int code)
 Check if a device supports a specific event. More...
 
bool GetAbsData (int code, int *min, int *max, int *fuzz=NULL, int *flat=NULL, int *resolution=NULL)
 Retrieve data about an absolute axis on this device. More...
 

Detailed Description

evemu input device for replaying events through the Linux uinput evdev subsystem.

Use the Recording class to play back a specific recording.

Constructor & Destructor Documentation

◆ Device()

xorg::testing::evemu::Device::Device ( const std::string &  path)
explicit

Create a new device context.

Parameters
[in]pathPath to evemu device property file.
Exceptions
std::runtime_errorif the device property file could not be found or the device could not be created.

Member Function Documentation

◆ GetAbsData()

bool xorg::testing::evemu::Device::GetAbsData ( int  code,
int *  min,
int *  max,
int *  fuzz = NULL,
int *  flat = NULL,
int *  resolution = NULL 
)

Retrieve data about an absolute axis on this device.

Parameters
[in]codeThe axis to query (e.g. ABS_X)
[out]minMin value for this axis
[out]maxMax value for this axis
[out]fuzzFuzz value for this axis
[out]flatFlat value for this axis
[out]resolutionResolution of this axis
Returns
false if this device doesn't have this axis, or true on success

◆ GetDeviceNode()

const std::string & xorg::testing::evemu::Device::GetDeviceNode ( void  )

Return the /dev/input/eventX device node for this device.

Note that evemu doesn't know the device node, so we traverse the file system looking for it. There is a tiny chance of the device node being wrong, or the device disappearing before we find it. If the device node cannot be found, an empty string is returned.

Returns
The string representing the device node

◆ HasEvent()

bool xorg::testing::evemu::Device::HasEvent ( int  type,
int  code 
)

Check if a device supports a specific event.

Parameters
[in]typeType of the event (EV_REL, EV_ABS, ...)
[in]codeEvent code (ABS_X, REL_Y, ...)
Returns
true if this device supports this event or false otherwise.

◆ Play()

void xorg::testing::evemu::Device::Play ( const std::string &  path) const

Play a evemu recording through the device.

Plays the recording from the beginning through the end. This call will block until the recording has finished.

Parameters
[in]pathPath to evemu recording file.
Exceptions
std::runtime_errorif playback failed for any reason.

◆ PlayOne()

void xorg::testing::evemu::Device::PlayOne ( int  type,
int  code,
int  value,
bool  sync = false 
)

Play a single event through the device.

Plays an event with the given type, code and value through the device.

Parameters
[in]typeEvdev interface event type, e.g. EV_ABS, EV_REL, EV_KEY.
[in]codeEvdev interface event code, e.g. ABS_X, REL_Y, BTN_LEFT
[in]valueEvent value
[in]syncIf true, submit an EV_SYN event after this event
Exceptions
std::runtime_errorif playback failed for any reason.

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