diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 50864734db..771c9735db 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -337,11 +337,12 @@ impl EventLoop { if let Some(pointers) = pointers { for pointer in pointers { + let tool_type = pointer.tool_type(); let position = PhysicalPosition { x: pointer.x() as _, y: pointer.y() as _ }; trace!( "Input event {device_id:?}, {action:?}, loc={position:?}, \ - pointer={pointer:?}" + pointer={pointer:?}, tool_type={tool_type:?}" ); let finger_id = event::FingerId(FingerId(pointer.pointer_id())); let force = Some(Force::Normalized(pointer.pressure() as f64)); @@ -351,14 +352,28 @@ impl EventLoop { let event = event::WindowEvent::PointerEntered { device_id, position, - kind: event::PointerKind::Touch(finger_id), + kind: match tool_type { + android_activity::input::ToolType::Finger => { + event::PointerKind::Touch(finger_id) + }, + // TODO mouse events + android_activity::input::ToolType::Mouse => continue, + _ => event::PointerKind::Unknown, + }, }; app.window_event(&self.window_target, window_id, event); let event = event::WindowEvent::PointerButton { device_id, state: event::ElementState::Pressed, position, - button: event::ButtonSource::Touch { finger_id, force }, + button: match tool_type { + android_activity::input::ToolType::Finger => { + event::ButtonSource::Touch { finger_id, force } + }, + // TODO mouse events + android_activity::input::ToolType::Mouse => continue, + _ => event::ButtonSource::Unknown(0), + }, }; app.window_event(&self.window_target, window_id, event); }, @@ -366,7 +381,14 @@ impl EventLoop { let event = event::WindowEvent::PointerMoved { device_id, position, - source: event::PointerSource::Touch { finger_id, force }, + source: match tool_type { + android_activity::input::ToolType::Finger => { + event::PointerSource::Touch { finger_id, force } + }, + // TODO mouse events + android_activity::input::ToolType::Mouse => continue, + _ => event::PointerSource::Unknown, + }, }; app.window_event(&self.window_target, window_id, event); }, @@ -376,7 +398,14 @@ impl EventLoop { device_id, state: event::ElementState::Released, position, - button: event::ButtonSource::Touch { finger_id, force }, + button: match tool_type { + android_activity::input::ToolType::Finger => { + event::ButtonSource::Touch { finger_id, force } + }, + // TODO mouse events + android_activity::input::ToolType::Mouse => continue, + _ => event::ButtonSource::Unknown(0), + }, }; app.window_event(&self.window_target, window_id, event); } @@ -384,7 +413,14 @@ impl EventLoop { let event = event::WindowEvent::PointerLeft { device_id, position: Some(position), - kind: event::PointerKind::Touch(finger_id), + kind: match tool_type { + android_activity::input::ToolType::Finger => { + event::PointerKind::Touch(finger_id) + }, + // TODO mouse events + android_activity::input::ToolType::Mouse => continue, + _ => event::PointerKind::Unknown, + }, }; app.window_event(&self.window_target, window_id, event); },