Introducing a new way to review your PRs.

Read the announcement

aprilnea / openlogi

⚡️A native, local-first alternative to Logitech Options+, written in Rust 🦀 — remap buttons, DPI, and SmartShift over HID++. No account, no telemetry.

View on GitHub

25 documents · Updated Nov 23, 2026

docs / camera-control

Camera control integration

The camera integration gives OpenLogi a product-level way to discover Logitech webcams, show a live preview, choose a preview stream, and change image settings that other camera apps can use. It also supplies camera-use state to the background agent so camera activity can drive linked device behavior without moving camera control through the input or overlay systems.

Product role

Camera device experience

The openlogi-camera crate is the camera boundary for the product. It treats supported Logitech webcams as standard USB Video Class (UVC) devices and presents discovery, permission, capture, stream selection, and control capabilities through one platform-neutral contract. The desktop app uses that contract as a camera detail experience beside the mouse, keyboard, and light experiences.

The crate supports Logitech cameras on macOS, Windows, and Linux when the platform has the required camera backend. Other camera brands are not part of this product path, and platforms without a backend return no usable camera capability.

References: crates/…/lib.rs• L1-18 crates/…/lib.rs• L334-365

Camera control boundary

Camera settings are device settings rather than app-only display settings. A change written through OpenLogi reaches the camera hardware, so applications such as video-call and recording tools see the same setting when they open the camera.

The camera path is separate from Logitech HID++ device control. Camera records have an operating-system capture identifier for opening the camera, while stream size and rate describe the OpenLogi preview session rather than a persistent camera setting. The usual HID route is not used for camera reads or writes. On macOS and Windows, camera settings use the camera's standard UVC control path and remain visible to other apps while the camera streams. This keeps webcam behavior behind the camera crate instead of coupling it to receiver or keyboard input code.

References: crates/…/lib.rs• L1-18 crates/…/stream_mode.rs• L1-14 crates/…/uvc_macos.rs• L1-19 crates/…/uvc_windows.rs• L1-15

Camera model

Device discovery and identity

Discovery finds connected Logitech UVC cameras and returns the name, operating-system capture identifier, USB identity, and available format information where the platform reports it. The desktop merges these results with its wider device list so a camera can be selected like another product device.

The system keeps two identities because they serve different purposes. The capture identifier opens the live device but can change when a camera moves to another USB port. The configuration key uses the USB serial when available and otherwise uses the vendor and product pair. This lets settings survive a port change, while the live capture identifier still distinguishes two serial-less cameras of the same model.

On Windows, discovery reads the DirectShow video-input category. It keeps USB sources, uses the device path as the capture identifier, and extracts the USB vendor and product IDs from that path. A real USB serial is used for the stable configuration key, while a parent-generated instance ID is rejected because it depends on the port.

Discovery also reports the largest known frame size and highest known frame rate as metadata where the backend can obtain them. On macOS, this information comes from the device's listed formats without opening a capture session or requesting camera permission. It describes the camera's reported capability, while the stream modes still describe the choices available to the current preview connection.

On Linux, several video nodes can belong to one physical camera. Discovery groups nodes by their shared USB device and chooses the main color node over a secondary monochrome node, so one camera does not appear as several products. On macOS, USB serial data is joined to the capture record by USB location, while the location in the capture identifier selects the same physical camera for control writes when identical cameras are attached.

References: crates/…/lib.rs• L273-321 crates/…/lib.rs• L354-365 crates/…/macos.rs• L37-132 crates/…/uvc_macos.rs• L319-439 crates/…/uvc_windows.rs• L103-117 crates/…/uvc_windows.rs• L403-432 crates/…/linux.rs• L40-126 crates/…/linux.rs• L141-180

Stream modes and USB connection

Stream modes describe the frame sizes and rates a camera can offer to the OpenLogi preview. The camera reports these choices for its current USB connection. A slower link can expose fewer choices than the camera is built to support, so the product can distinguish a camera limit from a connection limit when the platform provides that information.

