Buttplug sex toy control library
20
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Add simple hismith control support

+45
+43
buttplug/src/device/protocol/hismith.rs
··· 1 + use super::{ButtplugDeviceResultFuture, ButtplugProtocol, ButtplugProtocolCommandHandler}; 2 + use crate::{ 3 + core::messages::{self, ButtplugDeviceCommandMessageUnion, DeviceMessageAttributesMap}, 4 + device::{ 5 + protocol::{generic_command_manager::GenericCommandManager, ButtplugProtocolProperties}, 6 + DeviceImpl, 7 + DeviceWriteCmd, 8 + Endpoint, 9 + }, 10 + }; 11 + use std::sync::Arc; 12 + 13 + super::default_protocol_declaration!(Hismith); 14 + 15 + impl ButtplugProtocolCommandHandler for Hismith { 16 + fn handle_vibrate_cmd( 17 + &self, 18 + device: Arc<DeviceImpl>, 19 + message: messages::VibrateCmd, 20 + ) -> ButtplugDeviceResultFuture { 21 + // Store off result before the match, so we drop the lock ASAP. 22 + let manager = self.manager.clone(); 23 + Box::pin(async move { 24 + let result = manager.lock().await.update_vibration(&message, false)?; 25 + let mut fut_vec = vec![]; 26 + if let Some(cmds) = result { 27 + if let Some(speed) = cmds[0] { 28 + fut_vec.push(device.write_value(DeviceWriteCmd::new( 29 + Endpoint::Tx, 30 + vec![0xAA, 0x04, speed as u8, (speed + 4) as u8], 31 + false, 32 + ))); 33 + } 34 + } 35 + // TODO Just use join_all here 36 + for fut in fut_vec { 37 + // TODO Do something about possible errors here 38 + fut.await?; 39 + } 40 + Ok(messages::Ok::default().into()) 41 + }) 42 + } 43 + }
+2
buttplug/src/device/protocol/mod.rs
··· 7 7 pub mod fredorch; 8 8 pub mod generic_command_manager; 9 9 pub mod hgod; 10 + pub mod hismith; 10 11 pub mod htk_bm; 11 12 pub mod jejoue; 12 13 pub mod kiiroo_v2; ··· 103 104 add_to_protocol_map::<buttplug_passthru::ButtplugPassthru>(&map, "buttplug-passthru"); 104 105 add_to_protocol_map::<cachito::Cachito>(&map, "cachito"); 105 106 add_to_protocol_map::<fredorch::Fredorch>(&map, "fredorch"); 107 + add_to_protocol_map::<hismith::Hismith>(&map, "hismith"); 106 108 add_to_protocol_map::<hgod::Hgod>(&map, "hgod"); 107 109 add_to_protocol_map::<htk_bm::HtkBm>(&map, "htk_bm"); 108 110 add_to_protocol_map::<jejoue::JeJoue>(&map, "jejoue");