HID: report delivery failures are discarded, so the connection gate only works on Bluetooth

Author: mishamyteCreated Sep 21, 2026Updated Sep 21, 2026
Labelsarea/bluetootharea/systemtype/enhancement

Split out of the review of #1112, which added a "wait for the link" gate to the two Mouse Jiggler views. That gate is correct as far as it goes, but it sits a layer lower than the problem.

What is wrong

hid_hal_mouse_move() and its siblings are declared void and throw away a bool the HAL already returns:

  • applications/system/hid_app/transport_usb.c:37 calls furi_hal_hid_mouse_move(), declared bool at targets/f7/furi_hal/furi_hal_usb_hid.c:319
  • applications/system/hid_app/transport_ble.c:37 calls ble_profile_hid_mouse_move(), declared bool at lib/ble_profile/extra_profiles/hid_profile.c:300

Same for the keyboard, consumer and scroll shims.

Because the result is discarded, every view has to reconstruct "am I connected?" from a connected field in its own view model, fed by bt_hid_connection_status_changed_callback(). That callback is only registered in hid_ble_app() (hid.c:341), so:

  1. The USB build gets no gate at all. In #1112 the gate is behind #ifdef HID_TRANSPORT_BLE; on USB the local is hardcoded true and reports always go out.
  2. hid_send_report() fails five distinct ways that nobody can see (targets/f7/furi_hal/furi_hal_usb_hid.c:451-475): interface not configured, host not enumerated, endpoint busy (4 ms semaphore timeout), connection lost mid-send, and boot protocol.
  3. The boot-protocol case is a total blackout. A host that issues SET_PROTOCOL(boot) — BIOS/UEFI setup, many KVMs, some lock screens — makes hid_send_report() drop every non-keyboard report at furi_hal_usb_hid.c:453. The USB jiggler then transmits nothing at all, for as long as that lasts, while the screen shows a highlighted "Stop". The screen the user was trying to keep awake locks anyway, and there is no log line.
  4. The gate is inherently TOCTOU even on BLE. connected is copied out of the model, the link can drop before the transmit, and only the discarded return value could observe that. BtStatusConnected also does not imply the host has subscribed to HID input report notifications.

This affects all ~13 views with a *_set_connected_status() setter, not just the two jigglers.

Suggested fix

The shape already exists in this repo, in applications/main/bad_usb/helpers/bad_usb_hid.h:28-38, implemented for both transports:

c
bool (*is_connected)(void* inst);
bool (*mouse_move)(void* inst, int8_t dx, int8_t dy);

So:

  1. Make the hid_hal_* report senders in applications/system/hid_app/hid.h:80-84 return bool; transport_usb.c / transport_ble.c just stop discarding what they already get.
  2. Add bool hid_hal_is_connected(Hid*) — USB returns furi_hal_hid_is_connected() (already in the API table); BLE returns a bool stored once in struct Hid by bt_hid_connection_status_changed_callback(). bad_usb_hid.c:32-35,208-212 is the working precedent.
  3. Views then gate on hid_hal_is_connected() with no preprocessor, or react to a failed send directly. The per-view connected field stays only for drawing the BLE icon, which genuinely needs it.

That fixes all thirteen views at once, works on USB, and lets the two #ifdef HID_TRANSPORT_BLE blocks come out of the jiggler draw callbacks.

Notes

  • Not a regression: #1112 narrowed the window, it did not open it. The author and I agreed to defer this rather than grow that PR.
  • Worth a FURI_LOG_W on a dropped report while in there. Neither jiggler view has a single FURI_LOG_* today despite both defining TAG, which is why states like this turn into unreproducible reports.

Review thread this came from: https://github.com/DarkFlippers/unleashed-firmware/pull/1112#discussion_r3940652170

Source: DarkFlippers/unleashed-firmware