Skip to content

Commit

Permalink
feat: Adding support for Fleshy Thrust Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
blackspherefollower committed Dec 23, 2024
1 parent fa5b027 commit 0edc3f1
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17424,6 +17424,39 @@
}
}
]
},
"fleshy-thrust": {
"defaults": {
"name": "Fleshy Thrust Sync",
"features": [
{
"feature-type": "Position",
"actuator": {
"step-range": [
0,
180
],
"messages": [
"LinearCmd"
]
}
}
]
},
"communication": [
{
"btle": {
"names": [
"BT05"
],
"services": {
"0000ffe0-0000-1000-8000-00805f9b34fb": {
"tx": "0000ffe1-0000-1000-8000-00805f9b34fb"
}
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9980,3 +9980,21 @@ protocols:
services:
31bb1111-33e3-4f3c-a7fb-104288e7cb77:
tx: 31bb2222-33e3-4f3c-a7fb-104288e7cb77
fleshy-thrust:
defaults:
name: Fleshy Thrust Sync
features:
- feature-type: Position
actuator:
step-range:
- 0
- 180
messages:
- LinearCmd
communication:
- btle:
names:
- BT05
services:
0000ffe0-0000-1000-8000-00805f9b34fb:
tx: 0000ffe1-0000-1000-8000-00805f9b34fb
42 changes: 42 additions & 0 deletions buttplug/src/server/device/protocol/fleshy_thrust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Buttplug Rust Source Code File - See https://buttplug.io for more info.
//
// Copyright 2016-2024 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!(FleshyThrust, "fleshy-thrust");

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

impl ProtocolHandler for FleshyThrust {
fn handle_linear_cmd(
&self,
message: crate::core::message::LinearCmdV4,
) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
let current_cmd = message
.vectors()
.first()
.ok_or(ButtplugDeviceError::DeviceFeatureCountMismatch(1, 0))?;

Ok(vec![HardwareWriteCmd::new(
Endpoint::Tx,
vec![
(current_cmd.position() * 180f64).abs() as u8,
((current_cmd.duration() & 0xff00) >> 8) as u8,
(current_cmd.duration() & 0xff) 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 @@ -25,6 +25,7 @@ pub mod cowgirl_cone;
pub mod cupido;
pub mod deepsire;
pub mod feelingso;
pub mod fleshy_thrust;
pub mod foreo;
pub mod fox;
pub mod fredorch;
Expand Down Expand Up @@ -272,6 +273,10 @@ pub fn get_default_protocol_map() -> HashMap<String, Arc<dyn ProtocolIdentifierF
&mut map,
feelingso::setup::FeelingSoIdentifierFactory::default(),
);
add_to_protocol_map(
&mut map,
fleshy_thrust::setup::FleshyThrustIdentifierFactory::default(),
);
add_to_protocol_map(&mut map, foreo::setup::ForeoIdentifierFactory::default());
add_to_protocol_map(&mut map, fox::setup::FoxIdentifierFactory::default());
add_to_protocol_map(
Expand Down
4 changes: 4 additions & 0 deletions buttplug/tests/test_device_protocols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
#[test_case("test_tcode_linear_and_vibrate.yaml" ; "TCode (Linear + Vibrate)")]
#[test_case("test_serveu_protocol.yaml" ; "ServeU")]
#[test_case("test_kiiroo_prowand.yaml" ; "Kiiroo ProWand Protocol")]
#[test_case("test_fleshy_thrust_protocol.yaml" ; "Fleshy Thrust Sync Protocol")]
#[tokio::test]
async fn test_device_protocols_embedded_v3(test_file: &str) {
//tracing_subscriber::fmt::init();
Expand Down Expand Up @@ -226,6 +227,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) {
#[test_case("test_tcode_linear_and_vibrate.yaml" ; "TCode (Linear + Vibrate)")]
#[test_case("test_serveu_protocol.yaml" ; "ServeU")]
#[test_case("test_kiiroo_prowand.yaml" ; "Kiiroo ProWand Protocol")]
#[test_case("test_fleshy_thrust_protocol.yaml" ; "Fleshy Thrust Sync Protocol")]
#[tokio::test]
async fn test_device_protocols_json_v3(test_file: &str) {
//tracing_subscriber::fmt::init();
Expand Down Expand Up @@ -304,6 +306,7 @@ async fn test_device_protocols_json_v3(test_file: &str) {
#[test_case("test_tcode_linear_and_vibrate.yaml" ; "TCode (Linear + Vibrate)")]
#[test_case("test_serveu_protocol.yaml" ; "ServeU")]
#[test_case("test_kiiroo_prowand.yaml" ; "Kiiroo ProWand Protocol")]
#[test_case("test_fleshy_thrust_protocol.yaml" ; "Fleshy Thrust Sync 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)
Expand Down Expand Up @@ -381,6 +384,7 @@ async fn test_device_protocols_embedded_v2(test_file: &str) {
#[test_case("test_tcode_linear_and_vibrate.yaml" ; "TCode (Linear + Vibrate)")]
#[test_case("test_serveu_protocol.yaml" ; "ServeU")]
#[test_case("test_kiiroo_prowand.yaml" ; "Kiiroo ProWand Protocol")]
#[test_case("test_fleshy_thrust_protocol.yaml" ; "Fleshy Thrust Sync 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
devices:
- identifier:
name: "BT05"
expected_name: "Fleshy Thrust Sync"
device_commands:
- !Messages
device_index: 0
messages:
- !Linear
- Index: 0
Position: 0.30
Duration: 1000
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [54, 3, 232]
write_with_response: false

0 comments on commit 0edc3f1

Please sign in to comment.