Skip to content

obs-hotkey: Port libobs/obs-hotkey-name-map.c - #835

Merged
zackees merged 3 commits into
masterfrom
port/hotkey-name-map-rust
Oct 15, 2026
Merged

zackees merged 3 commits into
masterfrom
port/hotkey-name-map-rust

Conversation

@zackees

@zackees zackees commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Refs #833.

RED (obs-hotkey: Test the hotkey name map port against todo!() stubs): new obs-hotkey crate with obs_key_to_name/obs_key_from_name shims and a hidden no-op obs_hotkey_name_map_free (rust-hidden.txt, rust-exports.map, rust-unexports-macos.txt), over todo!() cores. Tier 1 aborts on todo!("hotkey name map port (#833)") in test_without_core.

  • Tier 1 tests/hotkey_name_map.rs: 1:1 port of test_hotkey_name_map (test: Characterize obs-hotkey-name-map.c before port #834).
  • Tier 2 ENABLE_RUST_LIBOBS=ON drops obs-hotkey-name-map.c.
  • Tier 3 tests/parity.rs: every code 0..2000 and every name, plus random names and codes, against the original compiled as oracle_*, both without a core (C's linear scan) and with a zeroed one (C's name map), so both C paths are compared.

The key table is generated at build time from obs-hotkeys.h: 636 entries, OBS_MOUSE_BUTTON keys included.

GREEN (obs-hotkey: Port libobs/obs-hotkey-name-map.c): one lazily built map from name to the first key with that name serves both of C's paths, which give the same answers. obs_key_to_name logs C's error for unknown codes. The obs->hotkeys.name_map field stays in obs-internal.h, unused.

Intentional differences (where C has undefined behavior): a null name returns OBS_KEY_NONE; a negative code logs and returns "".

Local:

  • Tier 1 and Tier 3 green; ci/local_gate.py --lane rust-test ok.
  • Mutation: an off-by-one in key_name fails every_key_matches.
  • Tier 2 rust/tools/linux-validate/run.sh: 247/247 OFF and ON, hotkey callers repeated.
  • ./lint ok.

A first Tier 2 run failed test_vlc_playlist_gap in the ON build (an audio timestamp jump cut 1.9 s of a file under load); it passed on rerun and does not use key names.

New obs-hotkey crate: obs_key_to_name and obs_key_from_name shims, and
a hidden no-op obs_hotkey_name_map_free, over todo!() cores. The key
table is generated from obs-hotkeys.h (636 entries, mouse buttons
included).
- Tier 1 (tests/hotkey_name_map.rs): 1:1 port of test_hotkey_name_map.
- Tier 3 (tests/parity.rs): every code and name, random names and
  codes, against obs-hotkey-name-map.c compiled as oracle_*, both
  without a core (linear scan) and with one (the name map).
- ENABLE_RUST_LIBOBS=ON drops obs-hotkey-name-map.c.

Refs #833
One lazily built map from key name to the first key with that name
serves both of C's paths (no core and after obs_startup), which give the
same answers. obs_key_to_name logs the same error for unknown codes.
The obs->hotkeys.name_map field stays in obs-internal.h, unused.

Refs #833
@zackees
zackees force-pushed the port/hotkey-name-map-rust branch from f4a5660 to 6520f6b Compare October 15, 2026 19:11
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

#834 merged; rebased onto master: replaced head f4a5660dc with 6520f6be7 (RED and GREEN only), verified on the remote.

…n clang

obs_key_from_name returns an int as obs_key_t, which clang treats as
unsigned; the oracle's -Wsign-conversion failed the macOS and cross
builds. libobs itself does not use the flag.

Refs #833
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Cross Lint and macOS Rust Tests failed: clang's -Wsign-conversion (the oracle's flag, not libobs's) rejects return v; (int → obs_key_t) in the original obs-hotkey-name-map.c. Silenced for that one include in oracle/hotkey_name_map.c (d3512a8d1); ci/local_gate.py --lane cross passes locally.

@zackees
zackees added this pull request to the merge queue Oct 15, 2026
Merged via the queue into master with commit 2d2c40c Oct 15, 2026
23 checks passed
@zackees
zackees deleted the port/hotkey-name-map-rust branch October 26, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant