Re-organize into module structure

This commit is contained in:
Osspial
2018-08-22 23:01:36 -04:00
parent f20fac99f6
commit 4377680a44
31 changed files with 740 additions and 701 deletions

View File

@@ -1,31 +1,34 @@
extern crate winit;
fn main() {
let events_loop = winit::EventLoop::new();
use winit::window::WindowBuilder;
use winit::event::{Event, WindowEvent, ElementState, KeyboardInput};
use winit::event_loop::{EventLoop, ControlFlow};
let window = winit::WindowBuilder::new()
fn main() {
let events_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_title("Super Cursor Grab'n'Hide Simulator 9000")
.build(&events_loop)
.unwrap();
events_loop.run(move |event, _, control_flow| {
*control_flow = winit::ControlFlow::Wait;
if let winit::Event::WindowEvent { event, .. } = event {
use winit::WindowEvent::*;
*control_flow = ControlFlow::Wait;
if let Event::WindowEvent { event, .. } = event {
match event {
CloseRequested => *control_flow = winit::ControlFlow::Exit,
KeyboardInput {
input: winit::KeyboardInput {
state: winit::ElementState::Released,
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::KeyboardInput {
input: KeyboardInput {
state: ElementState::Released,
virtual_keycode: Some(key),
modifiers,
..
},
..
} => {
use winit::VirtualKeyCode::*;
use winit::event::VirtualKeyCode::*;
match key {
Escape => *control_flow = winit::ControlFlow::Exit,
Escape => *control_flow = ControlFlow::Exit,
G => window.grab_cursor(!modifiers.shift).unwrap(),
H => window.hide_cursor(!modifiers.shift),
_ => (),