// Buttplug Rust Source Code File - See https://buttplug.io for more info. // // Copyright 2016-2024 Nonpolynomial Labs LLC. All rights reserved. // // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. use uuid::Uuid; use crate::device::{ hardware::{HardwareCommand, HardwareWriteCmd}, protocol::{ProtocolHandler, generic_protocol_setup}, }; use buttplug_core::errors::ButtplugDeviceError; use buttplug_server_device_config::Endpoint; generic_protocol_setup!(Maxpro, "maxpro"); #[derive(Default)] pub struct Maxpro {} impl ProtocolHandler for Maxpro { fn handle_output_vibrate_cmd( &self, _feature_index: u32, feature_id: Uuid, speed: u32, ) -> Result, ButtplugDeviceError> { let mut data = vec![ 0x55u8, 0x04, 0x07, 0xff, 0xff, 0x3f, speed as u8, 0x5f, speed as u8, 0x00, ]; let mut crc: u8 = 0; for b in data.clone() { crc = crc.wrapping_add(b); } data[9] = crc; Ok(vec![ HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, data, false).into(), ]) } }