Buttplug sex toy control library
at master 49 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::{ 9 hardware::{HardwareCommand, HardwareWriteCmd}, 10 protocol::{ProtocolHandler, ProtocolKeepaliveStrategy, generic_protocol_setup}, 11}; 12use buttplug_core::errors::ButtplugDeviceError; 13use buttplug_server_device_config::Endpoint; 14 15generic_protocol_setup!(SvakomPulse, "svakom-pulse"); 16 17#[derive(Default)] 18pub struct SvakomPulse {} 19 20impl ProtocolHandler for SvakomPulse { 21 fn keepalive_strategy(&self) -> ProtocolKeepaliveStrategy { 22 ProtocolKeepaliveStrategy::HardwareRequiredRepeatLastPacketStrategy 23 } 24 25 fn handle_output_vibrate_cmd( 26 &self, 27 _feature_index: u32, 28 feature_id: uuid::Uuid, 29 speed: u32, 30 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 31 Ok(vec![ 32 HardwareWriteCmd::new( 33 &[feature_id], 34 Endpoint::Tx, 35 [ 36 0x55, 37 0x03, 38 0x03, 39 0x00, 40 if speed == 0 { 0x00 } else { 0x01 }, 41 speed as u8 + 1, 42 ] 43 .to_vec(), 44 false, 45 ) 46 .into(), 47 ]) 48 } 49}