[oden] Input
This commit is contained in:
parent
c934914ac5
commit
e0878b4ea6
6 changed files with 363 additions and 14 deletions
|
|
@ -6,16 +6,18 @@ use std::ffi::OsStr;
|
|||
use std::sync::mpsc::{channel, Receiver};
|
||||
use std::time::Instant;
|
||||
use tracy_client::span;
|
||||
use winit::event::*;
|
||||
|
||||
pub mod graphics;
|
||||
mod input;
|
||||
mod io;
|
||||
mod time;
|
||||
|
||||
use graphics::GraphicsCommand;
|
||||
|
||||
mod typescript;
|
||||
use typescript::transpile_to_javascript;
|
||||
|
||||
mod io;
|
||||
mod time;
|
||||
|
||||
struct Loader {}
|
||||
|
||||
impl Loader {
|
||||
|
|
@ -49,6 +51,7 @@ pub struct ScriptContext {
|
|||
gfx_receive: Receiver<graphics::GraphicsCommand>,
|
||||
|
||||
time: time::TimeAPI,
|
||||
input: input::InputAPI,
|
||||
}
|
||||
|
||||
impl ScriptContext {
|
||||
|
|
@ -66,6 +69,8 @@ impl ScriptContext {
|
|||
.expect("Graphics module should load without error");
|
||||
let _io = io::IoAPI::define(&context).expect("IO module should load without error");
|
||||
let time = time::TimeAPI::define(&context).expect("Time module should load without error");
|
||||
let input =
|
||||
input::InputAPI::define(&context).expect("Input module should load without error");
|
||||
|
||||
let module = context
|
||||
.import_module("./main.ts", "")
|
||||
|
|
@ -92,6 +97,7 @@ impl ScriptContext {
|
|||
gfx_receive,
|
||||
|
||||
time,
|
||||
input,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +113,13 @@ impl ScriptContext {
|
|||
.expect("Exception in init");
|
||||
}
|
||||
|
||||
pub fn input(&mut self, event: &WindowEvent) -> bool {
|
||||
match event {
|
||||
WindowEvent::KeyboardInput { input, .. } => self.input.handle_keyboard_input(input),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update(&mut self) {
|
||||
let _span = span!("script update");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue