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!(Maxpro, "maxpro");
18
19#[derive(Default)]
20pub struct Maxpro {}
21
22impl ProtocolHandler for Maxpro {
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![
30 0x55u8,
31 0x04,
32 0x07,
33 0xff,
34 0xff,
35 0x3f,
36 speed as u8,
37 0x5f,
38 speed as u8,
39 0x00,
40 ];
41 let mut crc: u8 = 0;
42
43 for b in data.clone() {
44 crc = crc.wrapping_add(b);
45 }
46
47 data[9] = crc;
48 Ok(vec![
49 HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, data, false).into(),
50 ])
51 }
52}