Update readme, slash configs

This commit is contained in:
Luke D. Jones
2025-01-12 17:36:10 +13:00
parent 2123f369ad
commit 128bc3fce1
113 changed files with 1545 additions and 1305 deletions

View File

@@ -16,7 +16,7 @@ pub enum SlashType {
GA605,
GU605,
#[default]
Unsupported,
Unsupported
}
impl SlashType {
@@ -25,7 +25,7 @@ impl SlashType {
SlashType::GA403 => PROD_ID1,
SlashType::GA605 => PROD_ID2,
SlashType::GU605 => PROD_ID1,
SlashType::Unsupported => 0,
SlashType::Unsupported => 0
}
}
@@ -34,7 +34,7 @@ impl SlashType {
SlashType::GA403 => PROD_ID1_STR,
SlashType::GA605 => PROD_ID2_STR,
SlashType::GU605 => PROD_ID1_STR,
SlashType::Unsupported => "",
SlashType::Unsupported => ""
}
}
@@ -60,7 +60,7 @@ impl FromStr for SlashType {
"ga403" | "GA403" => Self::GA403,
"ga605" | "GA605" => Self::GA605,
"gu605" | "GU605" => Self::GU605,
_ => Self::Unsupported,
_ => Self::Unsupported
})
}
}
@@ -83,7 +83,7 @@ pub enum SlashMode {
Ramp = 0x34,
GameOver = 0x42,
Start = 0x43,
Buzzer = 0x44,
Buzzer = 0x44
}
impl FromStr for SlashMode {
@@ -106,7 +106,7 @@ impl FromStr for SlashMode {
"GameOver" => Ok(SlashMode::GameOver),
"Start" => Ok(SlashMode::Start),
"Buzzer" => Ok(SlashMode::Buzzer),
_ => Ok(SlashMode::Bounce),
_ => Ok(SlashMode::Bounce)
}
}
}
@@ -128,7 +128,7 @@ impl Display for SlashMode {
SlashMode::Ramp => String::from("Ramp"),
SlashMode::GameOver => String::from("GameOver"),
SlashMode::Start => String::from("Start"),
SlashMode::Buzzer => String::from("Buzzer"),
SlashMode::Buzzer => String::from("Buzzer")
};
write!(f, "{}", str)
}
@@ -151,7 +151,7 @@ impl SlashMode {
SlashMode::Ramp.to_string(),
SlashMode::GameOver.to_string(),
SlashMode::Start.to_string(),
SlashMode::Buzzer.to_string(),
SlashMode::Buzzer.to_string()
]
}
}
@@ -162,5 +162,5 @@ pub struct DeviceState {
pub slash_enabled: bool,
pub slash_brightness: u8,
pub slash_interval: u8,
pub slash_mode: SlashMode,
pub slash_mode: SlashMode
}

View File

@@ -9,7 +9,7 @@ pub enum SlashError {
NoDevice,
UnsupportedDevice,
DataBufferLength,
ParseError(String),
ParseError(String)
}
impl fmt::Display for SlashError {
@@ -24,7 +24,7 @@ impl fmt::Display for SlashError {
f,
"The data buffer was incorrect length for generating USB packets"
),
SlashError::UnsupportedDevice => write!(f, "Unsupported Slash device found"),
SlashError::UnsupportedDevice => write!(f, "Unsupported Slash device found")
}
}
}

View File

@@ -55,7 +55,7 @@ pub const fn report_id(slash_type: SlashType) -> u8 {
SlashType::GA403 => REPORT_ID_193B,
SlashType::GA605 => REPORT_ID_19B6,
SlashType::GU605 => REPORT_ID_193B,
SlashType::Unsupported => REPORT_ID_19B6,
SlashType::Unsupported => REPORT_ID_19B6
}
}
@@ -81,7 +81,9 @@ pub fn pkts_for_init(slash_type: SlashType) -> [SlashUsbPacket; 2] {
pkt2[4] = 0x08;
pkt2[5] = 0xab;
[pkt1, pkt2]
[
pkt1, pkt2
]
}
#[inline]
@@ -126,40 +128,68 @@ pub const fn pkt_set_mode(slash_type: SlashType, mode: SlashMode) -> [SlashUsbPa
pkt2[15] = 0x06;
pkt2[16] = 0x13;
[pkt1, pkt2]
[
pkt1, pkt2
]
}
/// DEVICE SETTINGS
/// Interval:
/// - 1 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0x19, 0xff, 0x1
/// - 5 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0x19, 0xff, 0x5
/// Brightness: 100
/// - 100 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0xff, 0xff
/// - 000 = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x1, 0x6, 0x00, 0xff
/// - off = 0x5d, 0xd3, 0x3, 0x1, 0x8, 0xab, 0xff, 0x1, 0x0, 0x6, 0xff, 0xff
#[inline]
pub const fn pkt_set_options(
pub const fn get_options_packet(
slash_type: SlashType,
enabled: bool,
brightness: u8,
interval: u8,
) -> SlashUsbPacket {
let status_byte = if enabled { 0x01 } else { 0x00 };
let mut pkt = [0; PACKET_SIZE];
pkt[0] = report_id(slash_type);
pkt[1] = 0xd3;
pkt[2] = 0x03;
pkt[3] = 0x01;
pkt[4] = 0x08;
pkt[5] = 0xab; // Setting byte 1
pkt[6] = 0xff; // Setting byte 2
pkt[7] = 0x01;
pkt[8] = status_byte; // Setting enable/disable
pkt[9] = 0x06;
pkt[10] = brightness;
pkt[11] = 0xff;
pkt[12] = interval;
pkt
interval: u8
) -> [u8; 13] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
typ, 0xd3, 0x03, 0x01, 0x08, 0xab, 0xff, 0x01, status, 0x06, brightness, 0xff, interval
]
}
pub const fn get_boot_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
typ, 0xd3, 0x03, 0x01, 0x08, 0xa0, 0x04, 0xff, status, 0x01, 0xff, 0x00
]
}
pub const fn get_sleep_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = (!enabled) as u8;
[
typ, 0xd3, 0x03, 0x01, 0x08, 0xa1, 0x00, 0xff, status, 0x02, 0xff, 0xff
]
}
pub const fn get_low_battery_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
typ, 0xd3, 0x03, 0x01, 0x08, 0xa2, 0x01, 0xff, status, 0x02, 0xff, 0xff
]
}
pub const fn get_shutdown_packet(slash_type: SlashType, enabled: bool) -> [u8; 12] {
let typ = report_id(slash_type);
let status = enabled as u8;
[
typ, 0xd3, 0x03, 0x01, 0x08, 0xa4, 0x05, 0xff, status, 0x01, 0xff, 0x00
]
}
pub const fn get_battery_saver_packet(slash_type: SlashType, enabled: bool) -> [u8; 6] {
let typ = report_id(slash_type);
let status = if enabled { 0x00 } else { 0x80 };
[
typ, 0xd8, 0x01, 0x00, 0x01, status
]
}
pub const fn get_lid_closed_packet(slash_type: SlashType, enabled: bool) -> [u8; 7] {
let typ = report_id(slash_type);
let status = if enabled { 0x00 } else { 0x80 };
[
typ, 0xd8, 0x00, 0x00, 0x02, 0xa5, status
]
}