The shared stream contract removes invalid and duplicate choices, presents larger frames and faster rates first, and chooses a practical default near 1280×720 at 30 frames per second. A saved choice is used only when the current camera still offers it. If the user changes the frame size, the preview keeps the current rate when possible and otherwise selects the nearest available rate.

References: crates/…/stream_mode.rs• L19-24 crates/…/stream_mode.rs• L81-198 crates/…/usb_link.rs• L67-87 crates/…/usb_link.rs• L147-173

Control vocabulary

The shared control vocabulary describes the settings that the user can understand across supported camera models. It covers lens controls such as zoom, pan, tilt, and focus. It also covers image controls such as brightness and contrast plus camera conditions such as power-line frequency and low-light compensation. Automatic modes exist for focus, exposure, and white balance.

Each camera reports only the controls it supports. For each reported manual control, the product receives a minimum, maximum, default, and current value. A camera can also report a discrete set of valid values instead of accepting every value in the range. Automatic modes are represented separately because they decide whether a manual value can take effect.

Control groupProduct behavior
Manual lens controlsExpose supported zoom, pan, tilt, and focus values.
Manual image and camera-condition controlsExpose supported image, anti-flicker, and low-light values.
Focus, exposure, and white balancePair a manual value with an optional automatic mode.
Automatic modesShow the live and default on/off state.

Platform support can differ even when a control has a shared name. macOS maps the vocabulary to standard UVC camera controls and reports lens controls only when the camera describes a camera terminal. Linux maps it through the kernel camera interface and does not expose tint. Windows maps lens and image controls through its camera interfaces. Power-line frequency and low-light compensation are reported as unsupported on Windows. The product must therefore build its control surface from the camera's reported state rather than from the full vocabulary.

When a profile targets several controls, the platform backends apply automatic modes before their dependent manual values. A manual value whose automatic mode is enabled in the same batch is omitted because the camera owns that value. Linux groups the remaining writes by its control classes and falls back to individual writes if a group is rejected. macOS attempts the remaining writes in the same device session and reports the first error after it has attempted the batch. Windows also attempts every requested auto and manual write, then reports the first error. Unsupported controls are skipped where possible, so a profile from a richer camera can still apply useful settings to a simpler model.

References: crates/…/controls.rs• L6-159 crates/…/uvc_macos.rs• L121-317 crates/…/uvc_linux.rs• L107-253 crates/…/uvc_windows.rs• L63-100 crates/…/uvc_windows.rs• L141-224

Desktop camera experience

Live preview

The desktop preview opens a camera stream only while the preview is visible. It asks for camera permission through the platform when needed, waits for the user decision, and then starts the stream without blocking the main window on the permission prompt. If startup fails, the preview keeps the selected camera in an error state and retries at a slow interval while the view remains selected.

The preview resolves the requested stream mode against the modes that the current camera connection offers. An unavailable saved choice falls back to the shared default, and a camera with no selectable modes uses a fixed preview preset. On macOS, the selected mode remains active for the life of the preview session, so the requested size and rate describe the frames shown by OpenLogi rather than a setting that other applications inherit.

The preview uses the latest delivered frame and updates the display only when a new frame arrives. Leaving the preview stops the stream and releases its image resources, so a camera is not left active after the user moves to another detail view. Changing cameras also cancels the old retry or repaint work before it can affect the new selection.

The preview and one-shot capture share the camera crate's capture boundary, but they serve different product needs. The preview consumes a continuing stream, while a snapshot returns one decoded frame. Capture backends can select or reduce frames near the preview target so the product avoids unnecessary high-resolution transfer work. Live previews are mirrored for the user's self-view, while snapshots preserve the camera frame.

Each capture operation keeps its own frame state. This keeps a snapshot and a live preview from consuming or replacing each other's frames when they overlap.

