parent
2e33c9c75e
commit
9719675465
@ -1,25 +1,209 @@
|
|||||||
use winit::window::WindowId;
|
use winit::window::{WindowId, Theme};
|
||||||
use winit::event::{WindowEvent, DeviceId, DeviceEvent, KeyboardInput, ModifiersState, MouseScrollDelta, TouchPhase, ElementState, MouseButton, AxisId, Touch};
|
use winit::event::{WindowEvent, DeviceId, DeviceEvent, KeyboardInput, ModifiersState, MouseScrollDelta, TouchPhase, ElementState, MouseButton, AxisId, Touch, StartCause, Event};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use winit::dpi::{PhysicalPosition, PhysicalSize};
|
use winit::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use gilrs::Event as GilEvent;
|
use gilrs::Event as GilEvent;
|
||||||
|
use vulkano::pipeline::shader::GeometryShaderExecutionMode::TrianglesWithAdjacency;
|
||||||
|
|
||||||
pub enum TrEvent {
|
#[derive(Clone)]
|
||||||
MouseFocusEvent {
|
pub enum TrEventExtension {
|
||||||
position : (f32, f32),
|
|
||||||
},
|
|
||||||
MouseClickEvent {
|
|
||||||
position : (f32, f32),
|
|
||||||
button : MouseButton,
|
|
||||||
},
|
|
||||||
MouseHeldEvent {
|
|
||||||
|
|
||||||
|
/// Custom events here
|
||||||
|
MouseHeldEvent {},
|
||||||
|
KeyHeldEvent {},
|
||||||
|
GamepadEvent {
|
||||||
|
gil_event: GilEvent,
|
||||||
},
|
},
|
||||||
KeyHeldEvent {
|
}
|
||||||
|
|
||||||
},
|
#[derive(Clone)]
|
||||||
|
pub enum TrEvent<T> {
|
||||||
|
|
||||||
|
/// Custom events here
|
||||||
|
MouseHeldEvent {},
|
||||||
|
KeyHeldEvent {},
|
||||||
GamepadEvent {
|
GamepadEvent {
|
||||||
gil_event: GilEvent,
|
gil_event: GilEvent,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Winit events here
|
||||||
|
NewEvents(StartCause),
|
||||||
|
WindowEvent {
|
||||||
|
window_id: WindowId,
|
||||||
|
event: TrWindowEvent,
|
||||||
|
},
|
||||||
|
DeviceEvent {
|
||||||
|
device_id: DeviceId,
|
||||||
|
event: DeviceEvent,
|
||||||
|
},
|
||||||
|
UserEvent(T),
|
||||||
|
Suspended,
|
||||||
|
Resumed,
|
||||||
|
MainEventsCleared,
|
||||||
|
RedrawRequested(WindowId),
|
||||||
|
RedrawEventsCleared,
|
||||||
|
LoopDestroyed,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl<T> From<Event<'_, T>> for TrEvent<T> {
|
||||||
|
fn from(event: Event<T>) -> Self {
|
||||||
|
match event {
|
||||||
|
Event::NewEvents(cause) => {
|
||||||
|
TrEvent::NewEvents(cause)
|
||||||
|
},
|
||||||
|
Event::WindowEvent { window_id: window_id, event: event } => {
|
||||||
|
TrEvent::WindowEvent {
|
||||||
|
window_id: window_id,
|
||||||
|
event: match event {
|
||||||
|
WindowEvent::AxisMotion { device_id, axis, value } => {
|
||||||
|
TrWindowEvent::AxisMotion { device_id, axis, value }
|
||||||
|
},
|
||||||
|
WindowEvent::Resized(physical_size) => {
|
||||||
|
TrWindowEvent::Resized(physical_size)
|
||||||
|
}
|
||||||
|
WindowEvent::Moved(physical_position) => {
|
||||||
|
TrWindowEvent::Moved(physical_position)
|
||||||
|
}
|
||||||
|
WindowEvent::CloseRequested => {
|
||||||
|
TrWindowEvent::CloseRequested
|
||||||
|
}
|
||||||
|
WindowEvent::Destroyed => {
|
||||||
|
TrWindowEvent::Destroyed
|
||||||
|
}
|
||||||
|
WindowEvent::DroppedFile(path_buf) => {
|
||||||
|
TrWindowEvent::DroppedFile(path_buf)
|
||||||
|
}
|
||||||
|
WindowEvent::HoveredFile(path_buf) => {
|
||||||
|
TrWindowEvent::HoveredFile(path_buf)
|
||||||
|
}
|
||||||
|
WindowEvent::HoveredFileCancelled => {
|
||||||
|
TrWindowEvent::HoveredFileCancelled
|
||||||
|
}
|
||||||
|
WindowEvent::ReceivedCharacter(char) => {
|
||||||
|
TrWindowEvent::ReceivedCharacter(char)
|
||||||
|
}
|
||||||
|
WindowEvent::Focused(bool) => {
|
||||||
|
TrWindowEvent::Focused(bool)
|
||||||
|
}
|
||||||
|
WindowEvent::KeyboardInput { device_id: device_id, input: input, is_synthetic: is_synthetic } => {
|
||||||
|
TrWindowEvent::KeyboardInput { device_id, input, is_synthetic }
|
||||||
|
}
|
||||||
|
WindowEvent::ModifiersChanged(modifiers_state) => {
|
||||||
|
TrWindowEvent::ModifiersChanged(modifiers_state)
|
||||||
|
}
|
||||||
|
WindowEvent::CursorMoved { device_id: device_id, position: position, modifiers: modifiers } => {
|
||||||
|
TrWindowEvent::CursorMoved { device_id, position, modifiers }
|
||||||
|
}
|
||||||
|
WindowEvent::CursorEntered { device_id: device_id } => {
|
||||||
|
TrWindowEvent::CursorEntered { device_id }
|
||||||
|
}
|
||||||
|
WindowEvent::CursorLeft { device_id: device_id } => {
|
||||||
|
TrWindowEvent::CursorLeft { device_id }
|
||||||
|
}
|
||||||
|
WindowEvent::MouseWheel { device_id: device_id, delta: delta, phase: phase, modifiers: modifiers } => {
|
||||||
|
TrWindowEvent::MouseWheel { device_id, delta, phase, modifiers }
|
||||||
|
}
|
||||||
|
WindowEvent::MouseInput { device_id: device_id, state: state, button: button, modifiers: modifiers } => {
|
||||||
|
TrWindowEvent::MouseInput { device_id, state, button, modifiers }
|
||||||
|
}
|
||||||
|
WindowEvent::TouchpadPressure { device_id: device_id, pressure: pressure, stage: stage } => {
|
||||||
|
TrWindowEvent::TouchpadPressure { device_id, pressure, stage }
|
||||||
|
}
|
||||||
|
WindowEvent::Touch(touch) => {
|
||||||
|
TrWindowEvent::Touch(touch)
|
||||||
|
}
|
||||||
|
WindowEvent::ScaleFactorChanged { scale_factor: scale_factor, new_inner_size: new_inner_size } => {
|
||||||
|
TrWindowEvent::ScaleFactorChanged { scale_factor, new_inner_size: PhysicalSize { width: new_inner_size.width, height: new_inner_size.height } }
|
||||||
|
}
|
||||||
|
WindowEvent::ThemeChanged(theme) => {
|
||||||
|
TrWindowEvent::ThemeChanged(theme)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::DeviceEvent { device_id: device_id, event: event } => {
|
||||||
|
TrEvent::DeviceEvent { device_id, event }
|
||||||
|
}
|
||||||
|
Event::UserEvent(user_event) => {
|
||||||
|
TrEvent::UserEvent(user_event)
|
||||||
|
}
|
||||||
|
Event::Suspended => {
|
||||||
|
TrEvent::Suspended
|
||||||
|
}
|
||||||
|
Event::Resumed => {
|
||||||
|
TrEvent::Resumed
|
||||||
|
}
|
||||||
|
Event::MainEventsCleared => {
|
||||||
|
TrEvent::MainEventsCleared
|
||||||
|
}
|
||||||
|
Event::RedrawRequested(window_id) => {
|
||||||
|
TrEvent::RedrawRequested(window_id)
|
||||||
|
}
|
||||||
|
Event::RedrawEventsCleared => {
|
||||||
|
TrEvent::RedrawEventsCleared
|
||||||
|
}
|
||||||
|
Event::LoopDestroyed => {
|
||||||
|
TrEvent::LoopDestroyed
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
pub enum TrWindowEvent {
|
||||||
|
|
||||||
|
Resized(PhysicalSize<u32>),
|
||||||
|
Moved(PhysicalPosition<i32>),
|
||||||
|
CloseRequested,
|
||||||
|
Destroyed,
|
||||||
|
DroppedFile(PathBuf),
|
||||||
|
HoveredFile(PathBuf),
|
||||||
|
HoveredFileCancelled,
|
||||||
|
ReceivedCharacter(char),
|
||||||
|
Focused(bool),
|
||||||
|
KeyboardInput {
|
||||||
|
device_id: DeviceId,
|
||||||
|
input: KeyboardInput,
|
||||||
|
is_synthetic: bool,
|
||||||
|
},
|
||||||
|
ModifiersChanged(ModifiersState),
|
||||||
|
CursorMoved {
|
||||||
|
device_id: DeviceId,
|
||||||
|
position: PhysicalPosition<f64>,
|
||||||
|
#[deprecated = "Deprecated in favor of WindowEvent::ModifiersChanged"]
|
||||||
|
modifiers: ModifiersState,
|
||||||
|
},
|
||||||
|
CursorEntered { device_id: DeviceId },
|
||||||
|
CursorLeft { device_id: DeviceId },
|
||||||
|
MouseWheel {
|
||||||
|
device_id: DeviceId,
|
||||||
|
delta: MouseScrollDelta,
|
||||||
|
phase: TouchPhase,
|
||||||
|
#[deprecated = "Deprecated in favor of WindowEvent::ModifiersChanged"]
|
||||||
|
modifiers: ModifiersState,
|
||||||
|
},
|
||||||
|
MouseInput {
|
||||||
|
device_id: DeviceId,
|
||||||
|
state: ElementState,
|
||||||
|
button: MouseButton,
|
||||||
|
#[deprecated = "Deprecated in favor of WindowEvent::ModifiersChanged"]
|
||||||
|
modifiers: ModifiersState,
|
||||||
|
},
|
||||||
|
TouchpadPressure {
|
||||||
|
device_id: DeviceId,
|
||||||
|
pressure: f32,
|
||||||
|
stage: i64,
|
||||||
|
},
|
||||||
|
AxisMotion {
|
||||||
|
device_id: DeviceId,
|
||||||
|
axis: AxisId,
|
||||||
|
value: f64,
|
||||||
|
},
|
||||||
|
Touch(Touch),
|
||||||
|
ScaleFactorChanged {
|
||||||
|
scale_factor: f64,
|
||||||
|
new_inner_size: PhysicalSize<u32>,
|
||||||
|
},
|
||||||
|
ThemeChanged(Theme),
|
||||||
}
|
}
|
Loading…
Reference in new issue