RADLib
RADical C++ application framework

RADInput discovers Linux evdev devices from /dev/input and /sys/class/input. RADInput::InputManager can read raw input events on a background thread and emit them through RADCore events, optionally posted back to a target RADCore::EventLoop.

InputManager derives from RADCore::RADObject and is constructed with an optional InputPaths and an optional target RADCore::EventLoop*. InputManager::discover() returns InputDeviceInfo records (path, name, sysfsPath) for the event nodes it finds. InputManager::startDevice() begins reading a single evdev node on a background reader thread, while startHotplugMonitor() / stopHotplugMonitor() run a lightweight polling loop that re-scans devices at a configurable interval. stopAll() stops every active reader, and isRunning() reports whether any reader is live.

Events are delivered through the RAD_EVENT signals eventReceived, which carries a RADInput::InputEvent (device path, timestamp, Linux type, code, and value), and devicesChanged, which carries the updated device list when hotplug detection sees a change. When an EventLoop is supplied, emissions are posted back onto that loop's thread.

Use RADInput::Calibration to map raw touch/pointer coordinates into display-space coordinates. Its map() method applies the configured input and output ranges plus the invertX / invertY flags. Tests and embedded products can pass InputPaths to point the API at a fixture tree or alternate device root.

Core features:

  • evdev discovery from /dev/input and /sys/class/input.
  • Background raw event reading emitted through RADCore events.
  • Lightweight polling hotplug detection via devicesChanged.
  • Touch/pointer calibration with range mapping and axis inversion.
  • Injectable InputPaths for fixtures and embedded roots.

Example:

RADInput::InputManager input({}, &loop);
calibration.inMaxX = 4095.0;
calibration.inMaxY = 4095.0;
calibration.outMaxX = 1920.0;
calibration.outMaxY = 1080.0;
input.eventReceived.connect([&](const RADInput::InputEvent& event) {
auto [x, y] = calibration.map(event.value, event.value);
RADLOG_TRACE("input") << event.devicePath << " " << x << "," << y;
});
for (const auto& device : input.discover()) {
input.startDevice(device.path);
}
input.startHotplugMonitor(1000);
loop.run();
#define RADLOG_TRACE(category)
Logs with RADLogging at trace level.
Definition: RADLogging.h:108
RADCore task event loop with locked and low-latency scheduling strategies.
Definition: RADCore.h:988
Input manager that reads evdev events and emits RADCore events.
Definition: RADInput.h:84
2D touch/pointer calibration transform.
Definition: RADInput.h:57
double inMaxX
Input maximum X.
Definition: RADInput.h:61
Raw Linux input_event translated into RADInput form.
Definition: RADInput.h:41
std::string devicePath
Device path that produced the event.
Definition: RADInput.h:43
int32_t value
Linux event value.
Definition: RADInput.h:53