diff --git a/buttplug/buttplug-device-config/buttplug-device-config.json b/buttplug/buttplug-device-config/buttplug-device-config.json index 800a03fe..e1c9b093 100644 --- a/buttplug/buttplug-device-config/buttplug-device-config.json +++ b/buttplug/buttplug-device-config/buttplug-device-config.json @@ -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" + } + ] + } + } } } } diff --git a/buttplug/buttplug-device-config/buttplug-device-config.yml b/buttplug/buttplug-device-config/buttplug-device-config.yml index bd893a30..6f0c11d2 100644 --- a/buttplug/buttplug-device-config/buttplug-device-config.yml +++ b/buttplug/buttplug-device-config/buttplug-device-config.yml @@ -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 diff --git a/buttplug/src/server/device/protocol/foreo.rs b/buttplug/src/server/device/protocol/foreo.rs new file mode 100644 index 00000000..34367175 --- /dev/null +++ b/buttplug/src/server/device/protocol/foreo.rs @@ -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, ButtplugDeviceError> { + Ok(vec![HardwareWriteCmd::new( + Endpoint::Tx, + vec![0x01, 0x01, scalar as u8], + false, + ) + .into()]) + } +} diff --git a/buttplug/src/server/device/protocol/mod.rs b/buttplug/src/server/device/protocol/mod.rs index f62ce71b..2b052d6f 100644 --- a/buttplug/src/server/device/protocol/mod.rs +++ b/buttplug/src/server/device/protocol/mod.rs @@ -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; @@ -179,6 +180,7 @@ pub fn get_default_protocol_map() -> HashMap 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(); @@ -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(); @@ -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) @@ -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; diff --git a/buttplug/tests/util/device_test/device_test_case/test_foreo_protocol.yaml b/buttplug/tests/util/device_test/device_test_case/test_foreo_protocol.yaml new file mode 100644 index 00000000..a960e886 --- /dev/null +++ b/buttplug/tests/util/device_test/device_test_case/test_foreo_protocol.yaml @@ -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