Files
Aeth3randClaude Opus 5.5 ca7e62ac8d Add Alvin library: input, capture, windows and vision
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>
2026-09-27 13:58:20 -04:00

63 lines
1.7 KiB
C++

#pragma once
#include <cstdint>
#include <optional>
#include <string_view>
#include <vector>
namespace alvin {
// Platform-neutral physical key identifiers. Names follow a US QWERTY layout
// but they identify key *positions*, the same way evdev codes and Win32
// scan codes do. Use Input::typeText() to produce characters instead.
enum class Key : std::uint16_t {
Unknown = 0,
A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9,
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
Escape, Enter, Tab, Backspace, Space,
Minus, Equal, LeftBracket, RightBracket, Backslash,
Semicolon, Apostrophe, Grave, Comma, Period, Slash,
CapsLock, NumLock, ScrollLock,
LeftShift, RightShift, LeftCtrl, RightCtrl, LeftAlt, RightAlt, LeftSuper, RightSuper,
Menu,
Insert, Delete, Home, End, PageUp, PageDown,
Left, Right, Up, Down,
PrintScreen, Pause,
Kp0, Kp1, Kp2, Kp3, Kp4, Kp5, Kp6, Kp7, Kp8, Kp9,
KpDecimal, KpDivide, KpMultiply, KpSubtract, KpAdd, KpEnter,
VolumeMute, VolumeDown, VolumeUp,
MediaPlayPause, MediaStop, MediaNext, MediaPrevious,
Count_,
};
enum class MouseButton : std::uint8_t {
Left,
Right,
Middle,
Back,
Forward,
};
// "ctrl", "a", "f5", "enter", "super", ... (case-insensitive).
std::optional<Key> keyFromName(std::string_view name);
std::string_view keyName(Key key);
// Parses a chord such as "ctrl+shift+t" into its keys, modifiers first as written.
std::optional<std::vector<Key>> parseChord(std::string_view chord);
bool isModifier(Key key);
} // namespace alvin