Buttplug sex toy control library
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!(ManNuo, "mannuo"); 18 19#[derive(Default)] 20pub struct ManNuo {} 21 22impl ProtocolHandler for ManNuo { 23 fn handle_output_vibrate_cmd( 24 &self, 25 _feature_index: u32, 26 feature_id: Uuid, 27 speed: u32, 28 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 29 let mut data = vec![0xAA, 0x55, 0x06, 0x01, 0x01, 0x01, speed as u8, 0xFA]; 30 // Simple XOR of everything up to the 9th byte for CRC. 31 let mut crc: u8 = 0; 32 for b in data.clone() { 33 crc ^= b; 34 } 35 data.push(crc); 36 Ok(vec![ 37 HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, data, true).into(), 38 ]) 39 } 40}