Skip to content

Commit

Permalink
feat: Adding support for Mizz Zee V2 models
Browse files Browse the repository at this point in the history
Thanks to @Spazzwanjunk at their friend for doing the hard work on this one:
buttplugio/stpihkal#136 (comment)
  • Loading branch information
blackspherefollower committed Sep 12, 2022
1 parent c834542 commit 52e5adb
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 51 deletions.
26 changes: 26 additions & 0 deletions buttplug/buttplug-device-config/buttplug-device-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3767,6 +3767,32 @@
}
}
},
"mizzzee-v2": {
"btle": {
"names": [
"XHT"
],
"services": {
"0000eea0-0000-1000-8000-00805f9b34fb": {
"tx": "0000ee01-0000-1000-8000-00805f9b34fb"
}
}
},
"defaults": {
"name": "Mizz Zee Device",
"messages": {
"ScalarCmd": [
{
"StepRange": [
0,
68
],
"ActuatorType": "Vibrate"
}
]
}
}
},
"htk_bm": {
"btle": {
"names": [
Expand Down
13 changes: 13 additions & 0 deletions buttplug/buttplug-device-config/buttplug-device-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,19 @@ protocols:
ScalarCmd:
- StepRange: [0, 68]
ActuatorType: Vibrate
mizzzee-v2:
btle:
names:
- XHT
services:
0000eea0-0000-1000-8000-00805f9b34fb:
tx: 0000ee01-0000-1000-8000-00805f9b34fb
defaults:
name: Mizz Zee Device
messages:
ScalarCmd:
- StepRange: [0, 68]
ActuatorType: Vibrate
htk_bm:
btle:
names:
Expand Down
51 changes: 0 additions & 51 deletions buttplug/src/server/device/protocol/mizzzee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,54 +39,3 @@ impl ProtocolHandler for MizzZee {
.into()])
}
}
/*
#[cfg(all(test, feature = "server"))]
mod test {
use crate::{
core::messages::{Endpoint, StopDeviceCmd, VibrateCmd, VibrateSubcommand},
server::device::{
hardware::communication::test::{check_test_recv_value, new_bluetoothle_test_device},
hardware::{HardwareCommand, HardwareWriteCmd},
},
util::async_manager,
};
#[test]
pub fn test_mizz_zee_protocol() {
async_manager::block_on(async move {
let (device, test_device) = new_bluetoothle_test_device("NFY008")
.await
.expect("Test, assuming infallible");
device
.parse_message(VibrateCmd::new(0, vec![VibrateSubcommand::new(0, 0.5)]).into())
.await
.expect("Test, assuming infallible");
let command_receiver = test_device
.endpoint_receiver(&Endpoint::Tx)
.expect("Test, assuming infallible");
check_test_recv_value(
&command_receiver,
HardwareCommand::Write(HardwareWriteCmd::new(
Endpoint::Tx,
vec![0x69, 0x96, 0x03, 0x01, 0x01, 34],
false,
)),
);
// Test to make sure we handle packet IDs across protocol clones correctly.
device
.parse_message(StopDeviceCmd::new(0).into())
.await
.expect("Test, assuming infallible");
check_test_recv_value(
&command_receiver,
HardwareCommand::Write(HardwareWriteCmd::new(
Endpoint::Tx,
vec![0x69, 0x96, 0x03, 0x01, 0x00, 0x00],
false,
)),
);
});
}
}
*/
43 changes: 43 additions & 0 deletions buttplug/src/server/device/protocol/mizzzee_v2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Buttplug Rust Source Code File - See https://buttplug.io for more info.
//
// Copyright 2016-2022 Nonpolynomial Labs LLC. All rights reserved.
//
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
hardware::{HardwareCommand, HardwareWriteCmd},
protocol::{generic_protocol_setup, ProtocolHandler},
},
};

generic_protocol_setup!(MizzZeeV2, "mizzzee-v2");

#[derive(Default)]
pub struct MizzZeeV2 {}

impl ProtocolHandler for MizzZeeV2 {
fn handle_scalar_vibrate_cmd(
&self,
_index: u32,
scalar: u32,
) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
Ok(vec![HardwareWriteCmd::new(
Endpoint::Tx,
vec![
0x69,
0x96,
0x04,
0x02,
scalar as u8,
0x2c,
scalar as u8,
],
false,
)
.into()])
}
}

