|
DUDS
|
Distributed Update of Data from Something
|
Handles getting input from a specific input device using libevdev. More...
#include <EvdevInput.hpp>
Public Member Functions | |
| EvdevInput () | |
| Constructs an EvdevInput object without opening a device file. More... | |
| EvdevInput (const std::string &path) | |
| Creates a EvdevInput object that will read input from the given device file. More... | |
| EvdevInput (EvdevInput &&old) | |
| Move constructor. More... | |
| ~EvdevInput () | |
| Destructor. More... | |
| const input_absinfo * | absInfo (unsigned int absEc) const |
| Provides information about a specified absolute axis. More... | |
| boost::signals2::connection | connect (const InputHandlersSptr &ihs) |
| Connect the given InputHandlers to the end of the input event signal. More... | |
| boost::signals2::connection | connect (const InputSignal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back) |
| Make a connection to the input event signal. More... | |
| boost::signals2::connection | connect (const InputSignal::group_type &group, const InputSignal::slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back) |
| Make a connection to the input event signal. More... | |
| boost::signals2::connection | connectExtended (const InputSignal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back) |
| Make a connection to the input event signal. More... | |
| boost::signals2::connection | connectExtended (const InputSignal::group_type &group, const InputSignal::extended_slot_type &slot, boost::signals2::connect_position at=boost::signals2::at_back) |
| Make a connection to the input event signal. More... | |
| void | disconnect (const InputSignal::group_type &group) |
| Disconnect a group from the input event signal. More... | |
| template<typename Slot > | |
| void | disconnect (const Slot &slotFunc) |
| Disconnect a slot from the input event signal. More... | |
| void | disconnectAll () |
| Disconnects all slots from the input event signal. More... | |
| bool | eventsAvailable () const |
| Returns true if there are events awaiting processing on this device. More... | |
| bool | grab () |
| Attempts to gain exclusive access to the input device. More... | |
| bool | hasEvent (EventTypeCode etc) const |
| Returns true if the input device can produce events of the given type and code. More... | |
| bool | hasEventCode (unsigned int et, unsigned int ec) const |
| Returns true if the input device can produce events of the given type and code. More... | |
| bool | hasEventType (unsigned int et) const |
| Returns true if the input device can produce events of the given type. More... | |
| bool | hasMultitouchSlots () const |
| True if the input device has at least one multitouch slot. More... | |
| InputHandlersSptr | makeConnectedHandlers () |
| Makes a new InputHandlers object, connects it to the input event signal for this device, and retruns the object. More... | |
| std::string | name () const |
| Reports the name of the device using libevdev_get_name(). More... | |
| int | numMultitouchSlots () const |
| Returns the number of slots supported by a multitouch input device. More... | |
| void | open (const std::string &path) |
| Opens the given input device file. More... | |
| EvdevInput & | operator= (EvdevInput &&old) noexcept |
| Move assignment. More... | |
| void | respond (Poller *, int) |
| Same as calling respondToNextEvent(); used with Poller. More... | |
| void | respondToNextEvent () |
| Responds to the next input event on the device. More... | |
| void | usePoller (Poller &p) |
| Registers this object with the given Poller so that Poller::wait() will invoke respondToNextEvent(). More... | |
| int | value (EventTypeCode etc) const |
| Returns the current input value for the given event. More... | |
| int | value (unsigned int et, unsigned int ec) const |
| Returns the current input value for the given event. More... | |
Static Public Member Functions | |
| static std::shared_ptr< EvdevInput > | make (const std::string &path) |
| Creates a EvdevInput object managed by a std::shared_ptr. More... | |
Private Attributes | |
| InputSignal | defReceiver |
| Handles all input events. More... | |
| libevdev * | dev = nullptr |
| The object provided by libevdev that is needed to work with the input device. More... | |
| int | fd |
| The file descriptor to the input device file. More... | |
Handles getting input from a specific input device using libevdev.
A single InputSignal processes all input events from the device. If InputSignals for specific events are needed, use InputHandlers. These objects can be connected with custom code, or with connect(const InputHandlersSptr &). An InputHandlers object may be used with multiple EvdevInput objects.
This class is not thread-safe, but this should not be an issue.
If used with Poller, this object must be managed by a std::shared_ptr.
Definition at line 29 of file EvdevInput.hpp.
| duds::os::linux::EvdevInput::EvdevInput | ( | ) |
Constructs an EvdevInput object without opening a device file.
Before input events can be handled, open() must be called.
Definition at line 22 of file EvdevInput.cpp.
| duds::os::linux::EvdevInput::EvdevInput | ( | const std::string & | path | ) |
Creates a EvdevInput object that will read input from the given device file.
| path | The device file. This is normally some variation of "/dev/input/event[0-9]+". Read-only access will be requested. |
| EvdevFileOpenError | The device file could not be opened. |
| EvdevInitError | The attempt to initialize libevdev failed. An error code will be added to the exception in a boost::errinfo_errno attribute. |
Definition at line 24 of file EvdevInput.cpp.
| duds::os::linux::EvdevInput::EvdevInput | ( | EvdevInput && | old | ) |
Move constructor.
Definition at line 50 of file EvdevInput.cpp.
| duds::os::linux::EvdevInput::~EvdevInput | ( | ) |
| const input_absinfo * duds::os::linux::EvdevInput::absInfo | ( | unsigned int | absEc | ) | const |
Provides information about a specified absolute axis.
| absEc | The event code for the axis to query. It must be for an event of type EV_ABS. |
| EvdevUnsupportedEvent | The requested event lacks the information; either isn't an axis, or the axis is not provided by the input device. |
Definition at line 137 of file EvdevInput.cpp.
Referenced by value().
| boost::signals2::connection duds::os::linux::EvdevInput::connect | ( | const InputHandlersSptr & | ihs | ) |
Connect the given InputHandlers to the end of the input event signal.
| ihs | The InputHandlers object that should process events from this input device. |
Definition at line 147 of file EvdevInput.cpp.
Referenced by makeConnectedHandlers(), and value().
|
inline |
Make a connection to the input event signal.
See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.
Definition at line 230 of file EvdevInput.hpp.
|
inline |
Make a connection to the input event signal.
See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.
Definition at line 242 of file EvdevInput.hpp.
|
inline |
Make a connection to the input event signal.
See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.
Definition at line 255 of file EvdevInput.hpp.
|
inline |
Make a connection to the input event signal.
See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.
Definition at line 267 of file EvdevInput.hpp.
|
inline |
Disconnect a group from the input event signal.
See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.
Definition at line 280 of file EvdevInput.hpp.
|
inline |
Disconnect a slot from the input event signal.
See the Boost reference documentation for more details, or the tutorial for an overview of the whole boost::singals2 system.
Definition at line 292 of file EvdevInput.hpp.
|
inline |
Disconnects all slots from the input event signal.
Definition at line 298 of file EvdevInput.hpp.
| bool duds::os::linux::EvdevInput::eventsAvailable | ( | ) | const |
Returns true if there are events awaiting processing on this device.
When true, respondToNextEvent() will not block.
Definition at line 106 of file EvdevInput.cpp.
Referenced by value().
| bool duds::os::linux::EvdevInput::grab | ( | ) |
Attempts to gain exclusive access to the input device.
Definition at line 80 of file EvdevInput.cpp.
Referenced by make().
| bool duds::os::linux::EvdevInput::hasEvent | ( | EventTypeCode | etc | ) | const |
Returns true if the input device can produce events of the given type and code.
| etc | The event type and code to check. |
Definition at line 88 of file EvdevInput.cpp.
Referenced by hasEventCode(), and make().
|
inline |
Returns true if the input device can produce events of the given type and code.
| et | The event type to check. |
| ec | The event code to check. |
Definition at line 134 of file EvdevInput.hpp.
| bool duds::os::linux::EvdevInput::hasEventType | ( | unsigned int | et | ) | const |
Returns true if the input device can produce events of the given type.
| et | The event type to check. |
Definition at line 84 of file EvdevInput.cpp.
Referenced by make().
|
inline |
True if the input device has at least one multitouch slot.
Definition at line 148 of file EvdevInput.hpp.
|
inlinestatic |
Creates a EvdevInput object managed by a std::shared_ptr.
| path | The device file. This is normally some variation of "/dev/input/event[0-9]+". Read-only access will be requested. |
| EvdevFileOpenError | The device file could not be opened. |
| EvdevInitError | The attempt to initialize libevdev failed. An error code will be added to the exception in a boost::errinfo_errno attribute. |
Definition at line 81 of file EvdevInput.hpp.
| InputHandlersSptr duds::os::linux::EvdevInput::makeConnectedHandlers | ( | ) |
Makes a new InputHandlers object, connects it to the input event signal for this device, and retruns the object.
Definition at line 156 of file EvdevInput.cpp.
Referenced by value().
| std::string duds::os::linux::EvdevInput::name | ( | ) | const |
Reports the name of the device using libevdev_get_name().
Definition at line 76 of file EvdevInput.cpp.
Referenced by make().
| int duds::os::linux::EvdevInput::numMultitouchSlots | ( | ) | const |
Returns the number of slots supported by a multitouch input device.
Some such devices support 0 slots. If a device has no slot support, the value will be -1.
Definition at line 92 of file EvdevInput.cpp.
Referenced by hasEventCode(), and hasMultitouchSlots().
| void duds::os::linux::EvdevInput::open | ( | const std::string & | path | ) |
Opens the given input device file.
| path | The device file. This is normally some variation of "/dev/input/event[0-9]+". Read-only access will be requested. |
| EvdevFileOpenError | The device file could not be opened. |
| EvdevFileAlreadyOpenError | A device file is already open. |
| EvdevInitError | The attempt to initialize libevdev failed. An error code will be added to the exception in a boost::errinfo_errno attribute. |
Definition at line 28 of file EvdevInput.cpp.
Referenced by EvdevInput(), and make().
|
noexcept |
Move assignment.
Definition at line 67 of file EvdevInput.cpp.
Referenced by make().
|
virtual |
Same as calling respondToNextEvent(); used with Poller.
Implements duds::os::linux::PollResponder.
Definition at line 129 of file EvdevInput.cpp.
Referenced by value().
| void duds::os::linux::EvdevInput::respondToNextEvent | ( | ) |
Responds to the next input event on the device.
If there is currently no queued event, this function will block until an event is available. If there are one or more queued events, all queued events will be handled without blocking for more events.
The event processing is in a loop. The next event is read and then provided to the appropriate InputSignal for handling. The InputSignal is invoked directly; it runs on this thread, and no other events are read until the signal has completed. The loop will continue while no error has occured, and there are queued events. The queued event check will include events that have been queued during the time this function is running.
Definition at line 110 of file EvdevInput.cpp.
| void duds::os::linux::EvdevInput::usePoller | ( | Poller & | p | ) |
Registers this object with the given Poller so that Poller::wait() will invoke respondToNextEvent().
| p | The Poller object. |
Definition at line 133 of file EvdevInput.cpp.
Referenced by value().
| int duds::os::linux::EvdevInput::value | ( | EventTypeCode | etc | ) | const |
Returns the current input value for the given event.
| etc | The event type and code to check. |
| EvdevUnsupportedEvent | The event is not supplied by the input device. |
Definition at line 96 of file EvdevInput.cpp.
Referenced by hasMultitouchSlots(), and value().
|
inline |
Returns the current input value for the given event.
| et | The event type to check. |
| ec | The event code to check. |
| EvdevUnsupportedEvent | The event is not supplied by the input device. |
Definition at line 165 of file EvdevInput.hpp.
|
private |
Handles all input events.
Definition at line 37 of file EvdevInput.hpp.
Referenced by connect(), operator=(), and respondToNextEvent().
|
private |
The object provided by libevdev that is needed to work with the input device.
Definition at line 42 of file EvdevInput.hpp.
Referenced by absInfo(), eventsAvailable(), grab(), hasEvent(), hasEventType(), name(), numMultitouchSlots(), open(), operator=(), respondToNextEvent(), value(), and ~EvdevInput().
|
private |
The file descriptor to the input device file.
Definition at line 46 of file EvdevInput.hpp.
Referenced by open(), operator=(), usePoller(), and ~EvdevInput().