forked from buttplugio/buttplug
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding support for Fleshy Thrust Sync
- Loading branch information
1 parent
fa5b027
commit 0edc3f1
Showing
6 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
buttplug/tests/util/device_test/device_test_case/test_fleshy_thrust_protocol.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |