libevdevxx 0.5.0
A C++ wrapper for libevdev.
|
Represents a device (real or not). More...
#include <Device.hpp>
Classes | |
struct | DelayPeriod |
Public Member Functions | |
Device (std::nullptr_t) noexcept | |
Construct invalid device. | |
Device () | |
Default constructor. | |
Device (int fd) | |
Construct form a device file descriptor. | |
Device (const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK) | |
Construct from a device file path. | |
~Device () noexcept | |
void | create () |
Create a new instance, in-place. | |
void | create (int fd) |
Construct form a device file descriptor, in-place. | |
void | create (const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK) |
Construct from a device file path, in-place. | |
void | destroy () noexcept override |
free all allocated resources and make the instance invalid. | |
Device (Device &&other) noexcept | |
Move constructor. | |
Device & | operator= (Device &&other) noexcept |
Move assignment. | |
void | acquire (libevdev *new_raw, int new_fd) noexcept |
void | acquire (state_type new_state) noexcept |
state_type | release () noexcept |
void | grab () |
Grab the device through a EVIOCGRAB syscall. | |
void | ungrab () |
Ungrab the device. | |
void | set_fd (int fd) |
Set a file descriptor and read the device metadata. | |
void | change_fd (int fd) |
Change the file descriptor used internally, without re-reading the actual device. | |
int | get_fd () const |
Return the internal file descriptor used to access the device file. | |
void | open (const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK) |
Open a device file and set it for the device. | |
bool | is_open () const noexcept |
Check if a file was opened with open(). | |
void | set_nonblock (bool enable) |
Set the owned file handle's O_NONBLOCK flag. | |
virtual void | log (LogLevel priority, const char *file, int line, const char *func, const char *format, std::va_list args) const noexcept |
std::string | get_name () const |
std::optional< std::string > | get_phys () const |
std::optional< std::string > | get_uniq () const |
std::uint16_t | get_product () const noexcept |
std::uint16_t | get_vendor () const noexcept |
std::uint16_t | get_bustype () const noexcept |
std::uint16_t | get_version () const noexcept |
int | get_driver_version () const noexcept |
bool | has (Property prop) const noexcept |
bool | has (Type type) const noexcept |
bool | has (Type type, Code code) const noexcept |
bool | has (const TypeCode &tc) const noexcept |
int | get_abs_min (Code code) const noexcept |
int | get_abs_max (Code code) const noexcept |
int | get_abs_fuzz (Code code) const noexcept |
int | get_abs_flat (Code code) const noexcept |
int | get_abs_res (Code code) const noexcept |
AbsInfo | get_abs_info (Code code) const |
int | get_value (Type type, Code code) const noexcept |
int | get_value (const TypeCode &tc) const noexcept |
std::optional< int > | try_get_value (Type type, Code code) const noexcept |
std::optional< int > | try_get_value (const TypeCode &tc) const noexcept |
bool | get_repeat (int &delay, int &period) const noexcept |
std::optional< DelayPeriod > | try_get_repeat () const noexcept |
int | get_slot (unsigned slot, Code code) const noexcept |
std::optional< int > | try_get_slot (unsigned slot, Code code) const noexcept |
int | get_num_slots () const |
std::optional< int > | try_get_num_slots () const noexcept |
int | get_current_slot () const noexcept |
void | set_name (const std::string &name) noexcept |
void | set_phys (const std::string &phys) noexcept |
void | set_uniq (const std::string &uniq) noexcept |
void | set_product (std::uint16_t pid) noexcept |
void | set_vendor (std::uint16_t vid) noexcept |
void | set_bustype (std::uint16_t bus) noexcept |
void | set_version (std::uint16_t ver) noexcept |
void | enable (Property prop) |
void | disable (Property prop) |
void | set_value (Type type, Code code, int value) |
void | set_value (const TypeCode &tc, int value) |
void | set_slot (unsigned slot, Code code, int value) |
void | set_abs_min (Code code, int val) noexcept |
void | set_abs_max (Code code, int val) noexcept |
void | set_abs_fuzz (Code code, int val) noexcept |
void | set_abs_flat (Code code, int val) noexcept |
void | set_abs_res (Code code, int val) noexcept |
void | set_abs_info (Code code, const AbsInfo &abs) noexcept |
void | enable (Type type) |
void | disable (Type type) |
void | enable (Type type, Code code) |
void | enable (const TypeCode &tc) |
void | enable_abs (Code code, const AbsInfo &info) |
void | enable_rep (Code code, int arg) |
void | disable (Type type, Code code) |
void | disable (const TypeCode &tc) |
void | set_kernel_abs_info (Code code, const AbsInfo &abs) |
void | set_kernel_led_value (Code code, libevdev_led_value value) |
void | set_clock_id (int clockid) |
Event | read (ReadFlag flags=ReadFlag::normal) |
ReadStatus | read (Event &event, ReadFlag flags=ReadFlag::normal) noexcept |
bool | has_pending () |
std::vector< Property > | get_properties () const |
std::vector< Type > | get_types () const |
std::vector< Code > | get_codes (Type type) const |
std::vector< Code > | get_codes (Type type, Code max) const |
void | enable_key (Code code) |
void | enable_rel (Code code) |
void | enable_abs (Code code) |
![]() | |
constexpr | basic_wrapper () noexcept=default |
constexpr | basic_wrapper (libevdev *src) noexcept |
constexpr | basic_wrapper (basic_wrapper &&other) noexcept |
Move constructor. | |
basic_wrapper & | operator= (basic_wrapper &&other) noexcept |
Move assignment. | |
bool | is_valid () const noexcept |
operator bool () const noexcept | |
raw_type | data () noexcept |
const raw_type | data () const noexcept |
void | acquire (state_type new_state) noexcept |
state_type | release () noexcept |
constexpr | basic_wrapper () noexcept=default |
constexpr | basic_wrapper (libevdev *src) noexcept |
constexpr | basic_wrapper (basic_wrapper &&other) noexcept |
Move constructor. | |
basic_wrapper & | operator= (basic_wrapper &&other) noexcept |
Move assignment. | |
bool | is_valid () const noexcept |
operator bool () const noexcept | |
raw_type | data () noexcept |
const raw_type | data () const noexcept |
void | acquire (state_type new_state) noexcept |
state_type | release () noexcept |
Protected Types | |
enum class | LogLevel { none = -1 , error = LIBEVDEV_LOG_ERROR , info = LIBEVDEV_LOG_INFO , debug = LIBEVDEV_LOG_DEBUG } |
Helper enum to use the logging functions. More... | |
Protected Member Functions | |
Device (LogLevel priority) | |
Constructor to enable logging. | |
Device (LogLevel priority, int fd) | |
Constructor to enable logging, and a non-owning device file descriptor. | |
Device (LogLevel priority, const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK) | |
Constructor to enable logging and a device filename. | |
void | create (LogLevel priority) |
Constructor to enable logging, in-place. | |
void | create (LogLevel priority, int fd) |
Constructor to enable logging, and a non-owning device file descriptor, in-place. | |
void | create (LogLevel priority, const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK) |
Constructor to enable logging and a device filename, in-place. | |
![]() | |
~basic_wrapper () noexcept=default | |
~basic_wrapper () noexcept=default | |
Additional Inherited Members | |
![]() | |
using | raw_type |
using | state_type |
![]() | |
static constexpr raw_type | invalid_value |
static constexpr raw_type | invalid_value |
![]() | |
libevdev * | raw |
libevdev * | raw |
Represents a device (real or not).
In order to use the logging function, the log() method must be overridden in a derived class, and a protected constructor (that takes a Device::LogLevel argument) must be called explicitly.
|
strongprotected |
Constructor to enable logging, and a non-owning device file descriptor.
priority | The priority level; the log() method will only be called when the message has this priority or above. |
fd | File descriptor fot the device file (from /dev/input/event* ) that will be used for I/O. Ownership is not taken over this, so the file will not be closed on destruction. |
|
protected |
Constructor to enable logging and a device filename.
priority | The priority level; the log() method will only be called when the message has this priority or above. |
filename | Path to to an evdev device (from /dev/input/event* ) that will be open by this device. |
flags | Flags used in the open system call. |
|
noexcept |
Construct invalid device.
In an invalid state, most operations are not allowed. You can safely destroy, move and check for validity.
Device | ( | ) |
Device | ( | int | fd | ) |
Construct form a device file descriptor.
The file descriptor is not owned: it won't be closed during destruction.
Device | ( | const std::filesystem::path & | filename, |
int | flags = O_RDONLY|O_NONBLOCK ) |
Construct from a device file path.
|
noexcept |
|
noexcept |
|
noexcept |
void change_fd | ( | int | fd | ) |
Change the file descriptor used internally, without re-reading the actual device.
This is only useful if you need to close and reopen the file descriptor.
void create | ( | ) |
void create | ( | const std::filesystem::path & | filename, |
int | flags = O_RDONLY|O_NONBLOCK ) |
Construct from a device file path, in-place.
void create | ( | int | fd | ) |
Construct form a device file descriptor, in-place.
The file descriptor is not owned: it won't be closed during destruction.
|
protected |
|
protected |
Constructor to enable logging and a device filename, in-place.
priority | The priority level; the log() method will only be called when the message has this priority or above. |
filename | Path to to an evdev device (from /dev/input/event* ) that will be open by this device. |
flags | Flags used in the open system call. |
|
protected |
Constructor to enable logging, and a non-owning device file descriptor, in-place.
priority | The priority level; the log() method will only be called when the message has this priority or above. |
fd | File descriptor fot the device file (from /dev/input/event* ) that will be used for I/O. Ownership is not taken over this, so the file will not be closed on destruction. |
|
overridevirtualnoexcept |
free all allocated resources and make the instance invalid.
The result is the same as if this object was moved from.
Implements basic_wrapper< libevdev * >.
void disable | ( | const TypeCode & | tc | ) |
void disable | ( | Property | prop | ) |
void disable | ( | Type | type | ) |
void enable | ( | const TypeCode & | tc | ) |
void enable | ( | Property | prop | ) |
void enable | ( | Type | type | ) |
void enable_abs | ( | Code | code | ) |
void enable_key | ( | Code | code | ) |
void enable_rel | ( | Code | code | ) |
void enable_rep | ( | Code | code, |
int | arg ) |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
int get_fd | ( | ) | const |
Return the internal file descriptor used to access the device file.
std::string get_name | ( | ) | const |
int get_num_slots | ( | ) | const |
std::optional< std::string > get_phys | ( | ) | const |
|
noexcept |
std::vector< Property > get_properties | ( | ) | const |
|
noexcept |
|
noexcept |
std::vector< Type > get_types | ( | ) | const |
std::optional< std::string > get_uniq | ( | ) | const |
|
noexcept |
|
noexcept |
|
noexcept |
void grab | ( | ) |
|
noexcept |
|
noexcept |
|
noexcept |
bool has_pending | ( | ) |
|
noexcept |
Check if a file was opened with open().
|
virtualnoexcept |
void open | ( | const std::filesystem::path & | filename, |
int | flags = O_RDONLY|O_NONBLOCK ) |
|
noexcept |
Event read | ( | ReadFlag | flags = ReadFlag::normal | ) |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
void set_clock_id | ( | int | clockid | ) |
void set_fd | ( | int | fd | ) |
Set a file descriptor and read the device metadata.
You can only call this function once.
void set_kernel_led_value | ( | Code | code, |
libevdev_led_value | value ) |
|
noexcept |
void set_nonblock | ( | bool | enable | ) |
Set the owned file handle's O_NONBLOCK
flag.
|
noexcept |
|
noexcept |
void set_slot | ( | unsigned | slot, |
Code | code, | ||
int | value ) |
|
noexcept |
void set_value | ( | const TypeCode & | tc, |
int | value ) |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
void ungrab | ( | ) |