Commit Graph
2 Commits
Author SHA1 Message Date
brad eb303db316 Add keyboard, gamepad and directional-shortcut control
Three input methods for the gimbal, all sharing the widget's velocity model:
hold to move, release to stop.

Keyboard in the applet. WASD and the arrow keys feed the same tick timer the
pointer does, through a new vectorFromKeys helper. Opposing keys cancel and a
diagonal is normalised to length 1, so two keys do not move faster than one.
Auto-repeat is discarded, because it arrives as a press/release cycle and
would make the motion stutter. The held keys are cleared when the popup loses
focus: otherwise the matching release never arrives and the camera keeps
panning on its own. The buttons and zoom slider are set to Qt.NoFocus so the
arrow keys still reach the pad after one of them is clicked.

Gamepad support, as a separate process. Qt 6 removed QtGamepad and ships no
replacement, so the applet cannot read a controller itself. bin/linkctl-gamepad
reads /dev/input/js* directly using only the standard library: the event
struct is eight bytes and needs no third-party package. Defaults target a
DualSense on hid_playstation, but axis and button numbering comes from the
driver rather than the controller and varies between kernels and connection
modes, so --monitor prints live events for mapping and every number is
overridable. Opening a joystick replays the current state of every button with
JS_EVENT_INIT set; those are filtered, or a held button would fire its mapped
action at startup. --wait reconnects a wireless pad that sleeps.

Directional global shortcuts. Meta+Alt plus the arrow keys nudge the gimbal.
These are discrete steps by necessity: kglobalaccel fires once per keypress
and exposes no press-and-hold, so this cannot be smooth motion and the README
says so and points at the widget or a gamepad instead. NUDGE sets the degrees.

Tested: 145 checks across five suites, all passing, shellcheck clean, QML free
of syntax errors. 13 new node checks cover the key vector, including the
cancellation and diagonal-normalisation cases. 36 new python checks cover
event decoding, the INIT flag, deadzone rescaling and command construction.
A new FIFO-driven suite stands in for /dev/input/js* and plays scripted events
through the real select/read/decode/tick path, confirming diagonals emit both
axes, a centred stick goes quiet, a deadzone deflection moves nothing, a real
button press fires, the initial-state burst does not, and disconnect is
handled.

Not verified: no physical controller, camera or Plasma session was available,
so the synthetic events cannot confirm a real DualSense reports the assumed
axis and button numbers.
2026-10-07 22:16:52 -07:00
brad f7e42f7132 Add OBS and KDE hotkey integration for linkctl
Wraps linkctl so the Insta360 Link 2's AI tracking and gimbal presets are
reachable from a keypress and from OBS, instead of a terminal.

bin/linkctl-macro resolves the linkctl binary itself, because a desktop
shortcut is launched with a far sparser PATH than an interactive shell and
would otherwise just fail silently. It defaults to --force on the grounds
that a deliberate keypress means "act now" even when nothing holds the
camera open, which is precisely the state the Link parks itself in. Results
go to a desktop notification, since tracking state and gimbal position are
invisible otherwise, and linkctl's documented exit codes are mapped to
actionable text.

kde/install-shortcuts.sh registers Plasma global shortcuts via .desktop
entries plus kglobalshortcutsrc. These work under Wayland, where OBS's own
hotkeys only fire while OBS has focus. It writes with the shortcut daemon
stopped, because the daemon rewrites that file on exit and would discard the
entries. Supports --dry-run, --list and --uninstall.

obs/obs-linkctl.lua adds OBS hotkeys, test buttons, and scene-to-action
mapping, so switching scenes can set the camera state unattended. Its
startup action defaults to loading the home preset, which undoes the
gimbal's idle parking when OBS launches. Commands are backgrounded so the
OBS UI thread never waits on the camera, and identical commands within
250ms are collapsed to absorb the repeated events studio mode emits.

Tested: 22 offline Lua checks over shell quoting, action tokenizing, scene
map parsing and command construction; the wrapper exercised against a stub
linkctl for every documented exit code; the KDE installer dry-run, install,
list and uninstall paths run against stubbed Plasma tools in a throwaway
HOME. shellcheck clean. Not yet run against a live camera or a real Plasma
session.
2026-10-07 09:46:15 -07:00