Skip to content

Commit 32a4111

Browse files
committed
Implement send_output_report() for windows-native
1 parent 0cec7e1 commit 32a4111

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/windows_native/mod.rs

100644100755
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::windows_native::types::{Handle, Overlapped};
3535
use crate::{DeviceInfo, HidDeviceBackendBase, HidDeviceBackendWindows, HidError, HidResult};
3636
use windows_sys::core::GUID;
3737
use windows_sys::Win32::Devices::HumanInterfaceDevice::{
38-
HidD_GetIndexedString, HidD_SetFeature, HidD_SetNumInputBuffers,
38+
HidD_GetIndexedString, HidD_SetFeature, HidD_SetNumInputBuffers, HidD_SetOutputReport,
3939
};
4040
use windows_sys::Win32::Devices::Properties::{
4141
DEVPKEY_Device_ContainerId, DEVPKEY_Device_InstanceId,
@@ -276,6 +276,22 @@ impl HidDeviceBackendBase for HidDevice {
276276
Ok(bytes_returned as usize)
277277
}
278278

279+
fn send_output_report(&self, data: &[u8]) -> HidResult<()> {
280+
ensure!(!data.is_empty(), Err(HidError::InvalidZeroSizeData));
281+
let mut state = self.feature_state.borrow_mut();
282+
state.fill_buffer(data);
283+
284+
check_boolean(unsafe {
285+
HidD_SetOutputReport(
286+
self.device_handle.as_raw(),
287+
state.buffer_ptr() as _,
288+
state.buffer_len() as u32,
289+
)
290+
})?;
291+
292+
Ok(())
293+
}
294+
279295
fn set_blocking_mode(&self, blocking: bool) -> HidResult<()> {
280296
self.blocking.set(blocking);
281297
Ok(())

0 commit comments

Comments
 (0)