Buttplug sex toy control library
at master 50 lines 1.3 kB view raw
1// Buttplug Rust Source Code File - See https://buttplug.io for more info. 2// 3// Copyright 2016-2023 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 8use crate::device::protocol::ProtocolKeepaliveStrategy; 9use crate::device::{ 10 hardware::{HardwareCommand, HardwareWriteCmd}, 11 protocol::{ProtocolHandler, generic_protocol_setup}, 12}; 13use buttplug_core::errors::ButtplugDeviceError; 14use buttplug_server_device_config::Endpoint; 15 16generic_protocol_setup!(SvakomV4, "svakom-v4"); 17 18#[derive(Default)] 19pub struct SvakomV4 {} 20 21impl ProtocolHandler for SvakomV4 { 22 fn keepalive_strategy(&self) -> ProtocolKeepaliveStrategy { 23 ProtocolKeepaliveStrategy::HardwareRequiredRepeatLastPacketStrategy 24 } 25 26 fn handle_output_vibrate_cmd( 27 &self, 28 feature_index: u32, 29 feature_id: uuid::Uuid, 30 speed: u32, 31 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 32 Ok(vec![ 33 HardwareWriteCmd::new( 34 &[feature_id], 35 Endpoint::Tx, 36 [ 37 0x55, 38 0x03, 39 feature_index as u8 + 1, 40 0x00, 41 if speed == 0 { 0x00 } else { 0x03 }, 42 speed as u8, 43 ] 44 .to_vec(), 45 false, 46 ) 47 .into(), 48 ]) 49 } 50}