Event
#[derive(Clone, PartialEq, Debug)]
/// Different event types.
pub enum Event {
Quit {
timestamp: u32,
},
AppTerminating {
timestamp: u32,
},
AppLowMemory {
timestamp: u32,
},
AppWillEnterBackground {
timestamp: u32,
},
AppDidEnterBackground {
timestamp: u32,
},
AppWillEnterForeground {
timestamp: u32,
},
AppDidEnterForeground {
timestamp: u32,
},
Display {
timestamp: u32,
display_index: i32,
display_event: DisplayEvent,
},
Window {
timestamp: u32,
window_id: u32,
win_event: WindowEvent,
},
KeyDown {
timestamp: u32,
window_id: u32,
keycode: Option<Keycode>,
scancode: Option<Scancode>,
keymod: Mod,
repeat: bool,
},
KeyUp {
timestamp: u32,
window_id: u32,
keycode: Option<Keycode>,
scancode: Option<Scancode>,
keymod: Mod,
repeat: bool,
},
TextEditing {
timestamp: u32,
window_id: u32,
text: String,
start: i32,
length: i32,
},
TextInput {
timestamp: u32,
window_id: u32,
text: String,
},
MouseMotion {
timestamp: u32,
window_id: u32,
which: u32,
mousestate: MouseState,
x: i32,
y: i32,
xrel: i32,
yrel: i32,
},
MouseButtonDown {
timestamp: u32,
window_id: u32,
which: u32,
mouse_btn: MouseButton,
clicks: u8,
x: i32,
y: i32,
},
MouseButtonUp {
timestamp: u32,
window_id: u32,
which: u32,
mouse_btn: MouseButton,
clicks: u8,
x: i32,
y: i32,
},
MouseWheel {
timestamp: u32,
window_id: u32,
which: u32,
/// How much did we scroll in X, with integer precision
x: i32,
/// How much did we scroll in Y, with integer precision
y: i32,
direction: MouseWheelDirection,
/// How much did we scroll in X, with floating precision (added in 2.0.18)
precise_x: f32,
/// How much did we scroll in Y, with floating precision (added in 2.0.18)
precise_y: f32,
/// The X position of the mouse from the window's origin
mouse_x: i32,
/// The X position of the mouse from the window's origin
mouse_y: i32,
},
JoyAxisMotion {
timestamp: u32,
/// The joystick's `id`
which: u32,
axis_idx: u8,
value: i16,
},
JoyBallMotion {
timestamp: u32,
/// The joystick's `id`
which: u32,
ball_idx: u8,
xrel: i16,
yrel: i16,
},
JoyHatMotion {
timestamp: u32,
/// The joystick's `id`
which: u32,
hat_idx: u8,
state: HatState,
},
JoyButtonDown {
timestamp: u32,
/// The joystick's `id`
which: u32,
button_idx: u8,
},
JoyButtonUp {
timestamp: u32,
/// The joystick's `id`
which: u32,
button_idx: u8,
},
JoyDeviceAdded {
timestamp: u32,
/// The newly added joystick's `joystick_index`
which: u32,
},
JoyDeviceRemoved {
timestamp: u32,
/// The joystick's `id`
which: u32,
},
ControllerAxisMotion {
timestamp: u32,
/// The controller's joystick `id`
which: u32,
axis: Axis,
value: i16,
},
ControllerButtonDown {
timestamp: u32,
/// The controller's joystick `id`
which: u32,
button: Button,
},
ControllerButtonUp {
timestamp: u32,
/// The controller's joystick `id`
which: u32,
button: Button,
},
ControllerDeviceAdded {
timestamp: u32,
/// The newly added controller's `joystick_index`
which: u32,
},
ControllerDeviceRemoved {
timestamp: u32,
/// The controller's joystick `id`
which: u32,
},
ControllerDeviceRemapped {
timestamp: u32,
/// The controller's joystick `id`
which: u32,
},
ControllerTouchpadDown {
timestamp: u32,
/// The joystick instance id
which: u32,
/// The index of the touchpad
touchpad: u32,
/// The index of the finger on the touchpad
finger: u32,
/// Normalized in the range 0...1 with 0 being on the left
x: f32,
/// Normalized in the range 0...1 with 0 being at the top
y: f32,
/// Normalized in the range 0...1
pressure: f32,
},
ControllerTouchpadMotion {
timestamp: u32,
/// The joystick instance id
which: u32,
/// The index of the touchpad
touchpad: u32,
/// The index of the finger on the touchpad
finger: u32,
/// Normalized in the range 0...1 with 0 being on the left
x: f32,
/// Normalized in the range 0...1 with 0 being at the top
y: f32,
/// Normalized in the range 0...1
pressure: f32,
},
ControllerTouchpadUp {
timestamp: u32,
/// The joystick instance id
which: u32,
/// The index of the touchpad
touchpad: u32,
/// The index of the finger on the touchpad
finger: u32,
/// Normalized in the range 0...1 with 0 being on the left
x: f32,
/// Normalized in the range 0...1 with 0 being at the top
y: f32,
/// Normalized in the range 0...1
pressure: f32,
},
/// Triggered when the gyroscope or accelerometer is updated
#[cfg(feature = "hidapi")]
ControllerSensorUpdated {
timestamp: u32,
which: u32,
sensor: crate::sensor::SensorType,
/// Data from the sensor.
///
/// See the `sensor` module for more information.
data: [f32; 3],
},
FingerDown {
timestamp: u32,
touch_id: i64,
finger_id: i64,
x: f32,
y: f32,
dx: f32,
dy: f32,
pressure: f32,
},
FingerUp {
timestamp: u32,
touch_id: i64,
finger_id: i64,
x: f32,
y: f32,
dx: f32,
dy: f32,
pressure: f32,
},
FingerMotion {
timestamp: u32,
touch_id: i64,
finger_id: i64,
x: f32,
y: f32,
dx: f32,
dy: f32,
pressure: f32,
},
DollarGesture {
timestamp: u32,
touch_id: i64,
gesture_id: i64,
num_fingers: u32,
error: f32,
x: f32,
y: f32,
},
DollarRecord {
timestamp: u32,
touch_id: i64,
gesture_id: i64,
num_fingers: u32,
error: f32,
x: f32,
y: f32,
},
MultiGesture {
timestamp: u32,
touch_id: i64,
d_theta: f32,
d_dist: f32,
x: f32,
y: f32,
num_fingers: u16,
},
ClipboardUpdate {
timestamp: u32,
},
DropFile {
timestamp: u32,
window_id: u32,
filename: String,
},
DropText {
timestamp: u32,
window_id: u32,
filename: String,
},
DropBegin {
timestamp: u32,
window_id: u32,
},
DropComplete {
timestamp: u32,
window_id: u32,
},
AudioDeviceAdded {
timestamp: u32,
which: u32,
iscapture: bool,
},
AudioDeviceRemoved {
timestamp: u32,
which: u32,
iscapture: bool,
},
RenderTargetsReset {
timestamp: u32,
},
RenderDeviceReset {
timestamp: u32,
},
User {
timestamp: u32,
window_id: u32,
type_: u32,
code: i32,
data1: *mut c_void,
data2: *mut c_void,
},
Unknown {
timestamp: u32,
type_: u32,
},
}