Skip to content

Commit e973212

Browse files
blackspherefollowerqdot
authored andcommitted
feat: Adding support for Bananasome Rocket X7
1 parent 037c5f5 commit e973212

File tree

6 files changed

+220
-1
lines changed

6 files changed

+220
-1
lines changed

buttplug/buttplug-device-config/build-config/buttplug-device-config-v3.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18199,6 +18199,63 @@
1819918199
}
1820018200
}
1820118201
]
18202+
},
18203+
"bananasome": {
18204+
"defaults": {
18205+
"name": "Bananasome Rocket X7",
18206+
"features": [
18207+
{
18208+
"feature-type": "Oscillate",
18209+
"actuator": {
18210+
"step-range": [
18211+
0,
18212+
255
18213+
],
18214+
"messages": [
18215+
"ScalarCmd"
18216+
]
18217+
}
18218+
},
18219+
{
18220+
"feature-type": "Vibrate",
18221+
"actuator": {
18222+
"step-range": [
18223+
0,
18224+
255
18225+
],
18226+
"messages": [
18227+
"ScalarCmd"
18228+
]
18229+
}
18230+
},
18231+
{
18232+
"feature-type": "Vibrate",
18233+
"actuator": {
18234+
"step-range": [
18235+
0,
18236+
255
18237+
],
18238+
"messages": [
18239+
"ScalarCmd"
18240+
]
18241+
}
18242+
}
18243+
]
18244+
},
18245+
"communication": [
18246+
{
18247+
"btle": {
18248+
"names": [
18249+
"火箭X7"
18250+
],
18251+
"services": {
18252+
"0000ae00-0000-1000-8000-00805f9b34fb": {
18253+
"tx": "0000ae01-0000-1000-8000-00805f9b34fb"
18254+
}
18255+
}
18256+
}
18257+
}
18258+
]
1820218259
}
1820318260
}
1820418261
}

buttplug/buttplug-device-config/device-config-v3/buttplug-device-config-v3.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10435,4 +10435,36 @@ protocols:
1043510435
- LOOB
1043610436
services:
1043710437
b75c49d2-04a3-4071-a0b5-35853eb08307:
10438-
tx: ba5c49d2-04a3-4071-a0b5-35853eb08307
10438+
tx: ba5c49d2-04a3-4071-a0b5-35853eb08307
10439+
bananasome:
10440+
defaults:
10441+
name: Bananasome Rocket X7
10442+
features:
10443+
- feature-type: Oscillate
10444+
actuator:
10445+
step-range:
10446+
- 0
10447+
- 255
10448+
messages:
10449+
- ScalarCmd
10450+
- feature-type: Vibrate
10451+
actuator:
10452+
step-range:
10453+
- 0
10454+
- 255
10455+
messages:
10456+
- ScalarCmd
10457+
- feature-type: Vibrate
10458+
actuator:
10459+
step-range:
10460+
- 0
10461+
- 255
10462+
messages:
10463+
- ScalarCmd
10464+
communication:
10465+
- btle:
10466+
names:
10467+
- 火箭X7
10468+
services:
10469+
0000ae00-0000-1000-8000-00805f9b34fb:
10470+
tx: 0000ae01-0000-1000-8000-00805f9b34fb
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Buttplug Rust Source Code File - See https://buttplug.io for more info.
2+
//
3+
// Copyright 2016-2025 Nonpolynomial Labs LLC. All rights reserved.
4+
//
5+
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
6+
// for full license information.
7+
8+
use crate::{
9+
core::{
10+
errors::ButtplugDeviceError,
11+
message::{
12+
ActuatorType,
13+
ActuatorType::{Oscillate, Vibrate},
14+
Endpoint,
15+
},
16+
},
17+
server::device::{
18+
hardware::{HardwareCommand, HardwareWriteCmd},
19+
protocol::{generic_protocol_setup, ProtocolHandler},
20+
},
21+
};
22+
23+
generic_protocol_setup!(Bananasome, "bananasome");
24+
25+
#[derive(Default)]
26+
pub struct Bananasome {}
27+
28+
impl ProtocolHandler for Bananasome {
29+
fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
30+
super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategy
31+
}
32+
33+
fn needs_full_command_set(&self) -> bool {
34+
true
35+
}
36+
fn handle_scalar_cmd(
37+
&self,
38+
commands: &[Option<(ActuatorType, u32)>],
39+
) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
40+
Ok(vec![HardwareWriteCmd::new(
41+
Endpoint::Tx,
42+
vec![
43+
0xa0,
44+
0x03,
45+
commands[0].unwrap_or((Oscillate, 0)).1 as u8,
46+
if commands.len() > 1 {
47+
commands[1].unwrap_or((Vibrate, 0)).1
48+
} else {
49+
0
50+
} as u8,
51+
if commands.len() > 2 {
52+
commands[2].unwrap_or((Vibrate, 0)).1
53+
} else {
54+
0
55+
} as u8,
56+
],
57+
false,
58+
)
59+
.into()])
60+
}
61+
}

