Remove DeviceEvent::Added and Removed
This had no real use because we don't expose any information on `DeviceId` except on Windows. But there we only expose the name. The assumption is that this was originally added for gamepad support, which never made it into Winit.
This commit is contained in:
parent
586255ac0a
commit
b7a7f59298
4 changed files with 18 additions and 48 deletions
|
|
@ -104,6 +104,7 @@ changelog entry.
|
||||||
- On Web, remove unused `platform::web::CustomCursorError::Animation`.
|
- On Web, remove unused `platform::web::CustomCursorError::Animation`.
|
||||||
- Remove the `rwh_04` and `rwh_05` cargo feature and the corresponding `raw-window-handle` v0.4 and
|
- Remove the `rwh_04` and `rwh_05` cargo feature and the corresponding `raw-window-handle` v0.4 and
|
||||||
v0.5 support. v0.6 remains in place and is enabled by default.
|
v0.5 support. v0.6 remains in place and is enabled by default.
|
||||||
|
- Remove `DeviceEvent::Added` and `DeviceEvent::Removed`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -460,9 +460,6 @@ impl DeviceId {
|
||||||
/// Note that these events are delivered regardless of input focus.
|
/// Note that these events are delivered regardless of input focus.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum DeviceEvent {
|
pub enum DeviceEvent {
|
||||||
Added,
|
|
||||||
Removed,
|
|
||||||
|
|
||||||
/// Change in physical position of a pointing device.
|
/// Change in physical position of a pointing device.
|
||||||
///
|
///
|
||||||
/// This represents raw, unfiltered physical motion. Not to be confused with
|
/// This represents raw, unfiltered physical motion. Not to be confused with
|
||||||
|
|
@ -1104,8 +1101,6 @@ mod tests {
|
||||||
let with_device_event =
|
let with_device_event =
|
||||||
|dev_ev| x(event::Event::DeviceEvent { device_id: did, event: dev_ev });
|
|dev_ev| x(event::Event::DeviceEvent { device_id: did, event: dev_ev });
|
||||||
|
|
||||||
with_device_event(Added);
|
|
||||||
with_device_event(Removed);
|
|
||||||
with_device_event(MouseMotion { delta: (0.0, 0.0).into() });
|
with_device_event(MouseMotion { delta: (0.0, 0.0).into() });
|
||||||
with_device_event(MouseWheel {
|
with_device_event(MouseWheel {
|
||||||
delta: event::MouseScrollDelta::LineDelta(0.0, 0.0),
|
delta: event::MouseScrollDelta::LineDelta(0.0, 0.0),
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ impl EventProcessor {
|
||||||
|
|
||||||
xinput2::XI_HierarchyChanged => {
|
xinput2::XI_HierarchyChanged => {
|
||||||
let xev: &XIHierarchyEvent = unsafe { xev.as_event() };
|
let xev: &XIHierarchyEvent = unsafe { xev.as_event() };
|
||||||
self.xinput2_hierarchy_changed(xev, &mut callback);
|
self.xinput2_hierarchy_changed(xev);
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
@ -1496,10 +1496,7 @@ impl EventProcessor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn xinput2_hierarchy_changed<F>(&mut self, xev: &XIHierarchyEvent, mut callback: F)
|
fn xinput2_hierarchy_changed(&mut self, xev: &XIHierarchyEvent) {
|
||||||
where
|
|
||||||
F: FnMut(&RootAEL, Event),
|
|
||||||
{
|
|
||||||
let wt = Self::window_target(&self.target);
|
let wt = Self::window_target(&self.target);
|
||||||
|
|
||||||
// Set the timestamp.
|
// Set the timestamp.
|
||||||
|
|
@ -1508,15 +1505,7 @@ impl EventProcessor {
|
||||||
for info in infos {
|
for info in infos {
|
||||||
if 0 != info.flags & (xinput2::XISlaveAdded | xinput2::XIMasterAdded) {
|
if 0 != info.flags & (xinput2::XISlaveAdded | xinput2::XIMasterAdded) {
|
||||||
self.init_device(info.deviceid as xinput::DeviceId);
|
self.init_device(info.deviceid as xinput::DeviceId);
|
||||||
callback(&self.target, Event::DeviceEvent {
|
|
||||||
device_id: mkdid(info.deviceid as xinput::DeviceId),
|
|
||||||
event: DeviceEvent::Added,
|
|
||||||
});
|
|
||||||
} else if 0 != info.flags & (xinput2::XISlaveRemoved | xinput2::XIMasterRemoved) {
|
} else if 0 != info.flags & (xinput2::XISlaveRemoved | xinput2::XIMasterRemoved) {
|
||||||
callback(&self.target, Event::DeviceEvent {
|
|
||||||
device_id: mkdid(info.deviceid as xinput::DeviceId),
|
|
||||||
event: DeviceEvent::Removed,
|
|
||||||
});
|
|
||||||
let mut devices = self.devices.borrow_mut();
|
let mut devices = self.devices.borrow_mut();
|
||||||
devices.remove(&DeviceId(info.deviceid as xinput::DeviceId));
|
devices.remove(&DeviceId(info.deviceid as xinput::DeviceId));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,21 +38,20 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{
|
||||||
CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetClientRect, GetCursorPos,
|
CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetClientRect, GetCursorPos,
|
||||||
GetMenu, GetMessageW, KillTimer, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW,
|
GetMenu, GetMessageW, KillTimer, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW,
|
||||||
RegisterWindowMessageA, SetCursor, SetTimer, SetWindowPos, TranslateMessage, CREATESTRUCTW,
|
RegisterWindowMessageA, SetCursor, SetTimer, SetWindowPos, TranslateMessage, CREATESTRUCTW,
|
||||||
GIDC_ARRIVAL, GIDC_REMOVAL, GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO,
|
GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT, MINMAXINFO, MNC_CLOSE, MSG, NCCALCSIZE_PARAMS,
|
||||||
MNC_CLOSE, MSG, NCCALCSIZE_PARAMS, PM_REMOVE, PT_PEN, PT_TOUCH, RI_MOUSE_HWHEEL,
|
PM_REMOVE, PT_PEN, PT_TOUCH, RI_MOUSE_HWHEEL, RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE,
|
||||||
RI_MOUSE_WHEEL, SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE,
|
SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS,
|
||||||
SWP_NOSIZE, SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, WMSZ_BOTTOM, WMSZ_BOTTOMLEFT,
|
WMSZ_BOTTOM, WMSZ_BOTTOMLEFT, WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT,
|
||||||
WMSZ_BOTTOMRIGHT, WMSZ_LEFT, WMSZ_RIGHT, WMSZ_TOP, WMSZ_TOPLEFT, WMSZ_TOPRIGHT,
|
WMSZ_TOPRIGHT, WM_CAPTURECHANGED, WM_CLOSE, WM_CREATE, WM_DESTROY, WM_DPICHANGED,
|
||||||
WM_CAPTURECHANGED, WM_CLOSE, WM_CREATE, WM_DESTROY, WM_DPICHANGED, WM_ENTERSIZEMOVE,
|
WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE, WM_GETMINMAXINFO, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION,
|
||||||
WM_EXITSIZEMOVE, WM_GETMINMAXINFO, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION,
|
WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, WM_INPUT, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS,
|
||||||
WM_IME_SETCONTEXT, WM_IME_STARTCOMPOSITION, WM_INPUT, WM_INPUT_DEVICE_CHANGE, WM_KEYDOWN,
|
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MENUCHAR, WM_MOUSEHWHEEL,
|
||||||
WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP,
|
WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCCREATE, WM_NCDESTROY,
|
||||||
WM_MENUCHAR, WM_MOUSEHWHEEL, WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCACTIVATE, WM_NCCALCSIZE,
|
WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN,
|
||||||
WM_NCCREATE, WM_NCDESTROY, WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN, WM_POINTERUP,
|
WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE, WM_SIZING, WM_SYSCOMMAND,
|
||||||
WM_POINTERUPDATE, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE,
|
WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING,
|
||||||
WM_SIZE, WM_SIZING, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED,
|
WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW,
|
||||||
WM_WINDOWPOSCHANGING, WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED,
|
WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE,
|
||||||
WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::window::set_skip_taskbar;
|
use super::window::set_skip_taskbar;
|
||||||
|
|
@ -61,7 +60,7 @@ use crate::application::ApplicationHandler;
|
||||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use crate::error::EventLoopError;
|
use crate::error::EventLoopError;
|
||||||
use crate::event::{
|
use crate::event::{
|
||||||
DeviceEvent, Event, Force, Ime, InnerSizeWriter, RawKeyEvent, Touch, TouchPhase, WindowEvent,
|
Event, Force, Ime, InnerSizeWriter, RawKeyEvent, Touch, TouchPhase, WindowEvent,
|
||||||
};
|
};
|
||||||
use crate::event_loop::{ActiveEventLoop as RootAEL, ControlFlow, DeviceEvents};
|
use crate::event_loop::{ActiveEventLoop as RootAEL, ControlFlow, DeviceEvents};
|
||||||
use crate::keyboard::ModifiersState;
|
use crate::keyboard::ModifiersState;
|
||||||
|
|
@ -2348,20 +2347,6 @@ unsafe extern "system" fn thread_event_target_callback(
|
||||||
// when opening them.
|
// when opening them.
|
||||||
DefWindowProcW(window, msg, wparam, lparam)
|
DefWindowProcW(window, msg, wparam, lparam)
|
||||||
},
|
},
|
||||||
|
|
||||||
WM_INPUT_DEVICE_CHANGE => {
|
|
||||||
let event = match wparam as u32 {
|
|
||||||
GIDC_ARRIVAL => DeviceEvent::Added,
|
|
||||||
GIDC_REMOVAL => DeviceEvent::Removed,
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
userdata
|
|
||||||
.send_event(Event::DeviceEvent { device_id: wrap_device_id(lparam as u32), event });
|
|
||||||
|
|
||||||
0
|
|
||||||
},
|
|
||||||
|
|
||||||
WM_INPUT => {
|
WM_INPUT => {
|
||||||
if let Some(data) = raw_input::get_raw_input_data(lparam as _) {
|
if let Some(data) = raw_input::get_raw_input_data(lparam as _) {
|
||||||
unsafe { handle_raw_input(&userdata, data) };
|
unsafe { handle_raw_input(&userdata, data) };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue