MCPcopy Create free account
hub / github.com/FrameworkComputer/framework-system / open_haptic_touchpad

Function open_haptic_touchpad

framework_lib/src/touchpad.rs:35–53  ·  view source on GitHub ↗

Open the PTP HID interface of the touchpad. Note: every modern touchpad exposes this interface; only haptic touchpads respond to the feature reports used by `set_haptic_intensity` / `set_click_force`.

()

Source from the content-addressed store, hash-verified

33/// exposes this interface; only haptic touchpads respond to the feature
34/// reports used by `set_haptic_intensity` / `set_click_force`.
35fn open_haptic_touchpad() -> Option<HidDevice> {
36 let api = HidApi::new().ok()?;
37 for dev_info in api.device_list() {
38 if dev_info.usage_page() != TOUCHPAD_USAGE_PAGE || dev_info.usage() != TOUCHPAD_USAGE {
39 continue;
40 }
41 debug!(
42 " Touchpad candidate {:04X}:{:04X} (Usage Page {:04X}, Usage {:04X})",
43 dev_info.vendor_id(),
44 dev_info.product_id(),
45 dev_info.usage_page(),
46 dev_info.usage()
47 );
48 if let Ok(device) = dev_info.open_device(&api) {
49 return Some(device);
50 }
51 }
52 None
53}
54
55// The firmware accepts SET_FEATURE for these reports but doesn't reply
56// to GET_FEATURE, so both controls are write-only.

Callers 2

set_haptic_intensityFunction · 0.85
set_click_forceFunction · 0.85

Calls 1

open_deviceMethod · 0.45

Tested by

no test coverage detected