Buttplug sex toy control library
at master 50 lines 1.4 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 buttplug_core::errors::ButtplugDeviceError; 9use buttplug_server_device_config::Endpoint; 10use uuid::Uuid; 11 12use crate::device::{ 13 hardware::{HardwareCommand, HardwareWriteCmd}, 14 protocol::{ProtocolHandler, generic_protocol_setup}, 15}; 16 17generic_protocol_setup!(SvakomTaraX, "svakom-tarax"); 18 19#[derive(Default)] 20pub struct SvakomTaraX {} 21 22impl ProtocolHandler for SvakomTaraX { 23 // I am like 90% sure this is wrong since this device has two vibrators, but the original 24 // implementation made no sense in terms of knowing which command addressed which index. Putting 25 // in a best effort here and we'll see if anyone complains. 26 fn handle_output_vibrate_cmd( 27 &self, 28 _feature_index: u32, 29 feature_id: 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 0x00, 40 0x00, 41 if speed == 0 { 0x01 } else { speed as u8 }, 42 if speed == 0 { 0x01 } else { 0x02 }, 43 ] 44 .to_vec(), 45 false, 46 ) 47 .into(), 48 ]) 49 } 50}