1
0
mirror of https://github.com/4yn/slidershim.git synced 2024-11-24 05:50:12 +01:00

add yubideck hid support

This commit is contained in:
4yn 2022-03-25 15:13:49 +08:00
parent 856d2ea49a
commit 1fe10cf615
3 changed files with 50 additions and 1 deletions

View File

@ -5,6 +5,7 @@ pub enum HardwareSpec {
TasollerOne,
TasollerTwo,
Yuancon,
Yubideck,
}
#[derive(Debug, Clone)]
@ -47,6 +48,10 @@ impl DeviceMode {
spec: HardwareSpec::Yuancon,
disable_air: v["disableAirStrings"].as_bool()?,
},
"yubideck" => DeviceMode::Hardware {
spec: HardwareSpec::Yubideck,
disable_air: v["disableAirStrings"].as_bool()?,
},
"diva" => DeviceMode::DivaSlider {
port: v["divaSerialPort"].as_str()?.to_string(),
brightness: u8::try_from(v["divaBrightness"].as_i64()?).ok()?,

View File

@ -190,6 +190,49 @@ impl HidJob {
}
},
),
HardwareSpec::Yubideck => Self::new(
state.clone(),
0x1973,
0x2001,
0x81, // Need to confirm
0x02, // Need to confirm
*disable_air,
|buf, input| {
if buf.len != 45 {
return;
}
input.ground.copy_from_slice(&buf.data[2..34]);
for i in 0..6 {
input.air[i ^ 1] = (buf.data[0] >> i) & 1;
}
for i in 0..3 {
input.extra[2 - i] = (buf.data[1] >> i) & 1;
}
},
WriteType::Interrupt,
|buf, lights| {
buf.len = 62;
let lights_nibbles: Vec<u8> = lights
.ground
.chunks(3)
.rev()
.flat_map(|x| x.iter().map(|y| *y >> 4))
.chain([0, 0, 0])
.collect();
for (buf_chunk, state_chunk) in buf
.data
.chunks_mut(3)
.take(16)
.zip(lights_nibbles.chunks(6))
{
buf_chunk[0] = (state_chunk[0]) | (state_chunk[1] << 4);
buf_chunk[1] = (state_chunk[2]) | (state_chunk[3] << 4);
buf_chunk[2] = (state_chunk[4]) | (state_chunk[5] << 4);
}
},
),
}
}

View File

@ -181,6 +181,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="yubideck">大四 / Yubideck, HID Firmware</option>
<option value="diva">Slider over Serial</option>
<option value="brokenithm">Brokenithm</option>
<option value="brokenithm-led">Brokenithm + Led</option>
@ -188,7 +189,7 @@
</select>
</div>
</div>
{#if deviceMode.slice(0, 8) === "tasoller" || deviceMode.slice(0, 7) === "yuancon" || (deviceMode.slice(0, 10) === "brokenithm" && deviceMode !== "brokenithm-nostalgia")}
{#if deviceMode.slice(0, 8) === "tasoller" || deviceMode.slice(0, 7) === "yuancon" || deviceMode.slice(0, 8) === "yubideck" || (deviceMode.slice(0, 10) === "brokenithm" && deviceMode !== "brokenithm-nostalgia")}
<div class="row">
<div class="label" />
<div class="input">