diff --git a/Cargo.toml b/Cargo.toml index 6578fd3..5901a6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ panic = "abort" chusan = [] tasoller_v1 = [] tasoller_v2 = [] -yubideck_v3 = [] [dependencies] anyhow = "1.0.76" diff --git a/README.md b/README.md index e413383..dd1d052 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ coin=0x33 Currently supported backends are: - `tasoller_v1` - `tasoller_v2` -- `yubideck_v3` ```shell CONTROLLER="tasoller_v1" # replace with your preferred controller backend diff --git a/build-all.sh b/build-all.sh index 130f2e8..cab53c1 100644 --- a/build-all.sh +++ b/build-all.sh @@ -3,7 +3,7 @@ mkdir -p dist/chusan mkdir -p dist/chuni -for backend in tasoller_v1 tasoller_v2 yubideck_v3 +for backend in tasoller_v1 tasoller_v2 do cargo build --target i686-pc-windows-msvc --release --features chusan,$backend cargo build --target x86_64-pc-windows-msvc --release --features chusan,$backend diff --git a/src/backends/README.md b/src/backends/README.md index 00424c9..19bfb8a 100644 --- a/src/backends/README.md +++ b/src/backends/README.md @@ -19,8 +19,6 @@ cfg_if::cfg_if! { use crate::backends::tasoller_v1 as con_impl; } else if #[cfg(feature = "tasoller_v2")] { use crate::backends::tasoller_v2 as con_impl; - } else if #[cfg(feature = "yubideck_v3")] { - use crate::backends::yubideck_v3 as con_impl; } else if #[cfg(feature = "my_controller")] { use crate::backends::my_controller as con_impl; } else { diff --git a/src/backends/mod.rs b/src/backends/mod.rs index 7a55c2d..9dd5b3f 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -1,7 +1,6 @@ pub mod dummy; pub mod tasoller_v1; pub mod tasoller_v2; -pub mod yubideck_v3; pub enum ReadType { Bulk, diff --git a/src/backends/yubideck_v3.rs b/src/backends/yubideck_v3.rs deleted file mode 100644 index 1bbfaa4..0000000 --- a/src/backends/yubideck_v3.rs +++ /dev/null @@ -1,139 +0,0 @@ -//! # YubiDeck v3 -//! USB device: 1973:2001 -//! -//! USB interface: 0 -//! -//! Note that carding in using the YubiDeck card reader will not -//! work until a compatible `aimeio` implementation is provided. -//! -//! ## Protocol information -//! -//! ### IN Interrupt (0x81) -//! - Content length: 45 bytes -//! - Byte 0: IR data (bit 0 for lowest IR to bit 6 for highest) -//! - Byte 1: -//! - Bit 0: Test -//! - Bit 1: Service -//! - Bit 2: Coin -//! - Bytes 2..34: Touch sensor pressure (starts from top left, -//! top to bottom then left to right) -//! - Byte 34: Card type: (0: no card, 1: MIFARE Classic, 2: FeliCa) -//! - Byte 35..45: Card IDm/access code -//! -//! ### OUT Interrupt (0x02) -//! - Content length: 61 bytes -//! - Byte 0: Packet type -//! - Type 0: -//! - Bytes 1..61: Slider LED (RGB, right -> left, 20 final pixels) -//! - Type 1: -//! - Bytes 1..34: Slider LED (RGB, right -> left, 11 first pixels) -//! - Bytes 34..37: Left air LED (RGB) -//! - Bytes 37..40: Right air LED (RGB) -//! - Bytes 40..43: Card reader LED (RGB) -//! - Bytes 43..61: Padding - -#[cfg(any(chuni, chusanapp))] -use anyhow::Result; -#[cfg(any(chuni, chusanapp))] -use rusb::{DeviceHandle, UsbContext}; - -use super::ReadType; -#[cfg(any(chuni, chusanapp))] -use crate::TIMEOUT; - -pub const DEVICE_VID: u16 = 0x1973; -pub const DEVICE_PID: u16 = 0x2001; -pub const READ_TYPE: ReadType = ReadType::Interrupt; -pub const READ_ENDPOINT: u8 = 0x81; -pub const INPUT_MEMORY_SIZE: usize = 45; -pub const OUTPUT_MEMORY_SIZE: usize = 122; - -#[cfg(any(chuni, amdaemon))] -#[inline(always)] -pub fn jvs_poll(input: &[u8]) -> (u8, u8) { - (input[1] & 3, input[0]) -} - -#[cfg(any(chuni, amdaemon))] -#[inline(always)] -pub fn is_coin_button_pressed(input: &[u8]) -> bool { - (input[1] & 4) != 0 -} - -#[cfg(any(chuni, chusanapp))] -#[inline(always)] -pub fn read_pressure_data(input: &[u8]) -> [u8; 32] { - let mut pressure = [0u8; 32]; - - for (i, p) in input.iter().skip(2).take(32).enumerate() { - pressure[if i % 2 == 0 { 30 - i } else { 32 - i }] = *p - } - - pressure -} - -#[cfg(any(chuni, chusanapp))] -#[inline(always)] -pub fn init_output_buffer(output: &mut [u8]) { - output[0] = 0; - output[61] = 1; -} - -#[cfg(any(chuni, chusanapp))] -#[inline(always)] -pub fn set_slider_leds( - device: &DeviceHandle, - output: &mut [u8], - rgb: &[u8], -) -> Result<()> { - for (buf_chunk, state_chunk) in output[1..61].chunks_mut(3).zip(rgb.chunks(3).take(20)) { - buf_chunk[0] = state_chunk[0]; - buf_chunk[1] = state_chunk[1]; - buf_chunk[2] = state_chunk[2]; - } - - for (buf_chunk, state_chunk) in output[62..95] - .chunks_mut(3) - .zip(rgb.chunks(3).skip(20).take(11)) - { - buf_chunk[0] = state_chunk[0]; - buf_chunk[1] = state_chunk[1]; - buf_chunk[2] = state_chunk[2]; - } - - device.write_interrupt(0x02, &output[0..61], TIMEOUT)?; - device.write_interrupt(0x02, &output[61..], TIMEOUT)?; - - Ok(()) -} - -#[cfg(any(chuni, chusanapp))] -#[inline(always)] -pub fn set_led_colors( - device: &DeviceHandle, - output: &mut [u8], - board: u8, - rgb: &[u8], -) -> Result<()> { - if board != 0 && board != 1 { - return Ok(()); - } - - match board { - 0 => { - output[95] = rgb[150]; - output[96] = rgb[151]; - output[97] = rgb[152]; - } - 1 => { - output[98] = rgb[180]; - output[99] = rgb[181]; - output[100] = rgb[182]; - } - _ => unreachable!(), - } - - device.write_interrupt(0x02, &output[61..], TIMEOUT)?; - - Ok(()) -} diff --git a/src/lib.rs b/src/lib.rs index 401ba19..83064ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,8 +34,6 @@ cfg_if::cfg_if! { use crate::backends::tasoller_v1 as con_impl; } else if #[cfg(feature = "tasoller_v2")] { use crate::backends::tasoller_v2 as con_impl; - } else if #[cfg(feature = "yubideck_v3")] { - use crate::backends::yubideck_v3 as con_impl; } else { use crate::backends::dummy as con_impl; }