8#ifndef LIBEVDEVXX_DEVICE_HPP
9#define LIBEVDEVXX_DEVICE_HPP
24#include <libevdev/libevdev.h>
53 using state_type = std::tuple<BaseType::state_type, int>;
58 log_helper(
const libevdev* dev,
59 libevdev_log_priority priority,
122 const std::filesystem::path& filename,
123 int flags = O_RDONLY | O_NONBLOCK);
171 const std::filesystem::path& filename,
172 int flags = O_RDONLY | O_NONBLOCK);
214 Device(
const std::filesystem::path& filename,
215 int flags = O_RDONLY | O_NONBLOCK);
255 create(const std::filesystem::path& filename,
256 int flags = O_RDONLY | O_NONBLOCK);
347 open(const std::filesystem::path& filename,
348 int flags = O_RDONLY | O_NONBLOCK);
384 std::optional<std::
string>
388 std::optional<std::
string>
479 std::optional<DelayPeriod>
629 libevdev_led_value value);
std::uint16_t get_bustype() const noexcept
bool has(Property prop) const noexcept
void set_fd(int fd)
Set a file descriptor and read the device metadata.
std::string get_name() const
void set_abs_res(Code code, int val) noexcept
void acquire(libevdev *new_raw, int new_fd) noexcept
void destroy() noexcept override
free all allocated resources and make the instance invalid.
void set_clock_id(int clockid)
void set_product(std::uint16_t pid) noexcept
int get_abs_fuzz(Code code) const noexcept
state_type release() noexcept
void disable(Property prop)
AbsInfo get_abs_info(Code code) const
void set_kernel_led_value(Code code, libevdev_led_value value)
void set_name(const std::string &name) noexcept
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.
void set_slot(unsigned slot, Code code, int value)
int get_value(Type type, Code code) const noexcept
int period
Definition Device.hpp:476
void set_abs_info(Code code, const AbsInfo &abs) noexcept
std::vector< Type > get_types() const
Device(const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK)
Construct from a device file path.
void set_abs_max(Code code, int val) noexcept
void enable_key(Code code)
std::uint16_t get_product() const noexcept
int get_num_slots() const
std::optional< std::string > get_uniq() const
void create(LogLevel priority)
Constructor to enable logging, in-place.
Device(LogLevel priority, const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK)
Constructor to enable logging and a device filename.
Device(int fd)
Construct form a device file descriptor.
std::optional< int > try_get_slot(unsigned slot, Code code) const noexcept
int delay
Definition Device.hpp:475
int get_abs_max(Code code) const noexcept
std::optional< std::string > get_phys() const
void set_abs_min(Code code, int val) noexcept
int get_abs_min(Code code) const noexcept
int get_slot(unsigned slot, Code code) const noexcept
void enable(Property prop)
void set_version(std::uint16_t ver) noexcept
int get_fd() const
Return the internal file descriptor used to access the device file.
bool is_open() const noexcept
Check if a file was opened with open().
void set_abs_fuzz(Code code, int val) noexcept
void set_phys(const std::string &phys) noexcept
std::optional< int > try_get_num_slots() const noexcept
void enable_abs(Code code, const AbsInfo &info)
int get_abs_res(Code code) const noexcept
void change_fd(int fd)
Change the file descriptor used internally, without re-reading the actual device.
Device(LogLevel priority, int fd)
Constructor to enable logging, and a non-owning device file descriptor.
void set_nonblock(bool enable)
Set the owned file handle's O_NONBLOCK flag.
void set_vendor(std::uint16_t vid) noexcept
void create(LogLevel priority, int fd)
Constructor to enable logging, and a non-owning device file descriptor, in-place.
std::uint16_t get_vendor() const noexcept
void set_uniq(const std::string &uniq) noexcept
void set_kernel_abs_info(Code code, const AbsInfo &abs)
int get_driver_version() const noexcept
void open(const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK)
Open a device file and set it for the device.
LogLevel
Helper enum to use the logging functions.
Definition Device.hpp:76
@ none
Invalid level.
Definition Device.hpp:77
@ debug
Debug level.
Definition Device.hpp:80
@ info
Information level.
Definition Device.hpp:79
@ error
Error level.
Definition Device.hpp:78
int get_current_slot() const noexcept
bool get_repeat(int &delay, int &period) const noexcept
void set_bustype(std::uint16_t bus) noexcept
std::vector< Property > get_properties() const
Event read(ReadFlag flags=ReadFlag::normal)
void enable_rel(Code code)
void ungrab()
Ungrab the device.
std::vector< Code > get_codes(Type type) const
void grab()
Grab the device through a EVIOCGRAB syscall.
void enable_rep(Code code, int arg)
int get_abs_flat(Code code) const noexcept
void set_value(Type type, Code code, int value)
std::uint16_t get_version() const noexcept
std::optional< int > try_get_value(Type type, Code code) const noexcept
std::optional< DelayPeriod > try_get_repeat() const noexcept
Device()
Default constructor.
Device(std::nullptr_t) noexcept
Construct invalid device.
void set_abs_flat(Code code, int val) noexcept
virtual void log(LogLevel priority, const char *file, int line, const char *func, const char *format, std::va_list args) const noexcept
Device(LogLevel priority)
Constructor to enable logging.
Definition Device.hpp:474
Definition Property.hpp:25
Definition basic_wrapper.hpp:21
raw_type data() noexcept
Definition basic_wrapper.hpp:102
The namespace of libevdevxx.
Definition AbsInfo.hpp:18
ReadFlag
Definition ReadFlag.hpp:19
@ normal
Definition ReadFlag.hpp:20
ReadStatus
Definition ReadStatus.hpp:20
Definition TypeCode.hpp:20
Maps to the input_absinfo struct from linux/input.h.
Definition AbsInfo.hpp:21
Type-safe class for evdev codes (KEY_*, BTN_*, REL_*, etc).
Definition Code.hpp:30