Buttplug sex toy control library
1// Buttplug Rust Source Code File - See https://buttplug.io for more info.
2//
3// Copyright 2016-2025 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!(Luvmazer, "luvmazer");
18
19#[derive(Default)]
20pub struct Luvmazer {}
21
22impl ProtocolHandler for Luvmazer {
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![0xa0, 0x01, 0x00, feature_index as u8, 0x64, speed as u8],
34 false,
35 )
36 .into(),
37 ])
38 }
39
40 fn handle_output_rotate_cmd(
41 &self,
42 _feature_index: u32,
43 feature_id: Uuid,
44 speed: i32,
45 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
46 Ok(vec![
47 HardwareWriteCmd::new(
48 &[feature_id],
49 Endpoint::Tx,
50 vec![0xa0, 0x0f, 0x00, 0x00, 0x64, speed as u8],
51 false,
52 )
53 .into(),
54 ])
55 }
56
57 fn handle_output_oscillate_cmd(
58 &self,
59 _feature_index: u32,
60 feature_id: Uuid,
61 speed: u32,
62 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
63 Ok(vec![
64 HardwareWriteCmd::new(
65 &[feature_id],
66 Endpoint::Tx,
67 vec![0xa0, 0x06, 0x01, 0x00, 0x64, speed as u8],
68 false,
69 )
70 .into(),
71 ])
72 }
73
74 fn handle_output_constrict_cmd(
75 &self,
76 _feature_index: u32,
77 feature_id: Uuid,
78 speed: u32,
79 ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
80 Ok(vec![
81 HardwareWriteCmd::new(
82 &[feature_id],
83 Endpoint::Tx,
84 vec![
85 0xa0,
86 0x0d,
87 0x00,
88 0x00,
89 if speed == 0 { 0x00 } else { 0x14 },
90 speed as u8,
91 ],
92 false,
93 )
94 .into(),
95 ])
96 }
97}