A cross-platform C++23 library with a platform-neutral public API and runtime-selected backends: - Input: Wayland virtual pointer/keyboard (Hyprland, wlroots), libei via the RemoteDesktop portal (GNOME, KDE), uinput, and Win32 SendInput - Capture: ScreenCast portal + PipeWire, and Win32 GDI - Windows: Hyprland IPC and Win32 enumeration - Monitors via wl_output/xdg-output and EnumDisplayMonitors - Optional OpenCV template matching (alvin::vision) Also adds the `alvin` CLI, Catch2 unit tests, install rules with find_package(Alvin) support, API docs (docs/API.md and the Obsidian vault), and README instructions for both ways of consuming the library. Windows backends are written but not yet compiled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
965 B
C++
39 lines
965 B
C++
#pragma once
|
|
|
|
#include <expected>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace alvin {
|
|
|
|
enum class ErrorCode {
|
|
Unknown,
|
|
Unsupported, // backend or feature not available on this platform/session
|
|
NotAvailable, // backend compiled in but its service/device isn't present
|
|
PermissionDenied, // e.g. /dev/uinput not writable, portal request denied
|
|
Cancelled, // user dismissed a portal dialog
|
|
Timeout,
|
|
InvalidArgument,
|
|
NotFound,
|
|
Io,
|
|
Protocol, // unexpected reply from a compositor / portal / IPC socket
|
|
};
|
|
|
|
struct Error {
|
|
ErrorCode code = ErrorCode::Unknown;
|
|
std::string message;
|
|
};
|
|
|
|
template <class T>
|
|
using Result = std::expected<T, Error>;
|
|
|
|
using Status = Result<void>;
|
|
|
|
inline std::unexpected<Error> fail(ErrorCode code, std::string message) {
|
|
return std::unexpected(Error{code, std::move(message)});
|
|
}
|
|
|
|
std::string_view toString(ErrorCode code) noexcept;
|
|
|
|
} // namespace alvin
|