References: crates/…/preview.rs• L1-24 crates/…/preview.rs• L55-230 crates/…/preview.rs• L233-339 crates/…/capture_types.rs• L6-41 crates/…/stream_mode.rs• L152-198 crates/…/capture_macos.rs• L424-449 crates/…/capture_macos.rs• L539-583 crates/…/capture_macos.rs• L755-771 crates/…/capture_windows.rs• L84-186 crates/…/tests.rs• L128-186

Camera settings and profiles

The settings panel reads the camera's supported controls and builds a focused set of sliders and automatic-mode switches. A slider release writes the chosen value to the device. When an automatic mode owns a value, changing that value also takes the control back to manual mode.

OpenLogi stores the last accepted values under the camera configuration key and re-applies them when the camera is viewed again. Profiles group a complete camera state into a single user action. Built-in profiles provide default, streaming, and video-call starting points, while custom profiles save user snapshots.

The panel treats the camera as the source of truth after a failed write. It re-reads the device rather than keeping a value that the hardware may not have accepted. This matters because a grouped camera update can apply some settings and reject others. The platform backends surface that partial result instead of allowing the caller to treat the whole profile as accepted.

References: crates/…/controls.rs• L1-12 crates/…/controls.rs• L129-167 crates/…/controls.rs• L318-359 crates/…/controls.rs• L511-581 crates/…/controls.rs• L79-93 crates/…/uvc_linux.rs• L184-253 crates/…/uvc_macos.rs• L282-317 crates/…/uvc_windows.rs• L199-224 crates/…/camera.rs• L19-59

Permission state

Camera permission is modeled as granted, denied, or not yet decided. The desktop uses this state to show the right preview action and to avoid opening a camera before access is ready.

The permission flow belongs to camera capture, not to camera discovery. The app can list a camera from its metadata before it has permission to capture frames. This separation lets the user reach the consent action from the selected camera instead of hiding the device.

References: crates/…/lib.rs• L257-271 crates/…/macos.rs• L84-168 crates/…/capture_macos.rs• L235-327 crates/…/mod.rs• L5-32

Agent integration

Camera-use observation

The background agent observes whether any camera device is in use and publishes that result as aggregate camera-active state. On macOS, the watcher polls the system camera-use property. It covers physical webcams and other camera-like devices without depending on a specific meeting or recording app.

The camera crate exposes in-use capture identifiers as metadata without opening a camera or requiring camera permission. The watcher sends only state changes to the agent. It confirms an inactive state with repeated samples and keeps the last state when a probe fails. Other platforms currently provide an inert watcher, so camera-linked automation keeps its manual behavior there.

The following flow shows the boundary from operating-system camera use to agent state and then to linked device behavior.

flowchart LR
    OS[Operating-system camera use] --> Watcher[Agent camera-use watcher]
    Watcher -->|active or inactive transition| Orchestrator[Agent orchestrator]
    Orchestrator --> Observable[Published agent state]
    Orchestrator --> LinkedLights[Camera-linked light power]
    Observable --> Desktop[Desktop state and status]

References: crates/…/lib.rs• L368-381 crates/…/macos.rs• L134-164 crates/…/camera.rs• L1-6 crates/…/camera.rs• L16-105 crates/…/main.rs• L313-385 crates/…/observable.rs• L137-145

Camera-linked device behavior

The agent uses camera-active state as a temporary power signal for lights that opt into camera automation. An active camera turns those lights on, and an inactive camera turns them off. The agent does not replace the saved manual light setting; the camera signal changes only effective power while the automation applies.

This integration is one-way. The camera crate owns camera discovery and direct UVC control. The agent owns camera-use observation and linked-light policy. The desktop reaches the agent for general device state through the normal application boundary, but camera sliders do not use agent IPC for their hardware writes.

References: crates/…/orchestrator.rs• L517-560 crates/…/camera.rs• L41-60

