···11+use super::{ButtplugDeviceResultFuture, ButtplugProtocol, ButtplugProtocolCommandHandler};
22+use crate::{
33+ core::messages::{self, ButtplugDeviceCommandMessageUnion, DeviceMessageAttributesMap},
44+ device::{
55+ protocol::{generic_command_manager::GenericCommandManager, ButtplugProtocolProperties},
66+ DeviceImpl,
77+ DeviceWriteCmd,
88+ Endpoint,
99+ },
1010+};
1111+use std::sync::Arc;
1212+1313+super::default_protocol_declaration!(Hismith);
1414+1515+impl ButtplugProtocolCommandHandler for Hismith {
1616+ fn handle_vibrate_cmd(
1717+ &self,
1818+ device: Arc<DeviceImpl>,
1919+ message: messages::VibrateCmd,
2020+ ) -> ButtplugDeviceResultFuture {
2121+ // Store off result before the match, so we drop the lock ASAP.
2222+ let manager = self.manager.clone();
2323+ Box::pin(async move {
2424+ let result = manager.lock().await.update_vibration(&message, false)?;
2525+ let mut fut_vec = vec![];
2626+ if let Some(cmds) = result {
2727+ if let Some(speed) = cmds[0] {
2828+ fut_vec.push(device.write_value(DeviceWriteCmd::new(
2929+ Endpoint::Tx,
3030+ vec![0xAA, 0x04, speed as u8, (speed + 4) as u8],
3131+ false,
3232+ )));
3333+ }
3434+ }
3535+ // TODO Just use join_all here
3636+ for fut in fut_vec {
3737+ // TODO Do something about possible errors here
3838+ fut.await?;
3939+ }
4040+ Ok(messages::Ok::default().into())
4141+ })
4242+ }
4343+}
+2
buttplug/src/device/protocol/mod.rs
···77pub mod fredorch;
88pub mod generic_command_manager;
99pub mod hgod;
1010+pub mod hismith;
1011pub mod htk_bm;
1112pub mod jejoue;
1213pub mod kiiroo_v2;
···103104 add_to_protocol_map::<buttplug_passthru::ButtplugPassthru>(&map, "buttplug-passthru");
104105 add_to_protocol_map::<cachito::Cachito>(&map, "cachito");
105106 add_to_protocol_map::<fredorch::Fredorch>(&map, "fredorch");
107107+ add_to_protocol_map::<hismith::Hismith>(&map, "hismith");
106108 add_to_protocol_map::<hgod::Hgod>(&map, "hgod");
107109 add_to_protocol_map::<htk_bm::HtkBm>(&map, "htk_bm");
108110 add_to_protocol_map::<jejoue::JeJoue>(&map, "jejoue");