2022-05-16 13:53:20 +00:00
|
|
|
//! Prints all mouse events to the console.
|
|
|
|
|
2020-04-06 23:15:59 +00:00
|
|
|
use bevy::{
|
2023-06-08 20:31:43 +00:00
|
|
|
input::{
|
|
|
|
mouse::{MouseButtonInput, MouseMotion, MouseWheel},
|
|
|
|
touchpad::{TouchpadMagnify, TouchpadRotate},
|
|
|
|
},
|
2020-04-06 23:15:59 +00:00
|
|
|
prelude::*,
|
|
|
|
};
|
2020-04-05 06:42:39 +00:00
|
|
|
|
|
|
|
fn main() {
|
2021-07-27 20:21:06 +00:00
|
|
|
App::new()
|
2020-11-03 03:01:17 +00:00
|
|
|
.add_plugins(DefaultPlugins)
|
2023-03-18 01:45:34 +00:00
|
|
|
.add_systems(Update, print_mouse_events_system)
|
2020-04-05 06:42:39 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2020-06-05 06:49:36 +00:00
|
|
|
/// This system prints out all mouse events as they come in
|
|
|
|
fn print_mouse_events_system(
|
2021-01-19 06:23:30 +00:00
|
|
|
mut mouse_button_input_events: EventReader<MouseButtonInput>,
|
|
|
|
mut mouse_motion_events: EventReader<MouseMotion>,
|
|
|
|
mut cursor_moved_events: EventReader<CursorMoved>,
|
|
|
|
mut mouse_wheel_events: EventReader<MouseWheel>,
|
2023-06-08 20:31:43 +00:00
|
|
|
mut touchpad_magnify_events: EventReader<TouchpadMagnify>,
|
|
|
|
mut touchpad_rotate_events: EventReader<TouchpadRotate>,
|
2020-04-30 20:52:11 +00:00
|
|
|
) {
|
2021-01-19 06:23:30 +00:00
|
|
|
for event in mouse_button_input_events.iter() {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("{:?}", event);
|
2020-04-30 20:52:11 +00:00
|
|
|
}
|
2020-04-05 07:32:53 +00:00
|
|
|
|
2021-01-19 06:23:30 +00:00
|
|
|
for event in mouse_motion_events.iter() {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("{:?}", event);
|
2020-04-30 20:52:11 +00:00
|
|
|
}
|
2020-06-04 06:22:32 +00:00
|
|
|
|
2021-01-19 06:23:30 +00:00
|
|
|
for event in cursor_moved_events.iter() {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("{:?}", event);
|
2020-06-04 06:22:32 +00:00
|
|
|
}
|
2020-08-21 00:04:01 +00:00
|
|
|
|
2021-01-19 06:23:30 +00:00
|
|
|
for event in mouse_wheel_events.iter() {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("{:?}", event);
|
2020-08-21 00:04:01 +00:00
|
|
|
}
|
2023-06-08 20:31:43 +00:00
|
|
|
|
|
|
|
// This event will only fire on macOS
|
|
|
|
for event in touchpad_magnify_events.iter() {
|
|
|
|
info!("{:?}", event);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This event will only fire on macOS
|
|
|
|
for event in touchpad_rotate_events.iter() {
|
|
|
|
info!("{:?}", event);
|
|
|
|
}
|
2020-04-06 23:15:59 +00:00
|
|
|
}
|