resolveHidShiftPressed function

Future<bool Function()?> resolveHidShiftPressed({
  1. Map<String, String>? env,
  2. bool isMacOS = true,
  3. void probeEntry(
    1. SendPort port
    )?,
  4. Duration probeTimeout = const Duration(milliseconds: 300),
})

Resolves the TUI host callback for Shift detection: the HID poll when the session allows it, null when it must stay off — a non-macOS host, the kill switch, an SSH session, or a startup probe whose HID read failed to complete in time (issue #355). Wiring keys on probe COMPLETION, never on the live Shift value it happened to read. The probe runs ONCE, at startup, off the UI isolate; probeEntry is the test seam for the isolate payload.

Implementation

Future<bool Function()?> resolveHidShiftPressed({
  Map<String, String>? env,
  bool isMacOS = true,
  void Function(SendPort port)? probeEntry,
  Duration probeTimeout = const Duration(milliseconds: 300),
}) async {
  if (!isMacOS) return null;
  if (!hidShiftPollingEnabled(env ?? Platform.environment)) return null;
  final ok = await probeHidShiftPolling(
    entry: probeEntry,
    timeout: probeTimeout,
  );
  return ok ? isShiftPressedViaHid : null;
}