Skip to content

Commit 7cc6e46

Browse files
committed
Merge branch 'sr1canskhsia-main'
2 parents 6124dee + 7b63ff3 commit 7cc6e46

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

src-slider_io/src/device/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub enum HardwareSpec {
55
TasollerOne,
66
TasollerTwo,
77
Yuancon,
8+
YuanconThree,
89
Yubideck,
910
YubideckThree,
1011
}
@@ -50,6 +51,10 @@ impl DeviceMode {
5051
spec: HardwareSpec::Yuancon,
5152
disable_air: v["disableAirStrings"].as_bool()?,
5253
},
54+
"yuancon-three" => DeviceMode::Hardware {
55+
spec: HardwareSpec::YuanconThree,
56+
disable_air: v["disableAirStrings"].as_bool()?,
57+
},
5358
"yubideck" => DeviceMode::Hardware {
5459
spec: HardwareSpec::Yubideck,
5560
disable_air: v["disableAirStrings"].as_bool()?,

src-slider_io/src/device/hid.rs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,53 @@ impl HidJob {
205205
}
206206
},
207207
),
208+
HardwareSpec::YuanconThree => Self::new(
209+
state.clone(),
210+
0x0518,
211+
0x2022,
212+
0x83,
213+
0x03,
214+
*disable_air,
215+
|buf, input| {
216+
if buf.len != 46 { // real length is 46 but last 12 bytes are unused
217+
return;
218+
}
219+
220+
input.ground.copy_from_slice(&buf.data[2..34]);
221+
input.flip_vert();
222+
223+
let bits: Vec<u8> = (0..8).map(|x| (buf.data[0] >> x) & 1).collect();
224+
for i in 0..6 {
225+
input.air[i ^ 1] = bits[i];
226+
}
227+
input.extra[0..2].copy_from_slice(&bits[6..8]);
228+
},
229+
WriteType::Interrupt,
230+
|buf, buf_two, lights| {
231+
buf.len = 61;
232+
buf.data[0] = 0;
233+
buf_two.len = 61;
234+
buf_two.data[0] = 1;
235+
236+
for (buf_chunk, state_chunk) in buf.data[1..61]
237+
.chunks_mut(3)
238+
.zip(lights.ground.chunks(3).skip(11).take(20).rev())
239+
{
240+
buf_chunk[0] = state_chunk[0];
241+
buf_chunk[1] = state_chunk[1];
242+
buf_chunk[2] = state_chunk[2];
243+
}
244+
245+
for (buf_chunk, state_chunk) in buf_two.data[1..34]
246+
.chunks_mut(3)
247+
.zip(lights.ground.chunks(3).take(11).rev())
248+
{
249+
buf_chunk[0] = state_chunk[0];
250+
buf_chunk[1] = state_chunk[1];
251+
buf_chunk[2] = state_chunk[2];
252+
}
253+
},
254+
),
208255
HardwareSpec::Yubideck => Self::new(
209256
state.clone(),
210257
0x1973,
@@ -323,8 +370,15 @@ impl HidJob {
323370
}
324371
info!("Device setting configuration");
325372
handle.set_active_configuration(1)?;
373+
374+
// A bit janky but Laverita v3 seems to require interface 3
326375
info!("Device claiming interface");
327-
handle.claim_interface(0)?;
376+
if self.vid == 0x0518 && self.pid == 0x2022 {
377+
handle.claim_interface(3)?;
378+
} else {
379+
handle.claim_interface(0)?;
380+
}
381+
328382
self.handle = Some(handle);
329383
Ok(())
330384
}

src/App.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
<option value="tasoller-one">GAMO2 Tasoller, 1.0 HID Firmware</option>
197197
<option value="tasoller-two">GAMO2 Tasoller, 2.0 HID Firmware</option>
198198
<option value="yuancon">Yuancon Laverita, HID Firmware</option>
199+
<option value="yuancon-three">Yuancon Laverita v3, HID Firmware</option>
199200
<option value="yubideck">大四 / Yubideck, HID Firmware 1.0</option>
200201
<option value="yubideck-three">大四 / Yubideck, HID Firmware 3.0</option>
201202
<option value="diva">Slider over Serial</option>

0 commit comments

Comments
 (0)