5 changes: 5 additions & 0 deletions buttplug/src/server/device/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub mod mannuo;
pub mod maxpro;
pub mod meese;
pub mod mizzzee;
pub mod mizzzee_v2;
pub mod motorbunny;
pub mod mysteryvibe;
pub mod nobra;
Expand Down Expand Up @@ -225,6 +226,10 @@ pub fn get_default_protocol_map() -> HashMap<String, Arc<dyn ProtocolIdentifierF
&mut map,
mizzzee::setup::MizzZeeIdentifierFactory::default(),
);
add_to_protocol_map(
&mut map,
mizzzee_v2::setup::MizzZeeV2IdentifierFactory::default(),
);
add_to_protocol_map(
&mut map,
motorbunny::setup::MotorbunnyIdentifierFactory::default(),
Expand Down
38 changes: 38 additions & 0 deletions buttplug/tests/device_test_case/test_mizzzee_protocol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
devices:
- identifier:
name: "NFY008"
address: null
identifier: "Default"
expected_name: "Mizz Zee Device"
device_commands:
# Commands
- !Messages
device_index: 0
messages:
- !ScalarCmd
Id: 1
DeviceIndex: 0
Scalars:
- Index: 0
Scalar: 0.5
ActuatorType: Vibrate
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x69, 0x96, 0x03, 0x01, 0x01, 0x22]
write_with_response: false
- !Messages
device_index: 0
messages:
- !StopDeviceCmd
Id: 1
DeviceIndex: 0
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x69, 0x96, 0x03, 0x01, 0x00, 0x00]
write_with_response: false
38 changes: 38 additions & 0 deletions buttplug/tests/device_test_case/test_mizzzee_v2_protocol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
devices:
- identifier:
name: "XHT"
address: null
identifier: "Default"
expected_name: "Mizz Zee Device"
device_commands:
# Commands
- !Messages
device_index: 0
messages:
- !ScalarCmd
Id: 1
DeviceIndex: 0
Scalars:
- Index: 0
Scalar: 0.5
ActuatorType: Vibrate
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x69, 0x96, 0x04, 0x02, 0x22, 0x2c, 0x22 ]
write_with_response: false
- !Messages
device_index: 0
messages:
- !StopDeviceCmd
Id: 1
DeviceIndex: 0
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x69, 0x96, 0x04, 0x02, 0x00, 0x2c, 0x00 ]
write_with_response: false
8 changes: 8 additions & 0 deletions buttplug/tests/test_device_protocols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
#[test_case("test_satisfyer_dual_vibrator.yaml" ; "Satisfyer Protocol - Dual Vibrator")]
#[test_case("test_mysteryvibe.yaml" ; "Mysteryvibe Protocol")]
#[test_case("test_meese_protocol.yaml" ; "Meese Protocol")]
#[test_case("test_mizzzee_protocol.yaml" ; "Mizz Zee Protocol")]
#[test_case("test_mizzzee_v2_protocol.yaml" ; "Mizz Zee v2 Protocol")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO TW")]
fn test_device_protocols_embedded_v3(test_file: &str) {
Expand Down Expand Up @@ -62,6 +64,8 @@ fn test_device_protocols_embedded_v3(test_file: &str) {
#[test_case("test_satisfyer_dual_vibrator.yaml" ; "Satisfyer Protocol - Dual Vibrator")]
#[test_case("test_mysteryvibe.yaml" ; "Mysteryvibe Protocol")]
#[test_case("test_meese_protocol.yaml" ; "Meese Protocol")]
#[test_case("test_mizzzee_protocol.yaml" ; "Mizz Zee Protocol")]
#[test_case("test_mizzzee_v2_protocol.yaml" ; "Mizz Zee v2 Protocol")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO TW")]
fn test_device_protocols_json_v3(test_file: &str) {
Expand All @@ -84,6 +88,8 @@ fn test_device_protocols_json_v3(test_file: &str) {
#[test_case("test_satisfyer_dual_vibrator.yaml" ; "Satisfyer Protocol - Dual Vibrator")]
#[test_case("test_mysteryvibe.yaml" ; "Mysteryvibe Protocol")]
#[test_case("test_meese_protocol.yaml" ; "Meese Protocol")]
#[test_case("test_mizzzee_protocol.yaml" ; "Mizz Zee Protocol")]
#[test_case("test_mizzzee_v2_protocol.yaml" ; "Mizz Zee v2 Protocol")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO TW")]
fn test_device_protocols_embedded_v2(test_file: &str) {
Expand All @@ -105,6 +111,8 @@ fn test_device_protocols_embedded_v2(test_file: &str) {
#[test_case("test_satisfyer_dual_vibrator.yaml" ; "Satisfyer Protocol - Dual Vibrator")]
#[test_case("test_mysteryvibe.yaml" ; "Mysteryvibe Protocol")]
#[test_case("test_meese_protocol.yaml" ; "Meese Protocol")]
#[test_case("test_mizzzee_protocol.yaml" ; "Mizz Zee Protocol")]
#[test_case("test_mizzzee_v2_protocol.yaml" ; "Mizz Zee v2 Protocol")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO")]
#[test_case("test_vorze_ufo.yaml" ; "Vorze Protocol - UFO TW")]
fn test_device_protocols_json_v2(test_file: &str) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
devices:
- identifier:
name: "NFY008"
expected_name: "Mizz Zee Device"
device_commands:
# Commands
- !Messages
device_index: 0
messages:
- !Vibrate
- Index: 0
Speed: 0.5
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [105, 150, 3, 1, 1, 34]
write_with_response: false
- !Messages
device_index: 0
messages:
- !Stop
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [105, 150, 3, 1, 0, 0]
write_with_response: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
devices:
- identifier:
name: "XHT"
expected_name: "Mizz Zee Device"
device_commands:
# Commands
- !Messages
device_index: 0
messages:
- !Vibrate
- Index: 0
Speed: 0.5
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [105, 150, 4, 2, 34, 44, 34]
write_with_response: false
- !Messages
device_index: 0
messages:
- !Stop
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [105, 150, 4, 2, 0, 44, 0]
write_with_response: false

0 comments on commit 52e5adb

Please sign in to comment.