Buttplug sex toy control library
at dev 1.1 kB view raw
1// Buttplug Rust Source Code File - See https://buttplug.io for more info. 2// 3// Copyright 2016-2024 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 uuid::Uuid; 9 10use crate::device::{ 11 hardware::{HardwareCommand, HardwareWriteCmd}, 12 protocol::{ProtocolHandler, generic_protocol_setup}, 13}; 14use buttplug_core::errors::ButtplugDeviceError; 15use buttplug_server_device_config::Endpoint; 16 17generic_protocol_setup!(FleshyThrust, "fleshy-thrust"); 18 19#[derive(Default)] 20pub struct FleshyThrust {} 21 22impl ProtocolHandler for FleshyThrust { 23 fn handle_position_with_duration_cmd( 24 &self, 25 _feature_index: u32, 26 feature_id: Uuid, 27 position: u32, 28 duration: u32, 29 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 Ok(vec![ 31 HardwareWriteCmd::new( 32 &[feature_id], 33 Endpoint::Tx, 34 vec![ 35 position as u8, 36 ((duration & 0xff00) >> 8) as u8, 37 (duration & 0xff) as u8, 38 ], 39 false, 40 ) 41 .into(), 42 ]) 43 } 44}