Save and load SRAM at all the right times

This commit is contained in:
2024-12-08 14:39:40 -05:00
parent e9ae8bed1b
commit 0504e351ba
4 changed files with 51 additions and 11 deletions
+11 -2
View File
@@ -1,4 +1,4 @@
use std::{collections::HashSet, num::NonZero, sync::Arc, thread};
use std::{collections::HashSet, num::NonZero, sync::Arc, thread, time::Duration};
use egui::{
ahash::{HashMap, HashMapExt},
@@ -15,7 +15,7 @@ use winit::{
use crate::{
controller::ControllerManager,
emulator::{EmulatorClient, SimId},
emulator::{EmulatorClient, EmulatorCommand, SimId},
input::MappingProvider,
window::{AppWindow, GameWindow, InputWindow},
};
@@ -170,6 +170,15 @@ impl ApplicationHandler<UserEvent> for Application {
viewport.window.request_redraw();
}
}
fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
let (sender, receiver) = oneshot::channel();
if self.client.send_command(EmulatorCommand::Exit(sender)) {
if let Err(err) = receiver.recv_timeout(Duration::from_secs(5)) {
eprintln!("could not gracefully exit: {}", err);
}
}
}
}
struct Viewport {