Buttplug sex toy control library
at master 68 lines 1.7 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 uuid::Uuid; 9 10use crate::device::{ 11 hardware::{HardwareCommand, HardwareWriteCmd}, 12 protocol::{ProtocolHandler, ProtocolKeepaliveStrategy, generic_protocol_setup}, 13}; 14use buttplug_core::errors::ButtplugDeviceError; 15use buttplug_server_device_config::Endpoint; 16 17generic_protocol_setup!(SvakomV3, "svakom-v3"); 18 19#[derive(Default)] 20pub struct SvakomV3 {} 21 22impl ProtocolHandler for SvakomV3 { 23 fn keepalive_strategy(&self) -> ProtocolKeepaliveStrategy { 24 ProtocolKeepaliveStrategy::HardwareRequiredRepeatLastPacketStrategy 25 } 26 27 fn handle_output_vibrate_cmd( 28 &self, 29 feature_index: u32, 30 feature_id: Uuid, 31 speed: u32, 32 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 33 Ok(vec![ 34 HardwareWriteCmd::new( 35 &[feature_id], 36 Endpoint::Tx, 37 [ 38 0x55, 39 if feature_index == 0 { 0x03 } else { 0x09 }, 40 if feature_index == 0 { 0x03 } else { 0x00 }, 41 0x00, 42 if speed == 0 { 0x00 } else { 0x01 }, 43 speed as u8, 44 ] 45 .to_vec(), 46 false, 47 ) 48 .into(), 49 ]) 50 } 51 52 fn handle_output_rotate_cmd( 53 &self, 54 _feature_index: u32, 55 feature_id: Uuid, 56 speed: i32, 57 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 58 Ok(vec![ 59 HardwareWriteCmd::new( 60 &[feature_id], 61 Endpoint::Tx, 62 [0x55, 0x08, 0x00, 0x00, speed as u8, 0xff].to_vec(), 63 false, 64 ) 65 .into(), 66 ]) 67 } 68}