Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
642 changes: 316 additions & 326 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ futures-channel = "0.3"
euclid = "0.22"

lilt = "0.8"
winit = "0.30"
winit = "0.31.0-beta.2"
dpi = "0.1"
rfd = "0.17"
cpal = "0.17"
Expand Down
35 changes: 30 additions & 5 deletions neothesia/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,37 @@ use crate::{
};
use neothesia_core::render::{QuadRendererFactory, TextRendererFactory};
use wgpu_jumpstart::{Gpu, Uniform};
use winit::event_loop::EventLoopProxy;

use winit::window::Window;

#[derive(Clone)]
pub struct EventLoopProxy {
proxy: winit::event_loop::EventLoopProxy,
tx: std::sync::mpsc::Sender<NeothesiaEvent>,
}

impl EventLoopProxy {
pub fn new(
proxy: winit::event_loop::EventLoopProxy,
) -> (Self, std::sync::mpsc::Receiver<NeothesiaEvent>) {
let (tx, rx) = std::sync::mpsc::channel();

(Self { proxy, tx }, rx)
}

pub fn send_event(&self, event: NeothesiaEvent) -> Result<(), ()> {
if let Err(err) = self.tx.send(event) {
log::error!("winit event send: {err}");
// TODO: Drop this once winit 0.31 is stable and merge conflits are no longer a concern
return Err(());
}
self.proxy.wake_up();
Ok(())
}
}

pub struct Context {
pub window: Arc<Window>,
pub window: Arc<dyn Window>,

pub window_state: WindowState,
pub gpu: Gpu,
Expand All @@ -24,7 +49,7 @@ pub struct Context {
pub input_manager: InputManager,
pub config: Config,

pub proxy: EventLoopProxy<NeothesiaEvent>,
pub proxy: EventLoopProxy,

/// Last frame timestamp
pub frame_timestamp: std::time::Instant,
Expand All @@ -41,9 +66,9 @@ impl Drop for Context {

impl Context {
pub fn new(
window: Arc<Window>,
window: Arc<dyn Window>,
window_state: WindowState,
proxy: EventLoopProxy<NeothesiaEvent>,
proxy: EventLoopProxy,
gpu: Gpu,
) -> Self {
let transform_uniform = Uniform::new(
Expand Down
7 changes: 3 additions & 4 deletions neothesia/src/input_manager/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use midi_file::midly::{self, MidiMessage, live::LiveEvent};
use winit::event_loop::EventLoopProxy;

use crate::NeothesiaEvent;
use crate::{NeothesiaEvent, context::EventLoopProxy};

pub struct InputManager {
input: midi_io::MidiInputManager,
tx: EventLoopProxy<NeothesiaEvent>,
tx: EventLoopProxy,
current_connection: Option<midi_io::MidiInputConnection>,
}

impl InputManager {
pub fn new(tx: EventLoopProxy<NeothesiaEvent>) -> Self {
pub fn new(tx: EventLoopProxy) -> Self {
let input = midi_io::MidiInputManager::new().unwrap();
Self {
input,
Expand Down
Loading