9#ifndef LIBEVDEVXX_DEVICE_HPP
10#define LIBEVDEVXX_DEVICE_HPP
21#include <libevdev/libevdev.h>
30#include "detail/ScopedFile.hpp"
39 error = LIBEVDEV_LOG_ERROR,
40 info = LIBEVDEV_LOG_INFO,
41 debug = LIBEVDEV_LOG_DEBUG
55 void operator()(::libevdev* dev)
const noexcept;
58 std::unique_ptr<::libevdev, Deleter> dev;
60 detail::ScopedFile owned_file;
108 const std::filesystem::path& filename,
109 int flags = O_RDONLY | O_NONBLOCK);
138 Device(
const std::filesystem::path& filename,
139 int flags = O_RDONLY | O_NONBLOCK);
148 const ::libevdev*
data() const noexcept;
191 void open(const std::filesystem::path& filename,
192 int flags = O_RDONLY | O_NONBLOCK);
206 const
char* file,
int line, const
char* func,
207 const
char* format, std::va_list args)
217 std::optional<std::
string>
phys() const;
218 std::optional<std::
string>
uniq() const;
281 void name(const std::
string& n);
Represents a device (real of not).
Definition: Device.hpp:52
std::vector< Type > types() const
int abs_res(Code code) const noexcept
bool has(Property prop) const noexcept
std::uint16_t product() const noexcept
Device(LogPriority priority, int filedes)
Constructor to enable logging, and a non-owning device file descriptor.
std::optional< int > num_slots() const noexcept
void set_clock_id(int clockid)
virtual void log(LogPriority p, const char *file, int line, const char *func, const char *format, std::va_list args) const
void disable(Property prop)
std::vector< Code > codes(Type type) const
void kernel_led_value(Code code, ::libevdev_led_value value)
int abs_flat(Code code) const noexcept
void set_slot(unsigned slot, Code code, int value)
Device(const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK)
Construct from a device file path.
int abs_max(Code code) const noexcept
void nonblock(bool enable)
std::optional< std::string > phys() const
std::uint16_t version() const noexcept
void enable_key(Code code)
std::vector< Property > properties() const
AbsInfo abs_info(Code code) const
::libevdev * data() noexcept
Access the internal ::libevdev object.
int get_slot(unsigned slot, Code code) const noexcept
void enable(Property prop)
int driver_version() const noexcept
bool is_open() const noexcept
std::uint16_t bustype() const noexcept
std::uint16_t vendor() const noexcept
void kernel_abs_info(Code code, const AbsInfo &abs)
std::optional< std::string > uniq() const
int get(Type type, Code code) const noexcept
int abs_min(Code code) const noexcept
Device(LogPriority priority, const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK)
Constructor to enable logging and a device filename.
void enable_abs(Code code, const AbsInfo &info)
Device(LogPriority priority)
Constructor to enable logging.
void change_fd(int fd)
Change the file descriptor used internally, without re-reading the actual device.
int abs_fuzz(Code code) const noexcept
virtual ~Device() noexcept
Device(int filedes)
Construct form a device file descriptor. The file descriptor is not owned.
void open(const std::filesystem::path &filename, int flags=O_RDONLY|O_NONBLOCK)
bool get_repeat(int &delay, int &period) const noexcept
int fd() const
Return the internal file descriptor used to access the device file.
void set(Type type, Code code, int value)
Event read(ReadFlag flags=ReadFlag::normal)
void enable_rel(Code code)
void ungrab()
Ungrab the device.
void grab()
Grab the device through a EVIOCGRAB syscall.
std::optional< int > fetch_slot(unsigned slot, Code code) const noexcept
void enable_rep(Code code, int arg)
int current_slot() const noexcept
std::optional< int > fetch(Type type, Code code) const noexcept
Device()
Default constructor.
Definition: Property.hpp:28
The namespace of libevdevxx.
Definition: AbsInfo.hpp:20
ReadFlag
Definition: ReadFlag.hpp:22
@ normal
Definition: ReadFlag.hpp:23
LogPriority
Helper enum to use the logging functions.
Definition: Device.hpp:37
ReadStatus
Definition: ReadStatus.hpp:23
Definition: TypeCode.hpp:23
Maps to the input_absinfo struct from linux/input.h.
Definition: AbsInfo.hpp:23
Type-safe class for evdev codes (KEY_*, BTN_*, REL_*, etc).
Definition: Code.hpp:32