diff --git a/buttplug/buttplug-device-config/buttplug-device-config.json b/buttplug/buttplug-device-config/buttplug-device-config.json index f87257276..a3d3ebcfe 100644 --- a/buttplug/buttplug-device-config/buttplug-device-config.json +++ b/buttplug/buttplug-device-config/buttplug-device-config.json @@ -7272,7 +7272,7 @@ } }, "defaults": { - "name": "Meeese Device", + "name": "Meese Device", "messages": { "ScalarCmd": [ { @@ -7297,13 +7297,13 @@ "identifier": [ "Meese-V389" ], - "name": "Meeese Tera" + "name": "Meese Tera" }, { "identifier": [ "Meese-cd" ], - "name": "Meeese Modo", + "name": "Meese Modo", "messages": { "ScalarCmd": [ { diff --git a/buttplug/buttplug-device-config/buttplug-device-config.yml b/buttplug/buttplug-device-config/buttplug-device-config.yml index e958099ca..3fa68606b 100644 --- a/buttplug/buttplug-device-config/buttplug-device-config.yml +++ b/buttplug/buttplug-device-config/buttplug-device-config.yml @@ -3572,7 +3572,7 @@ protocols: 0000ffe0-0000-1000-8000-00805f9b34fb: tx: 0000ffe1-0000-1000-8000-00805f9b34fb defaults: - name: Meeese Device + name: Meese Device messages: ScalarCmd: - StepRange: [0, 10] @@ -3582,10 +3582,10 @@ protocols: configurations: - identifier: - Meese-V389 - name: Meeese Tera + name: Meese Tera - identifier: - Meese-cd - name: Meeese Modo + name: Meese Modo messages: ScalarCmd: - StepRange: [0, 10] diff --git a/buttplug/src/server/device/protocol/motorbunny.rs b/buttplug/src/server/device/protocol/motorbunny.rs index 37b9d9c89..05e5c799a 100644 --- a/buttplug/src/server/device/protocol/motorbunny.rs +++ b/buttplug/src/server/device/protocol/motorbunny.rs @@ -54,4 +54,29 @@ impl ProtocolHandler for Motorbunny { ) .into()]) } + + fn handle_rotate_cmd( + &self, + commands: &[Option<(u32, bool)>], + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { + let rotate = commands[0].unwrap_or((0, false)); + let mut command_vec: Vec<u8>; + if rotate.0 == 0 { + command_vec = vec![0xa0, 0x00, 0x00, 0x00, 0x00, 0xec]; + } else { + command_vec = vec![0xfa]; + let mut rotate_command = vec![if rotate.1 { 0x2a } else { 0x29 }, rotate.0 as u8].repeat(7); + let crc = rotate_command + .iter() + .fold(0u8, |a, b| a.overflowing_add(*b).0); + command_vec.append(&mut rotate_command); + command_vec.append(&mut vec![crc, 0xec]); + } + Ok(vec![HardwareWriteCmd::new( + Endpoint::Tx, + command_vec, + false, + ) + .into()]) + } } diff --git a/buttplug/tests/test_device_protocols.rs b/buttplug/tests/test_device_protocols.rs index db7363e40..ea53f4459 100644 --- a/buttplug/tests/test_device_protocols.rs +++ b/buttplug/tests/test_device_protocols.rs @@ -98,6 +98,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase { #[test_case("test_joyhub_protocol.yaml" ; "JoyHub Protocol")] #[test_case("test_itoys_protocol.yaml" ; "iToys Protocol")] #[test_case("test_leten_protocol.yaml" ; "Leten Protocol")] +#[test_case("test_motorbunny_protocol.yaml" ; "Motorbunny Protocol")] #[tokio::test] async fn test_device_protocols_embedded_v3(test_file: &str) { //tracing_subscriber::fmt::init(); @@ -185,6 +186,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) { #[test_case("test_joyhub_protocol.yaml" ; "JoyHub Protocol")] #[test_case("test_itoys_protocol.yaml" ; "iToys Protocol")] #[test_case("test_leten_protocol.yaml" ; "Leten Protocol")] +#[test_case("test_motorbunny_protocol.yaml" ; "Motorbunny Protocol")] #[tokio::test] async fn test_device_protocols_json_v3(test_file: &str) { //tracing_subscriber::fmt::init(); @@ -250,6 +252,7 @@ async fn test_device_protocols_json_v3(test_file: &str) { #[test_case("test_foreo_protocol.yaml" ; "Foreo Protocol")] #[test_case("test_itoys_protocol.yaml" ; "iToys Protocol")] #[test_case("test_leten_protocol.yaml" ; "Leten Protocol")] +#[test_case("test_motorbunny_protocol.yaml" ; "Motorbunny Protocol")] #[tokio::test] async fn test_device_protocols_embedded_v2(test_file: &str) { util::device_test::client::client_v2::run_embedded_test_case(&load_test_case(test_file).await) @@ -314,6 +317,7 @@ async fn test_device_protocols_embedded_v2(test_file: &str) { #[test_case("test_foreo_protocol.yaml" ; "Foreo Protocol")] #[test_case("test_itoys_protocol.yaml" ; "iToys Protocol")] #[test_case("test_leten_protocol.yaml" ; "Leten Protocol")] +#[test_case("test_motorbunny_protocol.yaml" ; "Motorbunny Protocol")] #[tokio::test] async fn test_device_protocols_json_v2(test_file: &str) { util::device_test::client::client_v2::run_json_test_case(&load_test_case(test_file).await).await; diff --git a/buttplug/tests/util/device_test/device_test_case/test_motorbunny_protocol.yaml b/buttplug/tests/util/device_test/device_test_case/test_motorbunny_protocol.yaml new file mode 100644 index 000000000..6ad362931 --- /dev/null +++ b/buttplug/tests/util/device_test/device_test_case/test_motorbunny_protocol.yaml @@ -0,0 +1,74 @@ +devices: + - identifier: + name: "MB Controller" + expected_name: "Motorbunny Classic" +device_commands: + - !Messages + device_index: 0 + messages: + - !Vibrate + - Index: 0 + Speed: 0.5 + - !Commands + device_index: 0 + commands: + - !Write + endpoint: tx + data: [0xff, 0x80, 0x14, 0x80, 0x14, 0x80, 0x14, 0x80, 0x14, 0x80, 0x14, 0x80, 0x14, 0x80, 0x14, 0x0c, 0xec] + write_with_response: false + - !Messages + device_index: 0 + messages: + - !Vibrate + - Index: 0 + Speed: 0.75 + - !Commands + device_index: 0 + commands: + - !Write + endpoint: tx + data: [0xff, 0xC0, 0x14, 0xC0, 0x14, 0xC0, 0x14, 0xC0, 0x14, 0xC0, 0x14, 0xC0, 0x14, 0xC0, 0x14, 0xcc, 0xec] + write_with_response: false + - !Messages + device_index: 0 + messages: + - !Rotate + - Index: 0 + Speed: 0.5 + Clockwise: true + - !Commands + device_index: 0 + commands: + - !Write + endpoint: tx + data: [0xfa, 0x2a, 0x80, 0x2a, 0x80, 0x2a, 0x80, 0x2a, 0x80, 0x2a, 0x80, 0x2a, 0x80, 0x2a, 0x80, 0xa6, 0xec] + write_with_response: false + - !Messages + device_index: 0 + messages: + - !Rotate + - Index: 0 + Speed: 0.75 + Clockwise: false + - !Commands + device_index: 0 + commands: + - !Write + endpoint: tx + data: [0xfa, 0x29, 0xC0, 0x29, 0xC0, 0x29, 0xC0, 0x29, 0xC0, 0x29, 0xC0, 0x29, 0xC0, 0x29, 0xC0, 0x5F, 0xec] + write_with_response: false + - !Messages + device_index: 0 + messages: + - !Stop + - !Commands + device_index: 0 + commands: + - !Write + endpoint: tx + data: [ 0xf0, 0x00, 0x00, 0x00, 0x00, 0xec ] + write_with_response: false + - !Write + endpoint: tx + data: [ 0xa0, 0x00, 0x00, 0x00, 0x00, 0xec ] + write_with_response: false