Compare commits

..
4 Commits
Author SHA1 Message Date
SonicSwordcane ec7a89d9da chore: Release lemur version 0.15.0 2026-08-15 01:00:33 -04:00
SonicSwordcane a6c12a986c Persist watch rom setting 2026-08-15 00:59:35 -04:00
SonicSwordcane 762f43fd42 Support emulating low battery 2026-08-15 00:52:40 -04:00
SonicSwordcane 3a00497942 Fix warning on not-linux 2026-08-15 00:27:03 -04:00
7 changed files with 42 additions and 3 deletions
Generated
+1 -1
View File
@@ -2034,7 +2034,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "lemur"
version = "0.14.0"
version = "0.15.0"
dependencies = [
"anyhow",
"atoi",
+1 -1
View File
@@ -4,7 +4,7 @@ description = "An emulator for the Virtual Boy."
repository = "https://git.virtual-boy.com/PVB/lemur"
publish = false
license = "MIT"
version = "0.14.0"
version = "0.15.0"
edition = "2024"
[dependencies]
+4
View File
@@ -467,6 +467,9 @@ impl ApplicationHandler<UserEvent> for Application {
self.controllers.handle_gamepad_event(&event);
}
}
UserEvent::LowBattery(sim_id, pwr) => {
self.controllers.handle_low_battery(sim_id, pwr);
}
UserEvent::Quit(sim_id) => match sim_id {
SimId::Player1 => event_loop.exit(),
SimId::Player2 => self.app.close(ChildWindow::Player2),
@@ -673,6 +676,7 @@ impl ViewportManager {
pub enum UserEvent {
GamepadEvent(gilrs::Event),
Quit(SimId),
LowBattery(SimId, bool),
RequestRedraw(ViewportId, Instant),
}
+6
View File
@@ -141,6 +141,10 @@ pub struct SimConfig {
#[serde(default = "default_audio_enabled")]
pub audio_enabled: bool,
#[serde(default)]
pub low_battery: bool,
#[serde(default)]
pub watch_rom: bool,
#[serde(default)]
pub position: Option<Pos2>,
}
@@ -154,6 +158,8 @@ impl SimConfig {
colors: COLOR_PRESETS[0],
dimensions: DisplayMode::Anaglyph.proportions() + Vec2::new(0.0, 22.0),
audio_enabled: true,
low_battery: false,
watch_rom: false,
position: None,
}
}
+17
View File
@@ -77,6 +77,15 @@ impl Controller {
self.update_state(pressed, released)
}
pub fn low_battery(&mut self, pwr: bool) -> Option<VBKey> {
let (pressed, released) = if pwr {
(VBKey::PWR, VBKey::empty())
} else {
(VBKey::empty(), VBKey::PWR)
};
self.update_state(pressed, released)
}
fn update_state(&mut self, pressed: VBKey, released: VBKey) -> Option<VBKey> {
let old_state = self.state;
self.state = self.state.union(pressed).difference(released);
@@ -133,6 +142,14 @@ impl ControllerManager {
}
}
}
pub fn handle_low_battery(&mut self, sim_id: SimId, pwr: bool) {
let controller = &mut self.controllers[sim_id.to_index()];
if let Some(pressed) = controller.low_battery(pwr) {
self.client
.send_command(EmulatorCommand::SetKeys(controller.sim_id, pressed));
}
}
}
fn axis_presses(value: f32, pair_value: f32, neg: VBKey, pos: VBKey) -> (VBKey, VBKey) {
+2 -1
View File
@@ -1,5 +1,6 @@
#[cfg(target_os = "linux")]
use std::fmt::Write as _;
use std::{
fmt::Write as _,
path::PathBuf,
sync::{Arc, Weak},
};
+11
View File
@@ -72,6 +72,8 @@ impl GameWindow {
sim_id: SimId,
) -> Self {
let config = SimConfig::load(&persistence, sim_id);
let _ = proxy.send_event(UserEvent::LowBattery(sim_id, config.low_battery));
client.send_command(EmulatorCommand::WatchRom(sim_id, config.watch_rom));
let toasts = Toasts::new()
.with_anchor(Anchor::BottomLeft)
.with_margin((10.0, 10.0).into())
@@ -332,6 +334,7 @@ impl GameWindow {
}
let watch_rom = self.client.is_rom_watched(self.sim_id);
if ui.selectable_button(watch_rom, "Watch ROM").clicked() {
self.update_config(|c| c.watch_rom = !watch_rom);
self.client
.send_command(EmulatorCommand::WatchRom(self.sim_id, !watch_rom));
}
@@ -389,6 +392,14 @@ impl GameWindow {
{
pollster::block_on(self.take_screenshot());
}
ui.separator();
let low_battery = self.config.low_battery;
if ui.selectable_button(low_battery, "Low Battery").clicked() {
self.update_config(|c| c.low_battery = !low_battery);
let _ = self
.proxy
.send_event(UserEvent::LowBattery(self.sim_id, !low_battery));
}
});
ui.menu_button("Options", |ui| self.show_options_menu(ui));
ui.menu_button("Multiplayer", |ui| {