buttplug/src/server/device/protocol/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub mod adrienlastic;
1818
pub mod amorelie_joy;
1919
pub mod aneros;
2020
pub mod ankni;
21+
pub mod bananasome;
2122
pub mod buttplug_passthru;
2223
pub mod cachito;
2324
pub mod cowgirl;
@@ -234,6 +235,10 @@ pub fn get_default_protocol_map() -> HashMap<String, Arc<dyn ProtocolIdentifierF
234235
amorelie_joy::setup::AmorelieJoyIdentifierFactory::default(),
235236
);
236237
add_to_protocol_map(&mut map, aneros::setup::AnerosIdentifierFactory::default());
238+
add_to_protocol_map(
239+
&mut map,
240+
bananasome::setup::BananasomeIdentifierFactory::default(),
241+
);
237242
add_to_protocol_map(
238243
&mut map,
239244
buttplug_passthru::setup::ButtplugPassthruIdentifierFactory::default(),

buttplug/tests/test_device_protocols.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
123123
#[test_case("test_fleshy_thrust_protocol.yaml" ; "Fleshy Thrust Sync Protocol")]
124124
#[test_case("test_nexus_revo.yaml" ; "Nexus Revo Protocol")]
125125
#[test_case("test_luvmazer_protocol.yaml" ; "Luvmazer Protocol")]
126+
#[test_case("test_bananasome_protocol.yaml" ; "Bananasome Protocol")]
126127
#[tokio::test]
127128
async fn test_device_protocols_embedded_v3(test_file: &str) {
128129
//tracing_subscriber::fmt::init();
@@ -236,6 +237,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) {
236237
#[test_case("test_fleshy_thrust_protocol.yaml" ; "Fleshy Thrust Sync Protocol")]
237238
#[test_case("test_nexus_revo.yaml" ; "Nexus Revo Protocol")]
238239
#[test_case("test_luvmazer_protocol.yaml" ; "Luvmazer Protocol")]
240+
#[test_case("test_bananasome_protocol.yaml" ; "Bananasome Protocol")]
239241
#[tokio::test]
240242
async fn test_device_protocols_json_v3(test_file: &str) {
241243
//tracing_subscriber::fmt::init();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
devices:
2+
- identifier:
3+
name: "火箭X7"
4+
expected_name: "Bananasome Rocket X7"
5+
device_commands:
6+
- !Messages
7+
device_index: 0
8+
messages:
9+
- !Vibrate
10+
- Index: 0
11+
Speed: 0.5
12+
- !Commands
13+
device_index: 0
14+
commands:
15+
- !Write
16+
endpoint: tx
17+
data: [0xa0, 0x03, 0x00, 0x80, 0x00]
18+
write_with_response: false
19+
- !Messages
20+
device_index: 0
21+
messages:
22+
- !Vibrate
23+
- Index: 1
24+
Speed: 0.5
25+
- !Commands
26+
device_index: 0
27+
commands:
28+
- !Write
29+
endpoint: tx
30+
data: [0xa0, 0x03, 0x00, 0x80, 0x80]
31+
write_with_response: false
32+
- !Messages
33+
device_index: 0
34+
messages:
35+
- !Scalar
36+
- Index: 0
37+
Scalar: 0.75
38+
ActuatorType: Oscillate
39+
- Index: 1
40+
Scalar: 0.75
41+
ActuatorType: Vibrate
42+
- Index: 2
43+
Scalar: 0.25
44+
ActuatorType: Vibrate
45+
- !Commands
46+
device_index: 0
47+
commands:
48+
- !Write
49+
endpoint: tx
50+
data: [0xa0, 0x03, 0xc0, 0xc0, 0x40]
51+
write_with_response: false
52+
- !Messages
53+
device_index: 0
54+
messages:
55+
- !Stop
56+
- !Commands
57+
device_index: 0
58+
commands:
59+
- !Write
60+
endpoint: tx
61+
data: [0xa0, 0x03, 0x00, 0x00, 0x00]
62+
write_with_response: false

0 commit comments

Comments
 (0)