Skip to content

Commit

Permalink
feat: Adding support for Foreo Luna Fofo
Browse files Browse the repository at this point in the history
  • Loading branch information
blackspherefollower authored and qdot committed Oct 4, 2023
1 parent 929e0b8 commit 49aa2e1
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 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 @@ -7513,6 +7513,32 @@
]
}
}
},
"foreo": {
"btle": {
"names": [
"FOFO"
],
"services": {
"0000fff0-0000-1000-8000-00805f9b34fb": {
"tx": "0000fff1-0000-1000-8000-00805f9b34fb"
}
}
},
"defaults": {
"name": "Foreo Luna Fofo",
"messages": {
"ScalarCmd": [
{
"StepRange": [
0,
10
],
"ActuatorType": "Vibrate"
}
]
}
}
}
}
}
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 @@ -3716,3 +3716,16 @@ protocols:
ScalarCmd:
- StepRange: [0, 1000]
ActuatorType: Vibrate
foreo:
btle:
names:
- FOFO
services:
0000fff0-0000-1000-8000-00805f9b34fb:
tx: 0000fff1-0000-1000-8000-00805f9b34fb
defaults:
name: Foreo Luna Fofo
messages:
ScalarCmd:
- StepRange: [0, 10]
ActuatorType: Vibrate
34 changes: 34 additions & 0 deletions buttplug/src/server/device/protocol/foreo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Buttplug Rust Source Code File - See https://buttplug.io for more info.
//
// Copyright 2016-2023 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!(Foreo, "foreo");

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

impl ProtocolHandler for Foreo {
fn handle_scalar_vibrate_cmd(
&self,
_: u32,
scalar: u32,
) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
Ok(vec![HardwareWriteCmd::new(
Endpoint::Tx,
vec![0x01, 0x01, scalar as u8],
false,
)
.into()])
}
}
2 changes: 2 additions & 0 deletions buttplug/src/server/device/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod ankni;
pub mod buttplug_passthru;
pub mod cachito;
pub mod cowgirl;
pub mod foreo;
pub mod fox;
pub mod fredorch;
pub mod fredorch_rotary;
Expand Down Expand Up @@ -179,6 +180,7 @@ pub fn get_default_protocol_map() -> HashMap<String, Arc<dyn ProtocolIdentifierF
);

add_to_protocol_map(&mut map, ankni::setup::AnkniIdentifierFactory::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(
&mut 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 @@ -89,6 +89,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
#[test_case("test_xiuxiuda_protocol.yaml" ; "Xiuxiuda Protocol")]
#[test_case("test_longlosttouch_protocol.yaml" ; "LongLostTouch Protocol")]
#[test_case("test_adrienlastic_protocol.yaml" ; "Adrien Lastic Protocol")]
#[test_case("test_foreo_protocol.yaml" ; "Foreo Protocol")]
#[tokio::test]
async fn test_device_protocols_embedded_v3(test_file: &str) {
//tracing_subscriber::fmt::init();
Expand Down Expand Up @@ -167,6 +168,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) {
#[test_case("test_sakuraneko_koikoi.yaml" ; "Sakuraneko Protocol - Koikoi")]
#[test_case("test_xiuxiuda_protocol.yaml" ; "Xiuxiuda Protocol")]
#[test_case("test_adrienlastic_protocol.yaml" ; "Adrien Lastic Protocol")]
#[test_case("test_foreo_protocol.yaml" ; "Foreo Protocol")]
#[tokio::test]
async fn test_device_protocols_json_v3(test_file: &str) {
//tracing_subscriber::fmt::init();
Expand Down Expand Up @@ -228,6 +230,7 @@ async fn test_device_protocols_json_v3(test_file: &str) {
#[test_case("test_fox_protocol.yaml" ; "Fox Protocol")]
#[test_case("test_xiuxiuda_protocol.yaml" ; "Xiuxiuda Protocol")]
#[test_case("test_adrienlastic_protocol.yaml" ; "Adrien Lastic Protocol")]
#[test_case("test_foreo_protocol.yaml" ; "Foreo 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 @@ -288,6 +291,7 @@ async fn test_device_protocols_embedded_v2(test_file: &str) {
#[test_case("test_fox_protocol.yaml" ; "Fox Protocol")]
#[test_case("test_xiuxiuda_protocol.yaml" ; "Xiuxiuda Protocol")]
#[test_case("test_adrienlastic_protocol.yaml" ; "Adrien Lastic Protocol")]
#[test_case("test_foreo_protocol.yaml" ; "Foreo 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,42 @@
devices:
- identifier:
name: "FOFO"
expected_name: "Foreo Luna Fofo"
device_commands:
- !Messages
device_index: 0
messages:
- !Vibrate
- Index: 0
Speed: 0.5
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x01, 0x01, 0x05]
write_with_response: false
- !Messages
device_index: 0
messages:
- !Vibrate
- Index: 0
Speed: 0.75
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x01, 0x01, 0x08]
write_with_response: false
- !Messages
device_index: 0
messages:
- !Stop
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0x01, 0x01, 0x00]
write_with_response: false

0 comments on commit 49aa2e1

Please sign in to comment.