Feat: anime matrix gets custom image and gif support for Scar 2025 with other minor fixes

This commit is contained in:
Ghoul
2026-01-24 02:43:53 +00:00
committed by Denis Benato
parent 2ea2cec172
commit 90af90850a
17 changed files with 1448 additions and 49 deletions

View File

@@ -0,0 +1,70 @@
use super::Row;
// TODO: This is a placeholder for G635L map
pub const G635L: [Row; 63] = [
Row(0x01, 7, 32, 0),
Row(0x01, 7 + 34, 32, 0),
Row(0x01, 7 + 68, 32, 0),
Row(0x01, 7 + 102, 32, 0), // 34 len
Row(0x01, 7 + 136, 32, 0),
Row(0x01, 7 + 170, 34, 0),
Row(0x01, 7 + 204, 34, 0),
Row(0x01, 7 + 238, 34, 0),
Row(0x01, 7 + 272, 34, 0),
Row(0x01, 7 + 306, 34, 0),
Row(0x01, 7 + 340, 34, 0),
Row(0x01, 7 + 374, 34, 0),
Row(0x01, 7 + 408, 33, 1),
Row(0x01, 7 + 441, 33, 1),
Row(0x01, 7 + 474, 32, 2),
Row(0x01, 7 + 506, 32, 2),
Row(0x01, 7 + 538, 31, 3),
Row(0x01, 7 + 569, 31, 3),
Row(0x01, 7 + 600, 28, 4),
//
Row(0x74, 7 + 1, 3, 28 + 4), // adds to end of previous
Row(0x74, 7 + 3, 30, 4),
Row(0x74, 7 + 33, 29, 5),
Row(0x74, 7 + 62, 29, 5),
Row(0x74, 7 + 91, 28, 6),
Row(0x74, 7 + 119, 28, 6),
Row(0x74, 7 + 147, 27, 7),
Row(0x74, 7 + 174, 27, 7),
Row(0x74, 7 + 202, 26, 9),
Row(0x74, 7 + 228, 26, 9),
Row(0x74, 7 + 254, 25, 10),
Row(0x74, 7 + 278, 25, 9), // WEIRD OFFSET
Row(0x74, 7 + 303, 24, 10),
Row(0x74, 7 + 327, 24, 10),
Row(0x74, 7 + 351, 23, 11),
Row(0x74, 7 + 374, 23, 11),
Row(0x74, 7 + 397, 22, 12),
Row(0x74, 7 + 419, 22, 12),
Row(0x74, 7 + 441, 21, 13),
Row(0x74, 7 + 462, 21, 13),
Row(0x74, 7 + 483, 20, 14),
Row(0x74, 7 + 503, 20, 14),
Row(0x74, 7 + 523, 19, 15),
Row(0x74, 7 + 542, 19, 15),
Row(0x74, 7 + 561, 18, 16),
Row(0x74, 7 + 579, 18, 16),
Row(0x74, 7 + 597, 17, 17),
Row(0x74, 7 + 614, 13, 17),
//
Row(0xe7, 7 + 1, 4, 13 + 18), // adds to end of previous
Row(0xe7, 7 + 4, 16, 18),
Row(0xe7, 7 + 20, 16, 18),
Row(0xe7, 7 + 36, 15, 19),
Row(0xe7, 7 + 51, 15, 19),
Row(0xe7, 7 + 66, 14, 20),
Row(0xe7, 7 + 80, 12, 20), // too long? 14
Row(0xe7, 7 + 94, 13, 21),
Row(0xe7, 7 + 107, 13, 21),
Row(0xe7, 7 + 120, 12, 12), // Actual display end
Row(0xe7, 7 + 132, 12, 22),
Row(0xe7, 7 + 144, 11, 23),
Row(0xe7, 7 + 155, 11, 23),
Row(0xe7, 7 + 166, 10, 24),
Row(0xe7, 7 + 176, 10, 24),
Row(0xe7, 7 + 186, 9, 25),
];

View File

