Compare commits

..
2 Commits
Author SHA1 Message Date
SonicSwordcane 2ce0edee76 chore: Release lemur version 0.12.4 2026-05-22 00:02:15 -04:00
SonicSwordcane d21cb4e5d0 Fix controller code 2026-05-21 23:45:00 -04:00
3 changed files with 25 additions and 4 deletions
Generated
+1 -1
View File
@@ -2122,7 +2122,7 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "lemur"
version = "0.12.3"
version = "0.12.4"
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.12.3"
version = "0.12.4"
edition = "2024"
[dependencies]
+23 -2
View File
@@ -61,7 +61,14 @@ impl Controller {
let neg = mapping.neg;
let pos = mapping.pos;
axis_presses(value, pair_value, neg, pos)
let (mut pressed, mut released) = axis_presses(value, pair_value, neg, pos);
if let Some(other) = mapping.pair.and_then(|p| self.map_axis(&event.id, &p)) {
let (other_pressed, other_released) =
axis_presses(pair_value, value, other.neg, other.pos);
pressed = pressed.union(other_pressed);
released = released.union(other_released);
}
(pressed, released)
}
_ => {
return None;
@@ -135,7 +142,7 @@ fn axis_presses(value: f32, pair_value: f32, neg: VBKey, pos: VBKey) -> (VBKey,
let mut released = VBKey::empty();
let magnitude = value.hypot(pair_value);
let abs_angle = pair_value.atan2(value);
let abs_angle = pair_value.atan2(value).abs();
if magnitude < 0.65 {
released = released.union(neg).union(pos);
@@ -204,4 +211,18 @@ mod tests {
assert_eq!(pressed, POS);
assert_eq!(released, NEG);
}
#[test]
fn ignores_diagonal_noise() {
let (pressed, released) = axis_presses(-1.0, -0.1484245, NEG, POS);
assert_eq!(pressed, NEG);
assert_eq!(released, POS);
}
#[test]
fn ignores_small_values() {
let (pressed, released) = axis_presses(-0.1484245, -1.0, NEG, POS);
assert_eq!(pressed, NONE);
assert_eq!(released, BOTH);
}
}