diff --git a/dhc/src/input/hid.rs b/dhc/src/input/hid.rs index 99a6c8a..81a2c8f 100644 --- a/dhc/src/input/hid.rs +++ b/dhc/src/input/hid.rs @@ -148,10 +148,10 @@ impl HidPreparsedData { } fn get_caps(&self) -> Result { - let mut caps = unsafe { MaybeUninit::uninit().assume_init() }; - let rc = unsafe { HidP_GetCaps(self.raw(), &mut caps) }; + let mut caps = MaybeUninit::::uninit(); + let rc = unsafe { HidP_GetCaps(self.raw(), caps.as_mut_ptr()) }; let result = hidp_result(rc); - result.and(Ok(caps)) + result.and(Ok(unsafe { caps.assume_init() })) } fn get_value_caps(&self) -> Result, HidPError> { @@ -374,7 +374,7 @@ fn get_rawinput_device_info_impl(device_id: RawInputDeviceId, cmd: UINT) -> Vec< }; let mut result = vec![0; size as usize]; - let ptr = result.as_mut_ptr() as *mut std::ffi::c_void; + let ptr = result.as_mut_ptr() as *mut winapi::ctypes::c_void; let mut dummy = size as u32; let rc = unsafe { GetRawInputDeviceInfoA(device_id.as_handle(), cmd, ptr, &mut dummy) }; assert!(size >= rc as usize); @@ -406,7 +406,7 @@ fn hid_get_product_string(handle: HANDLE) -> Option { let mut buf: Vec = vec![0; 512]; let buf_size = buf.len() * std::mem::size_of::(); - let ptr = buf.as_mut_ptr() as *mut std::ffi::c_void; + let ptr = buf.as_mut_ptr() as *mut winapi::ctypes::c_void; let result = unsafe { HidD_GetProductString(handle, ptr, buf_size as u32) }; if result == 0 { error!("HidD_GetProductString failed"); @@ -425,7 +425,7 @@ fn hid_get_manufacturer_string(handle: HANDLE) -> Option { let mut buf: Vec = vec![0; 512]; let buf_size = buf.len() * std::mem::size_of::(); - let ptr = buf.as_mut_ptr() as *mut std::ffi::c_void; + let ptr = buf.as_mut_ptr() as *mut winapi::ctypes::c_void; let result = unsafe { HidD_GetManufacturerString(handle, ptr, buf_size as u32) }; if result == 0 { error!("HidD_GetManufacturerString failed"); @@ -444,7 +444,7 @@ fn hid_get_serial_number(handle: HANDLE) -> Option { let mut buf: Vec = vec![0; 512]; let buf_size = buf.len() * std::mem::size_of::(); - let ptr = buf.as_mut_ptr() as *mut std::ffi::c_void; + let ptr = buf.as_mut_ptr() as *mut winapi::ctypes::c_void; let result = unsafe { HidD_GetSerialNumberString(handle, ptr, buf_size as u32) }; if result == 0 { error!("HidD_GetSerialNumberString failed"); diff --git a/dhc/src/input/mod.rs b/dhc/src/input/mod.rs index 7c2b8fb..8d5b029 100644 --- a/dhc/src/input/mod.rs +++ b/dhc/src/input/mod.rs @@ -243,13 +243,13 @@ impl RawInputManager { fn handle_device_input(&mut self, _hwnd: HWND, hrawinput: HRAWINPUT) { // TODO: Switch to GetRawInputBuffer? - let mut buffer = unsafe { MaybeUninit::uninit().assume_init() }; + let mut buffer = MaybeUninit::::uninit(); let mut size = std::mem::size_of_val(&buffer) as u32; let result = unsafe { GetRawInputData( hrawinput, RID_INPUT, - &mut buffer as *mut AlignedBuffer as *mut std::ffi::c_void, + buffer.as_mut_ptr() as *mut winapi::ctypes::c_void, &mut size, std::mem::size_of::() as UINT, ) @@ -260,6 +260,7 @@ impl RawInputManager { return; } + let buffer = unsafe { buffer.assume_init() }; let rawinput = unsafe { *(&buffer as *const AlignedBuffer as *const RAWINPUT) }; let device_id = RawInputDeviceId::from_handle(rawinput.header.hDevice); let device = self.devices.get_mut(&device_id); diff --git a/dhc/src/lib.rs b/dhc/src/lib.rs index 4317a50..5ee273a 100644 --- a/dhc/src/lib.rs +++ b/dhc/src/lib.rs @@ -48,7 +48,7 @@ lazy_static! { .expect("failed to open or create configuration file") .clone() }; - static ref CONTEXT: Context = { Context::new(CONFIG.device_count, CONFIG.mode == config::EmulationMode::XInput) }; + static ref CONTEXT: Context = Context::new(CONFIG.device_count, CONFIG.mode == config::EmulationMode::XInput); } fn get_executable_path() -> String { @@ -198,7 +198,7 @@ impl State { ref mut real_devices, } = *self; - for mut vdev in virtual_devices.iter_mut() { + for vdev in virtual_devices.iter_mut() { if let Some(rdev_id) = vdev.binding { let real_device_idx = find_real_device(&real_devices, rdev_id).unwrap(); let rdev = &mut real_devices[real_device_idx];