@@ -0,0 +1,74 @@
use super::Row;
// G835L layout: 68 rows (triangle + rectangle), 2 packets
pub const G835L: [Row; 69] = [
Row(0x01, 7, 0, 0),
Row(0x01, 8, 0, 0),
Row(0x01, 9, 1, 0),
Row(0x01, 11, 1, 0),
Row(0x01, 13, 2, 0),
Row(0x01, 16, 2, 0),
Row(0x01, 19, 3, 0),
Row(0x01, 23, 3, 0),
Row(0x01, 27, 4, 0),
Row(0x01, 32, 4, 0),
Row(0x01, 37, 5, 0),
Row(0x01, 43, 5, 0),
Row(0x01, 49, 6, 0),
Row(0x01, 56, 6, 0),
Row(0x01, 63, 7, 0),
Row(0x01, 71, 7, 0),
Row(0x01, 79, 8, 0),
Row(0x01, 88, 8, 0),
Row(0x01, 97, 9, 0),
Row(0x01, 107, 9, 0),
Row(0x01, 117, 10, 0),
Row(0x01, 128, 10, 0),
Row(0x01, 139, 11, 0),
Row(0x01, 151, 11, 0),
Row(0x01, 163, 12, 0),
Row(0x01, 176, 12, 0),
Row(0x01, 189, 13, 0),
Row(0x01, 203, 13, 0),
Row(0x01, 217, 14, 0),
Row(0x01, 232, 14, 0),
Row(0x01, 247, 14, 1),
Row(0x01, 262, 14, 1),
Row(0x01, 277, 14, 2),
Row(0x01, 292, 14, 2),
Row(0x01, 307, 14, 3),
Row(0x01, 322, 14, 3),
Row(0x01, 337, 14, 4),
Row(0x01, 352, 14, 4),
Row(0x01, 367, 14, 5),
Row(0x01, 382, 14, 5),
Row(0x01, 397, 14, 6),
Row(0x01, 412, 14, 6),
Row(0x01, 427, 14, 7),
Row(0x01, 442, 14, 7),
Row(0x01, 457, 14, 8),
Row(0x01, 472, 14, 8),
Row(0x01, 487, 14, 9),
Row(0x01, 502, 14, 9),
Row(0x01, 517, 14, 10),
Row(0x01, 532, 14, 10),
Row(0x01, 547, 14, 11),
Row(0x01, 562, 14, 11),
Row(0x01, 577, 14, 12),
Row(0x01, 592, 14, 12),
Row(0x01, 607, 14, 13),
Row(0x01, 622, 11, 13),
Row(0x74, 7, 2, 25),
Row(0x74, 10, 14, 14),
Row(0x74, 25, 14, 14),
Row(0x74, 40, 14, 15),
Row(0x74, 55, 14, 15),
Row(0x74, 70, 14, 16),
Row(0x74, 85, 14, 16),
Row(0x74, 100, 14, 17),
Row(0x74, 115, 14, 17),
Row(0x74, 130, 14, 18),
Row(0x74, 145, 14, 18),
Row(0x74, 160, 14, 19),
Row(0x74, 175, 14, 19),
];

View File

@@ -1,9 +1,13 @@
use rog_anime::AnimeType;
use self::map_g635l::G635L;
use self::map_g835l::G835L;
use self::map_ga401::GA401;
use self::map_ga402::GA402;
use self::map_gu604::GU604;
mod map_g635l;
mod map_g835l;
mod map_ga401;
mod map_ga402;
mod map_gu604;
@@ -38,30 +42,18 @@ pub struct AniMatrix {
impl AniMatrix {
pub fn new(model: AnimeType) -> Self {
let led_shape = match model {
AnimeType::GA401 => LedShape {
vertical: 2,
horizontal: 5,
},
AnimeType::GA402 | AnimeType::G635L | AnimeType::G835L | AnimeType::Unsupported => {
LedShape {
vertical: 2,
horizontal: 5,
}
}
AnimeType::GU604 => LedShape {
vertical: 2,
horizontal: 5,
},
let led_shape = LedShape {
vertical: 2,
horizontal: 5,
};
// Do a hard mapping of each (derived from wireshardk captures)
let rows = match model {
AnimeType::GA401 => GA401.to_vec(),
AnimeType::GA402 | AnimeType::G635L | AnimeType::G835L | AnimeType::Unsupported => {
GA402.to_vec()
}
AnimeType::GA402 | AnimeType::Unsupported => GA402.to_vec(),
AnimeType::GU604 => GU604.to_vec(),
AnimeType::G635L => G635L.to_vec(),
AnimeType::G835L => G835L.to_vec(),
};
Self { rows, led_shape }

View File

@@ -2,7 +2,6 @@ use std::env;
use std::error::Error;
use std::str::FromStr;
use log::error;
use rog_anime::usb::{PROD_ID, VENDOR_ID};
use rog_anime::{AnimeType, USB_PREFIX2};
use sdl2::event::Event;
@@ -20,6 +19,7 @@ pub struct VirtAnimeMatrix {
animatrix: AniMatrix,
}
// TODO: This isn't working
impl VirtAnimeMatrix {
pub fn new(model: AnimeType) -> Self {
VirtAnimeMatrix {
@@ -86,8 +86,12 @@ impl VirtAnimeMatrix {
]
.to_vec(),
})
.map_err(|err| error!("Could not create virtual device: {:?}", err))
.expect("Could not create virtual device"),
.unwrap_or_else(|err| {
panic!(
"Could not create virtual device: {err:?}. \
Try loading the uhid module and ensure you have the necessary permissions."
)
}),
}
}
@@ -114,7 +118,7 @@ impl VirtAnimeMatrix {
fn main() -> Result<(), Box<dyn Error>> {
let args: Vec<String> = env::args().collect();
if args.len() <= 1 {
println!("Must supply arg, one of <GA401, GA402, GU604>");
println!("Must supply arg, one of <GA401, GA402, GU604, G835L>");
return Ok(());
}
let anime_type = AnimeType::from_str(&args[1])?;