···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+8+use crate::{
9+ core::{errors::ButtplugDeviceError, message::Endpoint},
10+ server::device::{
11+ hardware::{HardwareCommand, HardwareWriteCmd},
12+ protocol::{generic_protocol_setup, ProtocolHandler},
13+ },
14+};
15+16+generic_protocol_setup!(ActiveJoy, "activejoy");
17+18+#[derive(Default)]
19+pub struct ActiveJoy {}
20+21+impl ProtocolHandler for ActiveJoy {
22+ fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
23+ super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategy
24+ }
25+26+ fn handle_scalar_vibrate_cmd(
27+ &self,
28+ index: u32,
29+ scalar: u32,
30+ ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
31+ Ok(vec![HardwareWriteCmd::new(
32+ Endpoint::Tx,
33+ [
34+ 0xb0, // static header
35+ 0x01, // mode: 1=vibe, 5=shock, 6=thrust, 7=suction, 8=rotation, 16=swing,
36+ 0x00, // strong mode = 1 (thrust, suction, swing, rotate)
37+ index as u8, // 0 unless vibe2
38+ if scalar == 0 { 0x00 } else { 0x01 },
39+ scalar as u8,
40+ ]
41+ .to_vec(),
42+ false,
43+ )
44+ .into()])
45+ }
46+}
+5
buttplug/src/server/device/protocol/mod.rs
···13pub mod fleshlight_launch_helper;
1415// Since users can pick and choose protocols, we need all of these to be public.
016pub mod adrienlastic;
17pub mod aneros;
18pub mod ankni;
···197 map.insert(factory.identifier().to_owned(), factory);
198 }
1990000200 add_to_protocol_map(
201 &mut map,
202 adrienlastic::setup::AdrienLasticIdentifierFactory::default(),
···13pub mod fleshlight_launch_helper;
1415// Since users can pick and choose protocols, we need all of these to be public.
16+pub mod activejoy;
17pub mod adrienlastic;
18pub mod aneros;
19pub mod ankni;
···198 map.insert(factory.identifier().to_owned(), factory);
199 }
200201+ add_to_protocol_map(
202+ &mut map,
203+ activejoy::setup::ActiveJoyIdentifierFactory::default(),
204+ );
205 add_to_protocol_map(
206 &mut map,
207 adrienlastic::setup::AdrienLasticIdentifierFactory::default(),