Merge branch 'sr1canskhsia-main'

main
4yn 2025-03-22 15:01:14 +08:00
commit 7cc6e46afe
3 changed files with 61 additions and 1 deletions

View File

@ -5,6 +5,7 @@ pub enum HardwareSpec {
TasollerOne,
TasollerTwo,
Yuancon,
YuanconThree,
Yubideck,
YubideckThree,
}
@ -50,6 +51,10 @@ impl DeviceMode {
spec: HardwareSpec::Yuancon,
disable_air: v["disableAirStrings"].as_bool()?,
},
"yuancon-three" => DeviceMode::Hardware {
spec: HardwareSpec::YuanconThree,
disable_air: v["disableAirStrings"].as_bool()?,
},
"yubideck" => DeviceMode::Hardware {
spec: HardwareSpec::Yubideck,
disable_air: v["disableAirStrings"].as_bool()?,

View File

@ -205,6 +205,53 @@ impl HidJob {
}
},
),
HardwareSpec::YuanconThree => Self::new(
state.clone(),
0x0518,
0x2022,
0x83,
0x03,
*disable_air,
|buf, input| {
if buf.len != 46 { // real length is 46 but last 12 bytes are unused
return;
}
input.ground.copy_from_slice(&buf.data[2..34]);
input.flip_vert();
let bits: Vec<u8> = (0..8).map(|x| (buf.data[0] >> x) & 1).collect();
for i in 0..6 {
input.air[i ^ 1] = bits[i];
}
input.extra[0..2].copy_from_slice(&bits[6..8]);
},
WriteType::Interrupt,
|buf, buf_two, lights| {
buf.len = 61;
buf.data[0] = 0;
buf_two.len = 61;
buf_two.data[0] = 1;
for (buf_chunk, state_chunk) in buf.data[1..61]
.chunks_mut(3)
.zip(lights.ground.chunks(3).skip(11).take(20).rev())
{
buf_chunk[0] = state_chunk[0];
buf_chunk[1] = state_chunk[1];
buf_chunk[2] = state_chunk[2];
}
for (buf_chunk, state_chunk) in buf_two.data[1..34]
.chunks_mut(3)
.zip(lights.ground.chunks(3).take(11).rev())
{
buf_chunk[0] = state_chunk[0];
buf_chunk[1] = state_chunk[1];
buf_chunk[2] = state_chunk[2];
}
},
),
HardwareSpec::Yubideck => Self::new(
state.clone(),
0x1973,
@ -323,8 +370,15 @@ impl HidJob {
}
info!("Device setting configuration");
handle.set_active_configuration(1)?;
// A bit janky but Laverita v3 seems to require interface 3
info!("Device claiming interface");
handle.claim_interface(0)?;
if self.vid == 0x0518 && self.pid == 0x2022 {
handle.claim_interface(3)?;
} else {
handle.claim_interface(0)?;
}
self.handle = Some(handle);
Ok(())
}

View File

@ -196,6 +196,7 @@
<option value="tasoller-one">GAMO2 Tasoller, 1.0 HID Firmware</option>
<option value="tasoller-two">GAMO2 Tasoller, 2.0 HID Firmware</option>
<option value="yuancon">Yuancon Laverita, HID Firmware</option>
<option value="yuancon-three">Yuancon Laverita v3, HID Firmware</option>
<option value="yubideck">大四 / Yubideck, HID Firmware 1.0</option>
<option value="yubideck-three">大四 / Yubideck, HID Firmware 3.0</option>
<option value="diva">Slider over Serial</option>