From c7cf0cfd83230b2d1ca2002cbadcc8c871d8ca22 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Tue, 3 Oct 2023 23:23:18 +0200 Subject: [PATCH] Make DeviceId contain device id's on Android --- CHANGELOG.md | 1 + src/platform_impl/android/mod.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b1366e1..8807474a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ And please only add new entries to the top of this list, right below the `# Unre - On X11, fix event loop not waking up on `ControlFlow::Poll` and `ControlFlow::WaitUntil`. - **Breaking:** Change default `ControlFlow` from `Poll` to `Wait`. - **Breaking:** remove `DeviceEvent::Text`. +- On Android, fix `DeviceId` to contain device id's. # 0.29.1-beta diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 03ee9102..2855e7ed 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -387,7 +387,7 @@ impl EventLoop { match event { InputEvent::MotionEvent(motion_event) => { let window_id = window::WindowId(WindowId); - let device_id = event::DeviceId(DeviceId); + let device_id = event::DeviceId(DeviceId(motion_event.device_id())); let phase = match motion_event.action() { MotionAction::Down | MotionAction::PointerDown => { @@ -459,7 +459,7 @@ impl EventLoop { let event = event::Event::WindowEvent { window_id: window::WindowId(WindowId), event: event::WindowEvent::KeyboardInput { - device_id: event::DeviceId(DeviceId), + device_id: event::DeviceId(DeviceId(key.device_id())), event: event::KeyEvent { state, physical_key: keycodes::to_physical_keycode(keycode), @@ -739,11 +739,11 @@ impl From for WindowId { } #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -pub struct DeviceId; +pub struct DeviceId(i32); impl DeviceId { pub const fn dummy() -> Self { - DeviceId + DeviceId(0) } }