···11+// Buttplug Rust Source Code File - See https://buttplug.io for more info.
22+//
33+// Copyright 2016-2024 Nonpolynomial Labs LLC. All rights reserved.
44+//
55+// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
66+// for full license information.
77+88+use crate::{
99+ core::{errors::ButtplugDeviceError, message::Endpoint},
1010+ server::device::{
1111+ hardware::{HardwareCommand, HardwareWriteCmd},
1212+ protocol::{generic_protocol_setup, ProtocolHandler},
1313+ },
1414+};
1515+1616+generic_protocol_setup!(ActiveJoy, "activejoy");
1717+1818+#[derive(Default)]
1919+pub struct ActiveJoy {}
2020+2121+impl ProtocolHandler for ActiveJoy {
2222+ fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
2323+ super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategy
2424+ }
2525+2626+ fn handle_scalar_vibrate_cmd(
2727+ &self,
2828+ index: u32,
2929+ scalar: u32,
3030+ ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
3131+ Ok(vec![HardwareWriteCmd::new(
3232+ Endpoint::Tx,
3333+ [
3434+ 0xb0, // static header
3535+ 0x01, // mode: 1=vibe, 5=shock, 6=thrust, 7=suction, 8=rotation, 16=swing,
3636+ 0x00, // strong mode = 1 (thrust, suction, swing, rotate)
3737+ index as u8, // 0 unless vibe2
3838+ if scalar == 0 { 0x00 } else { 0x01 },
3939+ scalar as u8,
4040+ ]
4141+ .to_vec(),
4242+ false,
4343+ )
4444+ .into()])
4545+ }
4646+}
+5
buttplug/src/server/device/protocol/mod.rs
···1313pub mod fleshlight_launch_helper;
14141515// Since users can pick and choose protocols, we need all of these to be public.
1616+pub mod activejoy;
1617pub mod adrienlastic;
1718pub mod aneros;
1819pub mod ankni;
···197198 map.insert(factory.identifier().to_owned(), factory);
198199 }
199200201201+ add_to_protocol_map(
202202+ &mut map,
203203+ activejoy::setup::ActiveJoyIdentifierFactory::default(),
204204+ );
200205 add_to_protocol_map(
201206 &mut map,
202207 adrienlastic::setup::AdrienLasticIdentifierFactory::default(),