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!(SenseeCapsule, "sensee-capsule");
18
19#[derive(Default)]
20pub struct SenseeCapsule {}
21
22impl ProtocolHandler for SenseeCapsule {
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 Ok(vec![
30 HardwareWriteCmd::new(
31 &[feature_id],
32 Endpoint::Tx,
33 vec![
34 0x55,
35 0xaa,
36 0xf0,
37 0x01,
38 0x00,
39 0x12,
40 0x66,
41 0xf9,
42 0xf0 | speed as u8,
43 ],
44 false,
45 )
46 .into(),
47 ])
48 }
49
50 fn handle_output_constrict_cmd(
51 &self,
52 _feature_index: u32,
53 feature_id: Uuid,
54 level: u32,
55 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
56 Ok(vec![
57 HardwareWriteCmd::new(
58 &[feature_id],
59 Endpoint::Tx,
60 vec![
61 0x55,
62 0xaa,
63 0xf0,
64 0x01,
65 0x00,
66 0x11,
67 0x66,
68 0xf2,
69 0xf0 | level as u8,
70 0x00,
71 0x00,
72 ],
73 false,
74 )
75 .into(),
76 ])
77 }
78}