2015-06-24 08:05:37 +10:00
|
|
|
use std::path::PathBuf;
|
2018-06-15 09:42:18 +10:00
|
|
|
|
|
|
|
use {DeviceId, LogicalPosition, LogicalSize, WindowId};
|
2015-06-24 08:05:37 +10:00
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes a generic event.
|
2018-11-01 19:24:56 +11:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2014-07-27 20:59:45 +10:00
|
|
|
pub enum Event {
|
2017-01-29 01:00:17 +11:00
|
|
|
WindowEvent {
|
2017-02-03 19:13:11 +11:00
|
|
|
window_id: WindowId,
|
2017-01-29 01:00:17 +11:00
|
|
|
event: WindowEvent,
|
2017-04-23 06:52:35 +10:00
|
|
|
},
|
|
|
|
DeviceEvent {
|
|
|
|
device_id: DeviceId,
|
|
|
|
event: DeviceEvent,
|
|
|
|
},
|
2017-05-25 23:19:13 +10:00
|
|
|
Awakened,
|
2017-09-16 00:24:09 +10:00
|
|
|
|
|
|
|
/// The application has been suspended or resumed.
|
|
|
|
///
|
|
|
|
/// The parameter is true if app was suspended, and false if it has been resumed.
|
|
|
|
Suspended(bool),
|
2017-01-29 01:00:17 +11:00
|
|
|
}
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes an event from a `Window`.
|
2018-11-01 19:24:56 +11:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2017-01-29 01:00:17 +11:00
|
|
|
pub enum WindowEvent {
|
Windows: Position fixes (#479)
* Remove executable flag from os/macos.rs
This was causing me some grief while working on Windows, and it
doesn't belong here to begin with.
* Windows: get_position returns screen coordinates instead of workspace coordinates
Previously, get_position used GetWindowPlacement. As per the
documentation of WINDOWSTRUCT, the returned coordinates are in
workspace space, meaning they're relative to the taskbar. It's
also explicitly remarked that these coordinates should only be
used in conjunction with SetWindowPlacement, as mixing them with
functions expecting screen coordinates can cause unpleasantness.
Since our set_position (correctly) uses SetWindowPos, this meant
that passing the return of get_position to set_position would
cause the window to move.
We now use GetWindowRect, which returns screen coordinates. This
gives us both better consistency within the Windows backend and
across platforms.
Note that this only makes a difference if the taskbar is visible.
With the taskbar hidden, the values are exactly the same as before.
* Windows: Moved event position values are consistent with get_position
The old Moved values had two problems:
* They were obtained by casting a WORD (u16) straight to an i32.
This meant wrap-around would never be interpreted as negative,
thus negative positions (which are ubiquitous when using multiple
monitors) would result in positions around u16::MAX.
* WM_MOVE supplies client area positions, not window positions.
Switching to handling WM_WINDOWPOSCHANGED solves both of these
problems.
* Better documentation for Moved and Resized
2018-04-27 10:09:33 +10:00
|
|
|
/// The size of the window has changed. Contains the client area's new dimensions.
|
2018-06-15 09:42:18 +10:00
|
|
|
Resized(LogicalSize),
|
2014-07-27 20:59:45 +10:00
|
|
|
|
Windows: Position fixes (#479)
* Remove executable flag from os/macos.rs
This was causing me some grief while working on Windows, and it
doesn't belong here to begin with.
* Windows: get_position returns screen coordinates instead of workspace coordinates
Previously, get_position used GetWindowPlacement. As per the
documentation of WINDOWSTRUCT, the returned coordinates are in
workspace space, meaning they're relative to the taskbar. It's
also explicitly remarked that these coordinates should only be
used in conjunction with SetWindowPlacement, as mixing them with
functions expecting screen coordinates can cause unpleasantness.
Since our set_position (correctly) uses SetWindowPos, this meant
that passing the return of get_position to set_position would
cause the window to move.
We now use GetWindowRect, which returns screen coordinates. This
gives us both better consistency within the Windows backend and
across platforms.
Note that this only makes a difference if the taskbar is visible.
With the taskbar hidden, the values are exactly the same as before.
* Windows: Moved event position values are consistent with get_position
The old Moved values had two problems:
* They were obtained by casting a WORD (u16) straight to an i32.
This meant wrap-around would never be interpreted as negative,
thus negative positions (which are ubiquitous when using multiple
monitors) would result in positions around u16::MAX.
* WM_MOVE supplies client area positions, not window positions.
Switching to handling WM_WINDOWPOSCHANGED solves both of these
problems.
* Better documentation for Moved and Resized
2018-04-27 10:09:33 +10:00
|
|
|
/// The position of the window has changed. Contains the window's new position.
|
2018-06-15 09:42:18 +10:00
|
|
|
Moved(LogicalPosition),
|
2014-07-28 04:08:31 +10:00
|
|
|
|
2018-04-25 06:20:40 +10:00
|
|
|
/// The window has been requested to close.
|
|
|
|
CloseRequested,
|
|
|
|
|
|
|
|
/// The window has been destroyed.
|
|
|
|
Destroyed,
|
2014-07-27 20:59:45 +10:00
|
|
|
|
2017-07-27 12:56:34 +10:00
|
|
|
/// A file has been dropped into the window.
|
2018-11-20 19:28:26 +11:00
|
|
|
///
|
|
|
|
/// When the user drops multiple files at once, this event will be emitted for each file
|
|
|
|
/// separately.
|
2017-07-27 12:56:34 +10:00
|
|
|
DroppedFile(PathBuf),
|
|
|
|
|
2017-07-27 12:51:00 +10:00
|
|
|
/// A file is being hovered over the window.
|
2018-11-20 19:28:26 +11:00
|
|
|
///
|
|
|
|
/// When the user hovers multiple files at once, this event will be emitted for each file
|
|
|
|
/// separately.
|
2017-07-27 12:51:00 +10:00
|
|
|
HoveredFile(PathBuf),
|
|
|
|
|
2017-07-27 12:56:34 +10:00
|
|
|
/// A file was hovered, but has exited the window.
|
2018-11-20 19:28:26 +11:00
|
|
|
///
|
|
|
|
/// There will be a single `HoveredFileCancelled` event triggered even if multiple files were
|
|
|
|
/// hovered.
|
2017-07-27 12:56:34 +10:00
|
|
|
HoveredFileCancelled,
|
2015-06-24 08:05:37 +10:00
|
|
|
|
2014-07-28 01:06:03 +10:00
|
|
|
/// The window received a unicode character.
|
|
|
|
ReceivedCharacter(char),
|
|
|
|
|
2014-07-27 20:59:45 +10:00
|
|
|
/// The window gained or lost focus.
|
2014-10-11 21:04:48 +11:00
|
|
|
///
|
2014-07-27 20:59:45 +10:00
|
|
|
/// The parameter is true if the window has gained focus, and false if it has lost focus.
|
|
|
|
Focused(bool),
|
|
|
|
|
2014-08-14 01:04:57 +10:00
|
|
|
/// An event from the keyboard has been received.
|
2017-04-23 06:52:35 +10:00
|
|
|
KeyboardInput { device_id: DeviceId, input: KeyboardInput },
|
2014-08-14 01:04:57 +10:00
|
|
|
|
|
|
|
/// The cursor has moved on the window.
|
2017-11-13 07:56:57 +11:00
|
|
|
CursorMoved {
|
|
|
|
device_id: DeviceId,
|
|
|
|
|
|
|
|
/// (x,y) coords in pixels relative to the top-left corner of the window. Because the range of this data is
|
|
|
|
/// limited by the display area and it may have been transformed by the OS to implement effects such as cursor
|
|
|
|
/// acceleration, it should not be used to implement non-cursor-like interactions such as 3D camera control.
|
2018-06-15 09:42:18 +10:00
|
|
|
position: LogicalPosition,
|
2017-12-27 08:46:28 +11:00
|
|
|
modifiers: ModifiersState
|
2017-11-13 07:56:57 +11:00
|
|
|
},
|
2014-08-14 01:04:57 +10:00
|
|
|
|
2016-11-03 19:31:16 +11:00
|
|
|
/// The cursor has entered the window.
|
2017-11-13 07:56:57 +11:00
|
|
|
CursorEntered { device_id: DeviceId },
|
2016-11-03 19:31:16 +11:00
|
|
|
|
|
|
|
/// The cursor has left the window.
|
2017-11-13 07:56:57 +11:00
|
|
|
CursorLeft { device_id: DeviceId },
|
2016-11-03 19:31:16 +11:00
|
|
|
|
2015-06-16 08:54:43 +10:00
|
|
|
/// A mouse wheel movement or touchpad scroll occurred.
|
2017-12-27 08:46:28 +11:00
|
|
|
MouseWheel { device_id: DeviceId, delta: MouseScrollDelta, phase: TouchPhase, modifiers: ModifiersState },
|
2014-08-14 01:04:57 +10:00
|
|
|
|
2017-04-23 06:52:35 +10:00
|
|
|
/// An mouse button press has been received.
|
2017-12-27 08:46:28 +11:00
|
|
|
MouseInput { device_id: DeviceId, state: ElementState, button: MouseButton, modifiers: ModifiersState },
|
2018-04-25 06:20:40 +10:00
|
|
|
|
2014-12-17 15:49:11 +11:00
|
|
|
|
2016-02-19 14:51:02 +11:00
|
|
|
/// Touchpad pressure event.
|
|
|
|
///
|
|
|
|
/// At the moment, only supported on Apple forcetouch-capable macbooks.
|
|
|
|
/// The parameters are: pressure level (value between 0 and 1 representing how hard the touchpad
|
|
|
|
/// is being pressed) and stage (integer representing the click level).
|
2017-04-23 06:52:35 +10:00
|
|
|
TouchpadPressure { device_id: DeviceId, pressure: f32, stage: i64 },
|
|
|
|
|
2017-11-13 07:56:57 +11:00
|
|
|
/// Motion on some analog axis. May report data redundant to other, more specific events.
|
2017-04-23 06:52:35 +10:00
|
|
|
AxisMotion { device_id: DeviceId, axis: AxisId, value: f64 },
|
2016-02-19 14:51:02 +11:00
|
|
|
|
2015-03-25 13:48:32 +11:00
|
|
|
/// The window needs to be redrawn.
|
|
|
|
Refresh,
|
2015-06-05 23:38:21 +10:00
|
|
|
|
|
|
|
/// Touch event has been received
|
2017-09-16 00:24:09 +10:00
|
|
|
Touch(Touch),
|
2017-10-17 22:56:38 +11:00
|
|
|
|
2018-06-15 09:42:18 +10:00
|
|
|
/// The DPI factor of the window has changed.
|
|
|
|
///
|
|
|
|
/// The following user actions can cause DPI changes:
|
2017-10-17 22:56:38 +11:00
|
|
|
///
|
2018-06-15 09:42:18 +10:00
|
|
|
/// * Changing the display's resolution.
|
|
|
|
/// * Changing the display's DPI factor (e.g. in Control Panel on Windows).
|
|
|
|
/// * Moving the window to a display with a different DPI factor.
|
2017-10-17 22:56:38 +11:00
|
|
|
///
|
2018-06-15 09:42:18 +10:00
|
|
|
/// For more information about DPI in general, see the [`dpi`](dpi/index.html) module.
|
|
|
|
HiDpiFactorChanged(f64),
|
2015-06-05 23:38:21 +10:00
|
|
|
}
|
|
|
|
|
2017-04-23 06:52:35 +10:00
|
|
|
/// Represents raw hardware events that are not associated with any particular window.
|
|
|
|
///
|
|
|
|
/// Useful for interactions that diverge significantly from a conventional 2D GUI, such as 3D camera or first-person
|
|
|
|
/// game controls. Many physical actions, such as mouse movement, can produce both device and window events. Because
|
|
|
|
/// window events typically arise from virtual devices (corresponding to GUI cursors and keyboard focus) the device IDs
|
|
|
|
/// may not match.
|
|
|
|
///
|
|
|
|
/// Note that these events are delivered regardless of input focus.
|
2018-11-01 19:24:56 +11:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2017-04-23 06:52:35 +10:00
|
|
|
pub enum DeviceEvent {
|
|
|
|
Added,
|
|
|
|
Removed,
|
2017-11-13 07:56:57 +11:00
|
|
|
|
|
|
|
/// Change in physical position of a pointing device.
|
|
|
|
///
|
|
|
|
/// This represents raw, unfiltered physical motion. Not to be confused with `WindowEvent::CursorMoved`.
|
|
|
|
MouseMotion {
|
|
|
|
/// (x, y) change in position in unspecified units.
|
|
|
|
///
|
|
|
|
/// Different devices may use different units.
|
|
|
|
delta: (f64, f64),
|
|
|
|
},
|
|
|
|
|
|
|
|
/// Physical scroll event
|
|
|
|
MouseWheel {
|
|
|
|
delta: MouseScrollDelta,
|
|
|
|
},
|
|
|
|
|
|
|
|
/// Motion on some analog axis. This event will be reported for all arbitrary input devices
|
|
|
|
/// that winit supports on this platform, including mouse devices. If the device is a mouse
|
|
|
|
/// device then this will be reported alongside the MouseMotion event.
|
2017-04-23 06:52:35 +10:00
|
|
|
Motion { axis: AxisId, value: f64 },
|
2017-11-13 07:56:57 +11:00
|
|
|
|
2017-04-23 06:52:35 +10:00
|
|
|
Button { button: ButtonId, state: ElementState },
|
|
|
|
Key(KeyboardInput),
|
|
|
|
Text { codepoint: char },
|
|
|
|
}
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes a keyboard input event.
|
2018-11-01 19:24:56 +11:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2017-04-23 06:52:35 +10:00
|
|
|
pub struct KeyboardInput {
|
|
|
|
/// Identifies the physical key pressed
|
|
|
|
///
|
|
|
|
/// This should not change if the user adjusts the host's keyboard map. Use when the physical location of the
|
|
|
|
/// key is more important than the key's host GUI semantics, such as for movement controls in a first-person
|
|
|
|
/// game.
|
|
|
|
pub scancode: ScanCode,
|
|
|
|
|
|
|
|
pub state: ElementState,
|
|
|
|
|
|
|
|
/// Identifies the semantic meaning of the key
|
|
|
|
///
|
|
|
|
/// Use when the semantics of the key are more important than the physical location of the key, such as when
|
|
|
|
/// implementing appropriate behavior for "page up."
|
|
|
|
pub virtual_keycode: Option<VirtualKeyCode>,
|
|
|
|
|
|
|
|
/// Modifier keys active at the time of this input.
|
|
|
|
///
|
|
|
|
/// This is tracked internally to avoid tracking errors arising from modifier key state changes when events from
|
|
|
|
/// this device are not being delivered to the application, e.g. due to keyboard focus being elsewhere.
|
|
|
|
pub modifiers: ModifiersState
|
|
|
|
}
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes touch-screen input state.
|
2015-06-05 23:38:21 +10:00
|
|
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
2018-11-01 19:24:56 +11:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2015-06-05 23:38:21 +10:00
|
|
|
pub enum TouchPhase {
|
|
|
|
Started,
|
|
|
|
Moved,
|
|
|
|
Ended,
|
|
|
|
Cancelled
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Represents touch event
|
|
|
|
///
|
|
|
|
/// Every time user touches screen new Start event with some finger id is generated.
|
|
|
|
/// When the finger is removed from the screen End event with same id is generated.
|
|
|
|
///
|
|
|
|
/// For every id there will be at least 2 events with phases Start and End (or Cancelled).
|
|
|
|
/// There may be 0 or more Move events.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Depending on platform implementation id may or may not be reused by system after End event.
|
|
|
|
///
|
|
|
|
/// Gesture regonizer using this event should assume that Start event received with same id
|
|
|
|
/// as previously received End event is a new finger and has nothing to do with an old one.
|
|
|
|
///
|
|
|
|
/// Touch may be cancelled if for example window lost focus.
|
2018-11-01 19:24:56 +11:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2015-06-05 23:38:21 +10:00
|
|
|
pub struct Touch {
|
2017-04-23 06:52:35 +10:00
|
|
|
pub device_id: DeviceId,
|
2015-06-05 23:38:21 +10:00
|
|
|
pub phase: TouchPhase,
|
2018-06-15 09:42:18 +10:00
|
|
|
pub location: LogicalPosition,
|
2015-06-05 23:38:21 +10:00
|
|
|
/// unique identifier of a finger.
|
|
|
|
pub id: u64
|
2014-08-14 01:04:57 +10:00
|
|
|
}
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Hardware-dependent keyboard scan code.
|
2017-04-23 06:52:35 +10:00
|
|
|
pub type ScanCode = u32;
|
2014-08-14 01:04:57 +10:00
|
|
|
|
2017-07-01 19:20:13 +10:00
|
|
|
/// Identifier for a specific analog axis on some device.
|
|
|
|
pub type AxisId = u32;
|
|
|
|
|
|
|
|
/// Identifier for a specific button on some device.
|
|
|
|
pub type ButtonId = u32;
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes the input state of a key.
|
2015-01-24 12:50:06 +11:00
|
|
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
2018-11-01 19:24:56 +11:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2014-08-14 01:04:57 +10:00
|
|
|
pub enum ElementState {
|
|
|
|
Pressed,
|
|
|
|
Released,
|
|
|
|
}
|
2014-07-28 01:06:03 +10:00
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes a button of a mouse controller.
|
2015-01-24 12:50:06 +11:00
|
|
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
2018-11-01 19:24:56 +11:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2014-08-14 01:04:57 +10:00
|
|
|
pub enum MouseButton {
|
2015-02-06 02:52:53 +11:00
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Middle,
|
|
|
|
Other(u8),
|
2014-07-28 01:06:03 +10:00
|
|
|
}
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Describes a difference in the mouse scroll wheel state.
|
2015-07-16 02:37:15 +10:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2018-11-01 19:24:56 +11:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2015-06-13 00:32:11 +10:00
|
|
|
pub enum MouseScrollDelta {
|
|
|
|
/// Amount in lines or rows to scroll in the horizontal
|
|
|
|
/// and vertical directions.
|
|
|
|
///
|
|
|
|
/// Positive values indicate movement forward
|
2015-06-14 08:22:51 +10:00
|
|
|
/// (away from the user) or rightwards.
|
2015-06-13 00:32:11 +10:00
|
|
|
LineDelta(f32, f32),
|
|
|
|
/// Amount in pixels to scroll in the horizontal and
|
|
|
|
/// vertical direction.
|
|
|
|
///
|
|
|
|
/// Scroll events are expressed as a PixelDelta if
|
|
|
|
/// supported by the device (eg. a touchpad) and
|
|
|
|
/// platform.
|
2018-06-15 09:42:18 +10:00
|
|
|
PixelDelta(LogicalPosition),
|
2015-06-13 00:32:11 +10:00
|
|
|
}
|
|
|
|
|
2017-09-25 23:58:59 +10:00
|
|
|
/// Symbolic name for a keyboard key.
|
2018-11-20 08:59:04 +11:00
|
|
|
#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]
|
2017-04-12 23:49:14 +10:00
|
|
|
#[repr(u32)]
|
2018-11-01 19:24:56 +11:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2014-08-14 01:04:57 +10:00
|
|
|
pub enum VirtualKeyCode {
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '1' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key1,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '2' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key2,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '3' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key3,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '4' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key4,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '5' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key5,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '6' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key6,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '7' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key7,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '8' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key8,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '9' key over the letters.
|
2014-07-28 01:06:03 +10:00
|
|
|
Key9,
|
2014-11-06 23:26:42 +11:00
|
|
|
/// The '0' key over the 'O' and 'P' keys.
|
|
|
|
Key0,
|
|
|
|
|
2014-07-28 01:06:03 +10:00
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
D,
|
|
|
|
E,
|
|
|
|
F,
|
2014-11-06 23:26:42 +11:00
|
|
|
G,
|
|
|
|
H,
|
|
|
|
I,
|
|
|
|
J,
|
|
|
|
K,
|
|
|
|
L,
|
|
|
|
M,
|
|
|
|
N,
|
|
|
|
O,
|
|
|
|
P,
|
|
|
|
Q,
|
|
|
|
R,
|
|
|
|
S,
|
|
|
|
T,
|
|
|
|
U,
|
|
|
|
V,
|
|
|
|
W,
|
|
|
|
X,
|
|
|
|
Y,
|
|
|
|
Z,
|
|
|
|
|
|
|
|
/// The Escape key, next to F1.
|
|
|
|
Escape,
|
|
|
|
|
2014-07-28 01:06:03 +10:00
|
|
|
F1,
|
|
|
|
F2,
|
|
|
|
F3,
|
|
|
|
F4,
|
|
|
|
F5,
|
|
|
|
F6,
|
|
|
|
F7,
|
|
|
|
F8,
|
|
|
|
F9,
|
|
|
|
F10,
|
|
|
|
F11,
|
|
|
|
F12,
|
|
|
|
F13,
|
|
|
|
F14,
|
|
|
|
F15,
|
2018-09-13 03:04:16 +10:00
|
|
|
F16,
|
|
|
|
F17,
|
|
|
|
F18,
|
|
|
|
F19,
|
|
|
|
F20,
|
|
|
|
F21,
|
|
|
|
F22,
|
|
|
|
F23,
|
|
|
|
F24,
|
2014-11-06 23:26:42 +11:00
|
|
|
|
|
|
|
/// Print Screen/SysRq.
|
|
|
|
Snapshot,
|
|
|
|
/// Scroll Lock.
|
|
|
|
Scroll,
|
|
|
|
/// Pause/Break key, next to Scroll lock.
|
|
|
|
Pause,
|
|
|
|
|
|
|
|
/// `Insert`, next to Backspace.
|
2014-07-28 01:06:03 +10:00
|
|
|
Insert,
|
2014-11-06 23:26:42 +11:00
|
|
|
Home,
|
|
|
|
Delete,
|
|
|
|
End,
|
|
|
|
PageDown,
|
|
|
|
PageUp,
|
|
|
|
|
|
|
|
Left,
|
|
|
|
Up,
|
|
|
|
Right,
|
|
|
|
Down,
|
|
|
|
|
|
|
|
/// The Backspace key, right over Enter.
|
|
|
|
// TODO: rename
|
|
|
|
Back,
|
|
|
|
/// The Enter key.
|
|
|
|
Return,
|
|
|
|
/// The space bar.
|
|
|
|
Space,
|
|
|
|
|
2016-07-05 09:20:18 +10:00
|
|
|
/// The "Compose" key on Linux.
|
|
|
|
Compose,
|
|
|
|
|
2018-01-25 23:32:30 +11:00
|
|
|
Caret,
|
|
|
|
|
2014-11-06 23:26:42 +11:00
|
|
|
Numlock,
|
|
|
|
Numpad0,
|
|
|
|
Numpad1,
|
|
|
|
Numpad2,
|
|
|
|
Numpad3,
|
|
|
|
Numpad4,
|
|
|
|
Numpad5,
|
|
|
|
Numpad6,
|
|
|
|
Numpad7,
|
|
|
|
Numpad8,
|
|
|
|
Numpad9,
|
|
|
|
|
|
|
|
AbntC1,
|
|
|
|
AbntC2,
|
|
|
|
Add,
|
|
|
|
Apostrophe,
|
|
|
|
Apps,
|
|
|
|
At,
|
|
|
|
Ax,
|
|
|
|
Backslash,
|
|
|
|
Calculator,
|
|
|
|
Capital,
|
|
|
|
Colon,
|
|
|
|
Comma,
|
|
|
|
Convert,
|
|
|
|
Decimal,
|
|
|
|
Divide,
|
|
|
|
Equals,
|
|
|
|
Grave,
|
2014-07-28 01:06:03 +10:00
|
|
|
Kana,
|
|
|
|
Kanji,
|
2014-10-24 03:01:09 +11:00
|
|
|
LAlt,
|
2014-10-15 20:49:10 +11:00
|
|
|
LBracket,
|
2014-07-28 01:06:03 +10:00
|
|
|
LControl,
|
|
|
|
LShift,
|
|
|
|
LWin,
|
|
|
|
Mail,
|
|
|
|
MediaSelect,
|
|
|
|
MediaStop,
|
|
|
|
Minus,
|
|
|
|
Multiply,
|
|
|
|
Mute,
|
|
|
|
MyComputer,
|
2016-02-27 20:59:06 +11:00
|
|
|
NavigateForward, // also called "Prior"
|
|
|
|
NavigateBackward, // also called "Next"
|
2014-07-28 01:06:03 +10:00
|
|
|
NextTrack,
|
|
|
|
NoConvert,
|
|
|
|
NumpadComma,
|
|
|
|
NumpadEnter,
|
|
|
|
NumpadEquals,
|
|
|
|
OEM102,
|
|
|
|
Period,
|
2015-07-02 17:52:44 +10:00
|
|
|
PlayPause,
|
2014-07-28 01:06:03 +10:00
|
|
|
Power,
|
2015-07-02 17:52:44 +10:00
|
|
|
PrevTrack,
|
2014-10-24 03:01:09 +11:00
|
|
|
RAlt,
|
2014-07-28 01:06:03 +10:00
|
|
|
RBracket,
|
|
|
|
RControl,
|
|
|
|
RShift,
|
|
|
|
RWin,
|
|
|
|
Semicolon,
|
|
|
|
Slash,
|
|
|
|
Sleep,
|
|
|
|
Stop,
|
|
|
|
Subtract,
|
|
|
|
Sysrq,
|
|
|
|
Tab,
|
|
|
|
Underline,
|
|
|
|
Unlabeled,
|
|
|
|
VolumeDown,
|
|
|
|
VolumeUp,
|
|
|
|
Wake,
|
2015-07-02 17:52:44 +10:00
|
|
|
WebBack,
|
2014-07-28 01:06:03 +10:00
|
|
|
WebFavorites,
|
|
|
|
WebForward,
|
|
|
|
WebHome,
|
|
|
|
WebRefresh,
|
|
|
|
WebSearch,
|
|
|
|
WebStop,
|
|
|
|
Yen,
|
2018-05-03 09:18:52 +10:00
|
|
|
Copy,
|
|
|
|
Paste,
|
|
|
|
Cut,
|
2014-07-27 20:59:45 +10:00
|
|
|
}
|
2017-01-18 05:01:10 +11:00
|
|
|
|
|
|
|
/// Represents the current state of the keyboard modifiers
|
|
|
|
///
|
|
|
|
/// Each field of this struct represents a modifier and is `true` if this modifier is active.
|
2018-02-23 04:15:56 +11:00
|
|
|
#[derive(Default, Debug, Hash, PartialEq, Eq, Clone, Copy)]
|
2018-11-01 19:24:56 +11:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
|
|
#[cfg_attr(feature = "serde", serde(default))]
|
2017-01-18 05:01:10 +11:00
|
|
|
pub struct ModifiersState {
|
|
|
|
/// The "shift" key
|
|
|
|
pub shift: bool,
|
|
|
|
/// The "control" key
|
|
|
|
pub ctrl: bool,
|
|
|
|
/// The "alt" key
|
|
|
|
pub alt: bool,
|
|
|
|
/// The "logo" key
|
|
|
|
///
|
|
|
|
/// This is the "windows" key on PC and "command" key on Mac.
|
|
|
|
pub logo: bool
|
|
|
|
}
|