Input-driven relationships

Input and overlay separation

Camera control does not observe global input, emit synthetic input, or draw transient overlay feedback. Those systems remain separate product paths for input observation, input emission, and on-screen feedback.

The camera feature can still participate in an input-driven experience through shared device selection and agent state. A future or existing input action may lead the user to a camera detail view, while camera use may change linked lights through the agent. The camera crate remains the hardware and capture boundary in both cases.

See Input and on-screen controls, Global input hooks, Synthetic input injection, and Visual overlay feedback for the neighboring boundaries.

References: crates/…/lib.rs• L23-81 crates/…/mod.rs• L1-4 crates/…/mod.rs• L1-12

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the camera configuration key and the live capture identifier separate. A change to either identity can affect persistence, selection, preview startup, and control writes.
  • Keep the control names aligned across the shared vocabulary, persisted camera settings, the desktop controls panel, and the CLI camera command.
  • Keep stream-mode ordering, default selection, saved-choice fallback, and the preview's displayed selection aligned across the camera crate and desktop UI.
  • When a USB-link scan changes, keep the reported link tied to the same camera identity and distinguish an unknown capability from a camera that cannot use a faster link.
  • When a control is added to the shared vocabulary, check each platform mapping and make unsupported controls fail closed rather than guess at another property.
  • When camera permission behavior changes, update both the desktop consent flow and the capture boundary. Discovery must remain usable before capture permission is granted.
  • When camera-use state changes, check the watcher, the agent event loop, the observable state, and camera-linked light policy as one contract.
  • When adding a supported platform, define both capture and UVC-control behavior. A platform can enumerate cameras without supporting live capture or control writes.
  • When capture startup or frame delivery changes, keep startup success tied to a decoded frame and keep cancellation from allowing a late frame to claim readiness.
  • When preview lifecycle changes, keep retries and frame repaint work tied to the selected target and release the stream and texture when that target is cleared.
  • When Linux discovery changes, preserve one product entry per physical USB camera and keep the primary color node ahead of secondary IR or depth nodes.
  • When changing batch control writes, keep automatic modes ahead of dependent manual values. Skip values handed to an auto mode in the same batch, preserve Linux class grouping and fallback, and retain macOS and Windows partial-write error reporting.
  • When Windows camera discovery changes, preserve the distinction between the live DirectShow device path and a real USB serial. Do not use a parent-generated instance ID as a stable configuration identity.
  • When macOS camera identity matching changes, preserve the USB location match for control writes and refuse an ambiguous location-less match instead of selecting an arbitrary camera.
  • When macOS metadata discovery changes, keep format and in-use reads metadata-only so device listing and camera-use observation do not require capture permission.

Important failure modes

