Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/crates/buttplug_server/src/device/protocol_impl/wevibe_chorus.rs b/crates/buttplug_server/src/device/protocol_impl/wevibe_chorus.rs
- index 35f9ed0f..ee05d8c4 100644
- --- a/crates/buttplug_server/src/device/protocol_impl/wevibe_chorus.rs
- +++ b/crates/buttplug_server/src/device/protocol_impl/wevibe_chorus.rs
- @@ -55,30 +55,26 @@ impl ProtocolInitializer for WeVibeChorusInitializer {
- pub struct WeVibeChorus {
- num_vibrators: u8,
- - speeds: [AtomicU8; 2],
- + speeds: [AtomicU8; 3],
- }
- impl WeVibeChorus {
- fn new(num_vibrators: u8) -> Self {
- Self {
- num_vibrators,
- - speeds: [AtomicU8::default(), AtomicU8::default()],
- + speeds: [
- + AtomicU8::default(),
- + AtomicU8::default(),
- + AtomicU8::default(),
- + ],
- }
- }
- -}
- -impl ProtocolHandler for WeVibeChorus {
- - fn handle_output_vibrate_cmd(
- - &self,
- - feature_index: u32,
- - _feature_id: uuid::Uuid,
- - speed: u32,
- - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
- - self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed);
- + fn two_motor_packet(&self) -> Vec<u8> {
- let max_vibrators = if self.num_vibrators > 1 { 1 } else { 0 };
- let r_speed_int = self.speeds[0].load(Ordering::Relaxed);
- let r_speed_ext = self.speeds[max_vibrators].load(Ordering::Relaxed);
- - let data = if r_speed_int == 0 && r_speed_ext == 0 {
- + if r_speed_int == 0 && r_speed_ext == 0 {
- vec![0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
- } else {
- // Note the motor order is flipped for the Chorus
- @@ -94,6 +90,54 @@ impl ProtocolHandler for WeVibeChorus {
- 0x00,
- 0x00,
- ]
- + }
- + }
- +
- + // The Chorus Pro uses the We-Connect app's 0xe0 command: three speeds (external tip,
- + // internal, external base), then one pattern byte per motor (0x03 steady, 0xaa off). Unlike
- + // the 0x0f command, this doesn't overwrite the toy's stored stand-alone settings, which 0x0f
- + // can leave with motors disabled.
- + fn three_motor_packet(&self) -> Vec<u8> {
- + // Features keep the two-motor Chorus order (internal, external), with the external base
- + // added as feature 2, so feature 0 goes in the middle slot.
- + let speeds: Vec<u8> = [1, 0, 2]
- + .iter()
- + .map(|&i| self.speeds[i].load(Ordering::Relaxed))
- + .collect();
- + let pattern = |speed: u8| if speed == 0 { 0xaa } else { 0x03 };
- + vec![
- + 0xe0,
- + speeds[0],
- + speeds[1],
- + speeds[2],
- + 0x00,
- + 0x00,
- + 0x00,
- + 0x00,
- + 0x00,
- + pattern(speeds[0]),
- + pattern(speeds[1]),
- + pattern(speeds[2]),
- + 0x00,
- + 0x00,
- + 0x00,
- + 0x00,
- + ]
- + }
- +}
- +
- +impl ProtocolHandler for WeVibeChorus {
- + fn handle_output_vibrate_cmd(
- + &self,
- + feature_index: u32,
- + _feature_id: uuid::Uuid,
- + speed: u32,
- + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
- + self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed);
- + let data = if self.num_vibrators > 2 {
- + self.three_motor_packet()
- + } else {
- + self.two_motor_packet()
- };
- Ok(vec![
- HardwareWriteCmd::new(&[WEVIBE_CHORUS_PROTOCOL_UUID], Endpoint::Tx, data, true).into(),
- diff --git a/crates/buttplug_server_device_config/device-config/protocols/wevibe-chorus.yml b/crates/buttplug_server_device_config/device-config/protocols/wevibe-chorus.yml
- index f60e59c2..09565789 100644
- --- a/crates/buttplug_server_device_config/device-config/protocols/wevibe-chorus.yml
- +++ b/crates/buttplug_server_device_config/device-config/protocols/wevibe-chorus.yml
- @@ -18,6 +18,35 @@ defaults:
- index: 1
- id: 5228aefe-bc48-445c-8129-48c3cebf6729
- configurations:
- +- identifier:
- + - Chorus Pro
- + name: WeVibe Chorus Pro
- + features:
- + - description: Internal Vibrator
- + id: 6e51328e-0384-4e18-b1c9-004512670487
- + output:
- + vibrate:
- + value:
- + - 0
- + - 30
- + index: 0
- + - description: External Tip Vibrator
- + id: 68285a0d-1d85-4e45-a4f8-1ad969291d0a
- + output:
- + vibrate:
- + value:
- + - 0
- + - 30
- + index: 1
- + - description: External Base Vibrator
- + id: 81b86559-0495-4931-8dae-a10100678f76
- + output:
- + vibrate:
- + value:
- + - 0
- + - 30
- + index: 2
- + id: 0efb42ee-2c70-4fb6-8636-4b4f452f7b93
- - identifier:
- - Sync 2
- name: WeVibe Sync 2
- @@ -65,6 +94,7 @@ communication:
- - btle:
- names:
- - Chorus
- + - Chorus Pro
- - skeena
- - Sync 2
- - Sync O
- diff --git a/crates/buttplug_tests/tests/test_device_protocols.rs b/crates/buttplug_tests/tests/test_device_protocols.rs
- index 7c5043eb..e078ee48 100644
- --- a/crates/buttplug_tests/tests/test_device_protocols.rs
- +++ b/crates/buttplug_tests/tests/test_device_protocols.rs
- @@ -260,6 +260,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -396,6 +397,7 @@ async fn test_device_protocols_embedded_v4(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -529,6 +531,7 @@ async fn test_device_protocols_json_v4(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -665,6 +668,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -789,6 +793,7 @@ async fn test_device_protocols_json_v3(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -914,6 +919,7 @@ async fn test_device_protocols_embedded_v2(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -1037,6 +1043,7 @@ async fn test_device_protocols_json_v2(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -1160,6 +1167,7 @@ async fn test_device_protocols_embedded_v1(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- #[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- #[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- #[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -1236,6 +1244,7 @@ async fn test_device_protocols_json_v1(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- //#[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- //#[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +//#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- //#[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- @@ -1308,6 +1317,7 @@ async fn test_device_protocols_embedded_v0(test_file: &str) {
- #[test_case("test_wetoy_protocol.yaml" ; "WeToy Protocol")]
- //#[test_case("test_wevibe_4plus.yaml" ; "WeVibe Protocol (Legacy) - 4 Plus")]
- //#[test_case("test_wevibe_chorus.yaml" ; "WeVibe Protocol (Chorus) - Chorus")]
- +//#[test_case("test_wevibe_chorus_pro.yaml" ; "WeVibe Protocol (Chorus) - Chorus Pro")]
- #[test_case("test_wevibe_moxie.yaml" ; "WeVibe Protocol (8bit) - Moxie")]
- #[test_case("test_wevibe_pivot.yaml" ; "WeVibe Protocol (Legacy) - Pivot")]
- //#[test_case("test_wevibe_vector.yaml" ; "WeVibe Protocol (8bit) - Vector")]
- diff --git a/crates/buttplug_tests/tests/util/device_test/device_test_case/test_wevibe_chorus_pro.yaml b/crates/buttplug_tests/tests/util/device_test/device_test_case/test_wevibe_chorus_pro.yaml
- new file mode 100644
- index 00000000..59584444
- --- /dev/null
- +++ b/crates/buttplug_tests/tests/util/device_test/device_test_case/test_wevibe_chorus_pro.yaml
- @@ -0,0 +1,50 @@
- +devices:
- + - identifier:
- + name: "Chorus Pro"
- + expected_name: "WeVibe Chorus Pro"
- +device_commands:
- + - !Messages
- + device_index: 0
- + messages:
- + - !Vibrate
- + - Index: 0
- + Speed: 0.5
- + - Index: 1
- + Speed: 0.25
- + - Index: 2
- + Speed: 1.0
- + - !Commands
- + device_index: 0
- + commands:
- + - !Write
- + endpoint: tx
- + data: [0xe0, 0x08, 0x0F, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00]
- + write_with_response: true
- + - !Messages
- + device_index: 0
- + messages:
- + - !Vibrate
- + - Index: 0
- + Speed: 0
- + - Index: 1
- + Speed: 0.5
- + - Index: 2
- + Speed: 0
- + - !Commands
- + device_index: 0
- + commands:
- + - !Write
- + endpoint: tx
- + data: [0xe0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00]
- + write_with_response: true
- + - !Messages
- + device_index: 0
- + messages:
- + - !Stop
- + - !Commands
- + device_index: 0
- + commands:
- + - !Write
- + endpoint: tx
- + data: [0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00]
- + write_with_response: true
Advertisement