Buttplug sex toy control library
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 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; 16use std::num::Wrapping; 17 18generic_protocol_setup!(Xibao, "xibao"); 19 20#[derive(Default)] 21pub struct Xibao {} 22 23impl ProtocolHandler for Xibao { 24 fn handle_output_oscillate_cmd( 25 &self, 26 _feature_index: u32, 27 feature_id: Uuid, 28 speed: u32, 29 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 Ok(vec![ 31 HardwareWriteCmd::new( 32 &[feature_id], 33 Endpoint::Tx, 34 vec![ 35 0x66, 36 0x3a, 37 0x00, 38 0x06, 39 0x00, 40 0x06, 41 0x01, 42 0x02, 43 0x00, 44 0x02, 45 0x04, 46 speed as u8, 47 (Wrapping(speed as u8) + Wrapping(0xb5)).0, 48 ], 49 false, 50 ) 51 .into(), 52 ]) 53 } 54}