TriggerConsequenceGuard
Camera permission is denied or remains undecidedThe camera can appear in the device list, but preview cannot startKeep discovery separate from capture and show the permission state in the preview surface
The requested stream mode is no longer offered by the current camera or linkPreview startup can fail or the UI can claim a mode that the stream does not useResolve saved and requested modes against the current list and show the resolved mode
The camera supports a faster USB link than its current connectionThe camera reports fewer stream choices than its hardware can provideCompare the current link with the camera's declared capability and treat the result as a connection limit
The operating-system capture identifier changes after a port moveA live open can miss the camera even though saved settings still existUse the capture identifier only for live access and the serial or model key for saved state
Two serial-less cameras share one modelThey have distinct live cards but share one saved settings bagReconcile live inventory by capture identifier and document the weaker persistence identity
Windows exposes a parent-generated instance ID instead of a real USB serialSaved settings can follow a port-specific identifier and fail to remain stableReject instance IDs that contain the parent path markers and fall back to the vendor and product identity
Linux exposes color and IR or depth nodes for one USB cameraThe same physical camera can appear more than once or the wrong node can become the targetGroup by USB device and prefer a color-capable node before comparing resolution
A camera rejects a grouped write after an earlier write succeedsThe hardware and panel can diverge, or a profile can describe a state that was not appliedRe-read live hardware state and clear the active profile after a failed batch
A control is absent or unsupported on a cameraA requested setting cannot be appliedBuild rows from the camera's reported controls and return a typed unsupported error
A shared control has no mapping in the platform camera APIThe setting is shown in the common vocabulary but cannot be read or written on that platformReport the control as unsupported and let the device state drive the UI
Capture startup ends before a decoded frame arrivesThe preview can report success without an image, or remain blocked on a dead streamTreat a stored decoded frame as startup readiness and classify timeout, access, resource, and setup errors separately
A Windows camera is held by another process or its system privacy toggle blocks accessPreview startup fails and the user may see an incorrect cause if all failures use one messageMap access denial to permission, map resource exhaustion to unavailable resources, and retry while the preview remains selected
A camera-use probe failsA transient probe error could turn linked lights off or on incorrectlyRetain the last state and confirm inactive transitions with consecutive samples
The camera watcher is unavailable on the current platformCamera-linked automation does not receive automatic state changesPreserve manual light power on platforms without a supported aggregate camera-use provider
A Linux control spans a platform control class or an auto mode still owns itA profile write can fail even though each setting is valid by itselfApply automatic changes first, omit values handed to enabled auto modes, and batch Linux values by control class
macOS cannot identify one camera uniquely during a control writeA write could target the wrong camera or fail to change the selected cameraMatch the USB location when available and refuse an ambiguous location-less match
macOS returns incomplete camera metadataThe camera can be listed without a useful capability summary, or a camera-use sample can miss a deviceTreat missing format fields as unknown and keep in-use observation separate from capture startup

Key files

FileWhy to read it
crates/…/lib.rsDefines the camera product boundary, discovery result, identity rules, permission model, platform capability, and camera-use metadata API.
crates/…/macos.rsShows the macOS metadata boundary for camera identity, supported formats, and camera-use observation without opening capture.
crates/…/controls.rsDefines the shared manual-control and automatic-mode vocabulary, batch ownership rules, and control errors.
crates/…/stream_mode.rsDefines the preview stream choices, ordering, defaults, and fallback rules.
crates/…/usb_link.rsDefines the distinction between the current USB link and the camera's declared capability.
crates/…/linux.rsShows Linux camera discovery, physical-device grouping, and primary color-node selection.
crates/…/capture_types.rsDefines the common frame and capture-error contract used by capture backends and the preview.
crates/…/capture_macos.rsShows the macOS capture, permission, stream-mode, and preview-session boundary.
crates/…/capture_windows.rsShows the Windows stream and snapshot boundary, startup readiness, frame delivery, and platform error mapping.
crates/…/uvc_linux.rsShows Linux control support, automatic-mode handling, grouped writes, fallback behavior, and unsupported-control handling.
crates/…/uvc_macos.rsShows how macOS camera settings reach the device, how camera identity is matched, and how batched writes report partial failure.
crates/…/uvc_windows.rsShows Windows camera discovery through DirectShow, stable-versus-live camera identity, shared-control mapping, automatic modes, and partial-write reporting.
crates/…/devices.rsShows how camera discovery joins the general device list and how live and saved identities differ.
crates/…/preview.rsExplains when the desktop starts and stops a preview, how permission affects that flow, and how failed starts retry.
crates/…/controls.rsExplains the user-facing control, profile, persistence, and resync behavior.
crates/…/camera.rsDefines the desktop persistence boundary and confirms that camera writes bypass agent IPC.
crates/…/camera.rsDefines camera-use observation and its platform and debounce behavior.
crates/…/main.rsShows where the camera watcher enters the agent event loop.
crates/…/orchestrator.rsShows how camera-active state affects camera-linked light power.
crates/…/observable.rsShows the state published for other processes to observe.