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::{
|
2024-06-04 12:44:25 +00:00
|
|
|
gestures::*,
|
2023-06-08 20:31:43 +00:00
|
|
|
mouse::{MouseButtonInput, MouseMotion, MouseWheel},
|
|
|
|
},
|
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>,
|
2024-06-04 12:44:25 +00:00
|
|
|
mut pinch_gesture_events: EventReader<PinchGesture>,
|
|
|
|
mut rotation_gesture_events: EventReader<RotationGesture>,
|
|
|
|
mut double_tap_gesture_events: EventReader<DoubleTapGesture>,
|
2020-04-30 20:52:11 +00:00
|
|
|
) {
|
2023-08-30 14:20:03 +00:00
|
|
|
for event in mouse_button_input_events.read() {
|
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
|
|
|
|
2023-08-30 14:20:03 +00:00
|
|
|
for event in mouse_motion_events.read() {
|
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
|
|
|
|
2023-08-30 14:20:03 +00:00
|
|
|
for event in cursor_moved_events.read() {
|
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
|
|
|
|
2023-08-30 14:20:03 +00:00
|
|
|
for event in mouse_wheel_events.read() {
|
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
|
2024-06-04 12:44:25 +00:00
|
|
|
for event in pinch_gesture_events.read() {
|
2023-06-08 20:31:43 +00:00
|
|
|
info!("{:?}", event);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This event will only fire on macOS
|
2024-06-04 12:44:25 +00:00
|
|
|
for event in rotation_gesture_events.read() {
|
|
|
|
info!("{:?}", event);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This event will only fire on macOS
|
|
|
|
for event in double_tap_gesture_events.read() {
|
2023-06-08 20:31:43 +00:00
|
|
|
info!("{:?}", event);
|
|
|
|
}
|
2020-04-06 23:15:59 +00:00
|
|
|
}
|