Buttplug sex toy control library

chore: Run rustfmt

+2654 -2170
+15 -4
crates/buttplug_client/src/client_device_feature.rs
··· 4 4 use getset::{CopyGetters, Getters}; 5 5 6 6 use buttplug_core::{ 7 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 8 - message::{ 9 - ButtplugDeviceMessageNameV4, ButtplugServerMessageV4, DeviceFeature, InputCmdV4, InputCommandType, InputType, OutputCmdV4, OutputCommand, OutputPositionWithDuration, OutputRotateWithDirection, OutputType, OutputValue 10 - }, 7 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 8 + message::{ 9 + ButtplugDeviceMessageNameV4, 10 + ButtplugServerMessageV4, 11 + DeviceFeature, 12 + InputCmdV4, 13 + InputCommandType, 14 + InputType, 15 + OutputCmdV4, 16 + OutputCommand, 17 + OutputPositionWithDuration, 18 + OutputRotateWithDirection, 19 + OutputType, 20 + OutputValue, 21 + }, 11 22 }; 12 23 13 24 use super::{
+5 -2
crates/buttplug_client/src/client_event_loop.rs
··· 27 27 }, 28 28 }; 29 29 use dashmap::DashMap; 30 + use log::*; 30 31 use std::sync::{ 31 32 atomic::{AtomicBool, Ordering}, 32 33 Arc, 33 34 }; 34 - use tokio::{select, sync::{broadcast, mpsc}}; 35 - use log::*; 35 + use tokio::{ 36 + select, 37 + sync::{broadcast, mpsc}, 38 + }; 36 39 37 40 /// Enum used for communication from the client to the event loop. 38 41 #[derive(Clone)]
+1 -1
crates/buttplug_client/src/client_message_sorter.rs
··· 14 14 }; 15 15 use buttplug_core::message::{ButtplugMessage, ButtplugMessageValidator, ButtplugServerMessageV4}; 16 16 use dashmap::DashMap; 17 + use log::*; 17 18 use std::sync::{ 18 19 atomic::{AtomicU32, Ordering}, 19 20 Arc, 20 21 }; 21 - use log::*; 22 22 23 23 /// Message sorting and pairing for remote client connectors. 24 24 ///
+2 -2
crates/buttplug_client/src/connector/mod.rs
··· 1 1 use super::serializer::ButtplugClientJSONSerializer; 2 2 use buttplug_core::{ 3 - connector::ButtplugRemoteConnector, 4 - message::{ButtplugClientMessageV4, ButtplugServerMessageV4}, 3 + connector::ButtplugRemoteConnector, 4 + message::{ButtplugClientMessageV4, ButtplugServerMessageV4}, 5 5 }; 6 6 7 7 pub type ButtplugRemoteClientConnector<
+13 -13
crates/buttplug_client/src/device.rs
··· 14 14 ButtplugClientResultFuture, 15 15 }; 16 16 use buttplug_core::{ 17 - errors::ButtplugDeviceError, 18 - message::{ 19 - OutputCmdV4, 20 - OutputCommand, 21 - OutputType, 22 - OutputValue, 23 - ButtplugServerMessageV4, 24 - DeviceFeature, 25 - DeviceMessageInfoV4, 26 - FeatureType, 27 - StopDeviceCmdV0, 28 - }, 17 + errors::ButtplugDeviceError, 18 + message::{ 19 + ButtplugServerMessageV4, 20 + DeviceFeature, 21 + DeviceMessageInfoV4, 22 + FeatureType, 23 + OutputCmdV4, 24 + OutputCommand, 25 + OutputType, 26 + OutputValue, 27 + StopDeviceCmdV0, 28 + }, 29 29 util::stream::convert_broadcast_receiver_to_stream, 30 30 }; 31 31 use futures::{FutureExt, Stream}; 32 32 use getset::{CopyGetters, Getters}; 33 + use log::*; 33 34 use std::{ 34 35 fmt, 35 36 sync::{ ··· 38 39 }, 39 40 }; 40 41 use tokio::sync::broadcast; 41 - use log::*; 42 42 43 43 /// Enum for messages going to a [ButtplugClientDevice] instance. 44 44 #[derive(Clone, Debug)]
+1 -1
crates/buttplug_client/src/lib.rs
··· 41 41 future::{self, BoxFuture, FutureExt}, 42 42 Stream, 43 43 }; 44 + use log::*; 44 45 use std::sync::{ 45 46 atomic::{AtomicBool, Ordering}, 46 47 Arc, ··· 48 49 use thiserror::Error; 49 50 use tokio::sync::{broadcast, mpsc, Mutex}; 50 51 use tracing_futures::Instrument; 51 - use log::*; 52 52 53 53 /// Result type used for public APIs. 54 54 ///
+3 -5
crates/buttplug_client_in_process/src/in_process_client.rs
··· 7 7 8 8 use super::ButtplugInProcessClientConnectorBuilder; 9 9 use buttplug_client::ButtplugClient; 10 - use buttplug_server_device_config::{DeviceConfigurationManagerBuilder}; 11 10 use buttplug_server::{device::ServerDeviceManagerBuilder, ButtplugServerBuilder}; 11 + use buttplug_server_device_config::DeviceConfigurationManagerBuilder; 12 12 13 13 /// Convenience function for creating in-process connectors. 14 14 /// ··· 50 50 .unwrap(); 51 51 52 52 let mut device_manager_builder = ServerDeviceManagerBuilder::new(dcm); 53 - #[cfg(feature = "btleplug-manager",)] 53 + #[cfg(feature = "btleplug-manager")] 54 54 { 55 55 use buttplug_server_hwmgr_btleplug::BtlePlugCommunicationManagerBuilder; 56 56 device_manager_builder.comm_manager(BtlePlugCommunicationManagerBuilder::default()); ··· 81 81 any(target_os = "windows", target_os = "macos", target_os = "linux") 82 82 ))] 83 83 { 84 - use buttplug_server_hwmgr_lovense_dongle::{ 85 - LovenseHIDDongleCommunicationManagerBuilder, 86 - }; 84 + use buttplug_server_hwmgr_lovense_dongle::LovenseHIDDongleCommunicationManagerBuilder; 87 85 device_manager_builder.comm_manager(LovenseHIDDongleCommunicationManagerBuilder::default()); 88 86 } 89 87 #[cfg(all(feature = "xinput-manager", target_os = "windows"))]
+11 -7
crates/buttplug_client_in_process/src/in_process_connector.rs
··· 8 8 //! In-process communication between clients and servers 9 9 10 10 use buttplug_core::{ 11 - connector::{ButtplugConnector, ButtplugConnectorError, ButtplugConnectorResultFuture}, 12 - errors::{ButtplugError, ButtplugMessageError}, 13 - message::{ButtplugClientMessageV4, ButtplugServerMessageV4}, 14 - util::async_manager, 15 - }; 16 - use buttplug_server::{message::ButtplugServerMessageVariant, ButtplugServer, ButtplugServerBuilder}; 11 + connector::{ButtplugConnector, ButtplugConnectorError, ButtplugConnectorResultFuture}, 12 + errors::{ButtplugError, ButtplugMessageError}, 13 + message::{ButtplugClientMessageV4, ButtplugServerMessageV4}, 14 + util::async_manager, 15 + }; 16 + use buttplug_server::{ 17 + message::ButtplugServerMessageVariant, 18 + ButtplugServer, 19 + ButtplugServerBuilder, 20 + }; 17 21 18 22 use futures::{ 19 23 future::{self, BoxFuture, FutureExt}, 20 24 StreamExt, 21 25 }; 26 + use futures_util::pin_mut; 22 27 use std::sync::{ 23 28 atomic::{AtomicBool, Ordering}, 24 29 Arc, 25 30 }; 26 - use futures_util::pin_mut; 27 31 use tokio::sync::mpsc::{channel, Sender}; 28 32 use tracing_futures::Instrument; 29 33
+4 -1
crates/buttplug_client_in_process/src/lib.rs
··· 5 5 mod in_process_connector; 6 6 7 7 pub use in_process_client::in_process_client; 8 - pub use in_process_connector::{ButtplugInProcessClientConnectorBuilder, ButtplugInProcessClientConnector}; 8 + pub use in_process_connector::{ 9 + ButtplugInProcessClientConnector, 10 + ButtplugInProcessClientConnectorBuilder, 11 + };
+1 -1
crates/buttplug_core/src/connector/remote_connector.rs
··· 21 21 util::async_manager, 22 22 }; 23 23 use futures::{future::BoxFuture, select, FutureExt}; 24 + use log::*; 24 25 use std::marker::PhantomData; 25 26 use tokio::sync::mpsc::{channel, Receiver, Sender}; 26 - use log::*; 27 27 28 28 enum ButtplugRemoteConnectorMessage<T> 29 29 where
+1 -1
crates/buttplug_core/src/connector/transport/mod.rs
··· 12 12 ButtplugConnectorResultFuture, 13 13 ButtplugSerializedMessage, 14 14 }; 15 + use displaydoc::Display; 15 16 use futures::future::BoxFuture; 16 17 use thiserror::Error; 17 18 use tokio::sync::mpsc::{Receiver, Sender}; 18 - use displaydoc::Display; 19 19 20 20 /// Messages we can receive from a connector. 21 21 #[derive(Clone, Debug, Display)]
+6 -6
crates/buttplug_core/src/connector/transport/stream.rs
··· 9 9 //! process space. 10 10 11 11 use crate::{ 12 - connector::{ 13 - transport::{ButtplugConnectorTransport, ButtplugTransportIncomingMessage}, 14 - ButtplugConnectorError, 15 - ButtplugConnectorResultFuture, 16 - }, 17 - message::serializer::ButtplugSerializedMessage, 12 + connector::{ 13 + transport::{ButtplugConnectorTransport, ButtplugTransportIncomingMessage}, 14 + ButtplugConnectorError, 15 + ButtplugConnectorResultFuture, 16 + }, 17 + message::serializer::ButtplugSerializedMessage, 18 18 util::async_manager, 19 19 }; 20 20 use futures::{
+1 -1
crates/buttplug_core/src/errors.rs
··· 10 10 use super::message::{ 11 11 self, 12 12 serializer::ButtplugSerializerError, 13 - OutputType, 14 13 ButtplugMessageSpecVersion, 15 14 Endpoint, 16 15 ErrorCode, 17 16 FeatureType, 18 17 InputType, 18 + OutputType, 19 19 }; 20 20 use futures::future::BoxFuture; 21 21 use serde::{Deserialize, Serialize};
+1 -1
crates/buttplug_core/src/message/v0/error.rs
··· 41 41 Getters, 42 42 CopyGetters, 43 43 Serialize, 44 - Deserialize 44 + Deserialize, 45 45 )] 46 46 pub struct ErrorV0 { 47 47 /// Message Id, used for matching message pairs in remote connection instances.
+8 -8
crates/buttplug_core/src/message/v4/mod.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - mod output_cmd; 9 8 mod device_added; 10 9 mod device_list; 11 10 mod device_message_info; 12 - mod request_server_info; 13 11 mod input_cmd; 14 12 mod input_reading; 13 + mod output_cmd; 14 + mod request_server_info; 15 15 mod server_info; 16 16 mod spec_enums; 17 17 18 18 pub use { 19 + device_added::DeviceAddedV4, 20 + device_list::DeviceListV4, 21 + device_message_info::DeviceMessageInfoV4, 22 + input_cmd::{InputCmdV4, InputCommandType}, 23 + input_reading::InputReadingV4, 19 24 output_cmd::{ 20 25 OutputCmdV4, 21 26 OutputCommand, ··· 23 28 OutputRotateWithDirection, 24 29 OutputValue, 25 30 }, 26 - device_added::DeviceAddedV4, 27 - device_list::DeviceListV4, 28 - device_message_info::DeviceMessageInfoV4, 29 31 request_server_info::RequestServerInfoV4, 30 - input_cmd::{InputCmdV4, InputCommandType}, 31 - input_reading::InputReadingV4, 32 32 server_info::ServerInfoV4, 33 - spec_enums::{ButtplugClientMessageV4, ButtplugServerMessageV4, ButtplugDeviceMessageNameV4}, 33 + spec_enums::{ButtplugClientMessageV4, ButtplugDeviceMessageNameV4, ButtplugServerMessageV4}, 34 34 };
+2 -5
crates/buttplug_core/src/message/v4/output_cmd.rs
··· 8 8 use crate::{ 9 9 errors::{ButtplugDeviceError, ButtplugError}, 10 10 message::{ 11 - OutputType, 12 11 ButtplugDeviceMessage, 13 12 ButtplugMessage, 14 13 ButtplugMessageError, 15 14 ButtplugMessageFinalizer, 16 15 ButtplugMessageValidator, 16 + OutputType, 17 17 }, 18 18 }; 19 19 use getset::CopyGetters; ··· 126 126 } 127 127 } 128 128 129 - pub fn from_output_type( 130 - output_type: OutputType, 131 - value: u32, 132 - ) -> Result<Self, ButtplugError> { 129 + pub fn from_output_type(output_type: OutputType, value: u32) -> Result<Self, ButtplugError> { 133 130 match output_type { 134 131 OutputType::Constrict => Ok(Self::Constrict(OutputValue::new(value))), 135 132 OutputType::Heater => Ok(Self::Heater(OutputValue::new(value))),
+1 -1
crates/buttplug_core/src/message/v4/spec_enums.rs
··· 7 7 8 8 use crate::message::{ 9 9 v4::input_cmd::InputCmdV4, 10 - OutputCmdV4, 11 10 ButtplugMessage, 12 11 ButtplugMessageError, 13 12 ButtplugMessageFinalizer, ··· 15 14 DeviceRemovedV0, 16 15 ErrorV0, 17 16 OkV0, 17 + OutputCmdV4, 18 18 PingV0, 19 19 RequestDeviceListV0, 20 20 RequestServerInfoV4,
+1 -1
crates/buttplug_core/src/util/async_manager/wasm_bindgen.rs
··· 35 35 Fut::Output: Send, 36 36 { 37 37 WasmBindgenAsyncManager::default().spawn_with_handle(future) 38 - } 38 + }
+5 -2
crates/buttplug_server/src/device/hardware/communication.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{{errors::ButtplugDeviceError, ButtplugResultFuture}, util::{async_manager, sleep}}; 9 8 use crate::device::hardware::HardwareConnector; 10 9 use async_trait::async_trait; 10 + use buttplug_core::{ 11 + util::{async_manager, sleep}, 12 + {errors::ButtplugDeviceError, ButtplugResultFuture}, 13 + }; 11 14 use futures::future::{self, FutureExt}; 12 15 use serde::{Deserialize, Serialize}; 13 16 use std::{sync::Arc, time::Duration}; ··· 48 51 #[derive(Error, Debug, Clone, Display, Serialize, Deserialize, PartialEq, Eq)] 49 52 pub enum HardwareSpecificError { 50 53 // HardwareSpecificError: {} Error: {} 51 - HardwareSpecificError(String, String) 54 + HardwareSpecificError(String, String), 52 55 } 53 56 54 57 #[async_trait]
+3 -6
crates/buttplug_server/src/device/hardware/mod.rs
··· 1 1 pub mod communication; 2 2 use std::{collections::HashSet, fmt::Debug, sync::Arc, time::Duration}; 3 3 4 - use buttplug_core::{ 5 - errors::ButtplugDeviceError, 6 - message::Endpoint, 7 - }; 4 + use async_trait::async_trait; 5 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 8 6 use buttplug_server_device_config::ProtocolCommunicationSpecifier; 9 - use async_trait::async_trait; 10 7 use futures::future::BoxFuture; 11 8 use futures_util::FutureExt; 12 9 use getset::{CopyGetters, Getters}; ··· 262 259 /// Minimum time between two packets being sent to the device. Used to deal with congestion across 263 260 /// protocols like Bluetooth LE, which have guaranteed delivery but can be overloaded due to 264 261 /// connection intervals. 265 - #[getset(get_copy = "pub")] 262 + #[getset(get_copy = "pub")] 266 263 message_gap: Option<Duration>, 267 264 /// Internal implementation details 268 265 internal_impl: Box<dyn HardwareInternal>,
+3 -5
crates/buttplug_server/src/device/protocol/activejoy.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(ActiveJoy, "activejoy"); 17 17 ··· 19 19 pub struct ActiveJoy {} 20 20 21 21 impl ProtocolHandler for ActiveJoy { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/adrienlastic.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(AdrienLastic, "adrienlastic"); 17 17 ··· 19 19 pub struct AdrienLastic {} 20 20 21 21 impl ProtocolHandler for AdrienLastic { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+8 -10
crates/buttplug_server/src/device/protocol/amorelie_joy.rs
··· 9 9 use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 10 10 11 11 use crate::device::{ 12 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 13 - protocol::{ 14 - generic_protocol_initializer_setup, 15 - ProtocolCommunicationSpecifier, 16 - ProtocolHandler, 17 - ProtocolIdentifier, 18 - ProtocolInitializer, 19 - }, 12 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 13 + protocol::{ 14 + generic_protocol_initializer_setup, 15 + ProtocolCommunicationSpecifier, 16 + ProtocolHandler, 17 + ProtocolIdentifier, 18 + ProtocolInitializer, 19 + }, 20 20 }; 21 21 use async_trait::async_trait; 22 22 use std::sync::Arc; ··· 52 52 pub struct AmorelieJoy {} 53 53 54 54 impl ProtocolHandler for AmorelieJoy { 55 - 56 - 57 55 fn handle_output_vibrate_cmd( 58 56 &self, 59 57 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/aneros.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Aneros, "aneros"); 17 17 ··· 19 19 pub struct Aneros {} 20 20 21 21 impl ProtocolHandler for Aneros { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 feature_index: u32,
+13 -11
crates/buttplug_server/src/device/protocol/ankni.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use uuid::{uuid, Uuid}; 22 26 ··· 77 81 pub struct Ankni {} 78 82 79 83 impl ProtocolHandler for Ankni { 80 - 81 - 82 84 fn handle_output_vibrate_cmd( 83 85 &self, 84 86 _feature_index: u32,
+3 -3
crates/buttplug_server/src/device/protocol/bananasome.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const BANANASOME_PROTOCOL_UUID: Uuid = uuid!("a0a2e5f8-3692-4f6b-8add-043513ed86f6"); 19 19 generic_protocol_setup!(Bananasome, "bananasome");
+3 -5
crates/buttplug_server/src/device/protocol/cachito.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Cachito, "cachito"); 17 17 ··· 19 19 pub struct Cachito {} 20 20 21 21 impl ProtocolHandler for Cachito { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 feature_index: u32,
+3 -3
crates/buttplug_server/src/device/protocol/cowgirl.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const COWGIRL_PROTOCOL_UUID: Uuid = uuid!("0474d2fd-f566-4bed-8770-88e457a96144"); 19 19 generic_protocol_setup!(Cowgirl, "cowgirl");
+13 -9
crates/buttplug_server/src/device/protocol/cowgirl_cone.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::sleep}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::sleep}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::{sync::Arc, time::Duration}; 21 25 use uuid::{uuid, Uuid}; 22 26
+3 -5
crates/buttplug_server/src/device/protocol/cupido.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{ProtocolHandler, generic_protocol_setup} 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Cupido, "cupido"); 17 17 ··· 19 19 pub struct Cupido {} 20 20 21 21 impl ProtocolHandler for Cupido { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/deepsire.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(DeepSire, "deepsire"); 17 17 ··· 19 19 pub struct DeepSire {} 20 20 21 21 impl ProtocolHandler for DeepSire { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -3
crates/buttplug_server/src/device/protocol/feelingso.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{ProtocolHandler, generic_protocol_setup} 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const FEELINGSO_PROTOCOL_UUID: Uuid = uuid!("397d4cce-3173-4f66-b7ad-6ee21e59f854"); 19 19
+3 -3
crates/buttplug_server/src/device/protocol/fleshy_thrust.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(FleshyThrust, "fleshy-thrust"); 17 17
+13 -11
crates/buttplug_server/src/device/protocol/foreo.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use uuid::Uuid; 22 26 ··· 52 56 } 53 57 54 58 impl ProtocolHandler for Foreo { 55 - 56 - 57 59 fn handle_output_vibrate_cmd( 58 60 &self, 59 61 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/fox.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Fox, "fox"); 17 17 ··· 19 19 pub struct Fox {} 20 20 21 21 impl ProtocolHandler for Fox { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+13 -9
crates/buttplug_server/src/device/protocol/fredorch.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::sleep}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::sleep}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use futures::FutureExt; 21 25 use std::{ 22 26 sync::{
+18 -11
crates/buttplug_server/src/device/protocol/fredorch_rotary.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::{async_manager, sleep},}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 18 - 9 + hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 19 16 }; 20 17 use async_trait::async_trait; 18 + use buttplug_core::{ 19 + errors::ButtplugDeviceError, 20 + message::Endpoint, 21 + util::{async_manager, sleep}, 22 + }; 23 + use buttplug_server_device_config::{ 24 + DeviceDefinition, 25 + ProtocolCommunicationSpecifier, 26 + UserDeviceIdentifier, 27 + }; 21 28 use futures::FutureExt; 22 29 use std::{ 23 30 sync::{ ··· 26 33 }, 27 34 time::Duration, 28 35 }; 29 - use uuid::{uuid, Uuid}; 30 36 use tokio::select; 37 + use uuid::{uuid, Uuid}; 31 38 32 39 const FREDORCH_COMMAND_TIMEOUT_MS: u64 = 100; 33 40 const FREDORCH_ROTORY_PROTOCOL_UUID: Uuid = uuid!("0ec6598a-bfd1-4f47-9738-e8cd8ace6473");
+19 -10
crates/buttplug_server/src/device/protocol/galaku.rs
··· 16 16 use buttplug_core::message::{InputReadingV4, InputType}; 17 17 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 18 18 19 - use buttplug_server_device_config::{UserDeviceIdentifier, ProtocolCommunicationSpecifier, DeviceDefinition}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 21 25 use crate::device::{ 22 - hardware::{ 23 - Hardware, 24 - HardwareCommand, 25 - HardwareEvent, 26 - HardwareSubscribeCmd, 27 - HardwareUnsubscribeCmd, 28 - HardwareWriteCmd, 29 - }, 30 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer, generic_protocol_initializer_setup,}, 26 + hardware::{ 27 + Hardware, 28 + HardwareCommand, 29 + HardwareEvent, 30 + HardwareSubscribeCmd, 31 + HardwareUnsubscribeCmd, 32 + HardwareWriteCmd, 33 + }, 34 + protocol::{ 35 + generic_protocol_initializer_setup, 36 + ProtocolHandler, 37 + ProtocolIdentifier, 38 + ProtocolInitializer, 39 + }, 31 40 }; 32 41 33 42 static KEY_TAB: [[u32; 12]; 4] = [
+3 -3
crates/buttplug_server/src/device/protocol/galaku_pump.rs
··· 7 7 8 8 use uuid::{uuid, Uuid}; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 use std::num::Wrapping; 16 16 use std::sync::atomic::{AtomicU8, Ordering}; 17 17
+17 -10
crates/buttplug_server/src/device/protocol/hgod.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier, ProtocolCommunicationSpecifier}; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::{async_manager, sleep}, 10 - }; 11 8 use crate::device::{ 12 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 13 - protocol::{ 14 - generic_protocol_initializer_setup, 15 - ProtocolHandler, 16 - ProtocolIdentifier, 17 - ProtocolInitializer, 18 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 19 16 }; 20 17 use async_trait::async_trait; 18 + use buttplug_core::{ 19 + errors::ButtplugDeviceError, 20 + message::Endpoint, 21 + util::{async_manager, sleep}, 22 + }; 23 + use buttplug_server_device_config::{ 24 + DeviceDefinition, 25 + ProtocolCommunicationSpecifier, 26 + UserDeviceIdentifier, 27 + }; 21 28 use std::{ 22 29 sync::{ 23 30 atomic::{AtomicU8, Ordering},
+8 -6
crates/buttplug_server/src/device/protocol/hismith.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier, ProtocolCommunicationSpecifier}; 9 8 use crate::device::protocol::hismith_mini::HismithMiniInitializer; 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 9 use crate::device::{ 12 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 13 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 10 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 11 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 14 12 }; 15 13 use async_trait::async_trait; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 + use buttplug_server_device_config::{ 16 + DeviceDefinition, 17 + ProtocolCommunicationSpecifier, 18 + UserDeviceIdentifier, 19 + }; 16 20 use std::sync::Arc; 17 21 use uuid::{uuid, Uuid}; 18 22 ··· 95 99 pub struct Hismith {} 96 100 97 101 impl ProtocolHandler for Hismith { 98 - 99 - 100 102 fn handle_output_oscillate_cmd( 101 103 &self, 102 104 _feature_index: u32,
+11 -9
crates/buttplug_server/src/device/protocol/hismith_mini.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{Endpoint, FeatureType}, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 13 8 use crate::device::{ 14 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 15 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 9 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 10 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 16 11 }; 17 12 use async_trait::async_trait; 13 + use buttplug_core::{ 14 + errors::ButtplugDeviceError, 15 + message::{Endpoint, FeatureType}, 16 + }; 17 + use buttplug_server_device_config::{ 18 + DeviceDefinition, 19 + ProtocolCommunicationSpecifier, 20 + UserDeviceIdentifier, 21 + }; 18 22 use std::sync::Arc; 19 23 use uuid::{uuid, Uuid}; 20 24 ··· 103 107 } 104 108 105 109 impl ProtocolHandler for HismithMini { 106 - 107 - 108 110 fn handle_output_oscillate_cmd( 109 111 &self, 110 112 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/htk_bm.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const HTK_BM_PROTOCOL_UUID: Uuid = uuid!("4c70cb95-d3d9-4288-81ab-be845f9ad1fe"); 19 19 generic_protocol_setup!(HtkBm, "htk_bm"); ··· 31 31 } 32 32 33 33 impl ProtocolHandler for HtkBm { 34 - 35 - 36 34 fn handle_output_vibrate_cmd( 37 35 &self, 38 36 feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/itoys.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(IToys, "itoys"); 17 17 ··· 19 19 pub struct IToys {} 20 20 21 21 impl ProtocolHandler for IToys { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/jejoue.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const JEJOUE_PROTOCOL_UUID: Uuid = uuid!("d3dd2bf5-b029-4bc1-9466-39f82c2e3258"); 19 19 generic_protocol_setup!(JeJoue, "jejoue"); ··· 31 31 } 32 32 33 33 impl ProtocolHandler for JeJoue { 34 - 35 - 36 34 fn handle_output_vibrate_cmd( 37 35 &self, 38 36 feature_index: u32,
+3 -3
crates/buttplug_server/src/device/protocol/joyhub_v3.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{ProtocolHandler, generic_protocol_setup} 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(JoyHubV3, "joyhub-v3"); 17 17
+26 -13
crates/buttplug_server/src/device/protocol/kgoal_boost.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use crate::{ 9 + device::{ 10 + hardware::{Hardware, HardwareEvent, HardwareSubscribeCmd, HardwareUnsubscribeCmd}, 11 + protocol::{generic_protocol_setup, ProtocolHandler}, 12 + }, 13 + message::ButtplugServerDeviceMessage, 14 + }; 8 15 use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{Endpoint, InputReadingV4, InputType}, 11 - util::{async_manager, stream::convert_broadcast_receiver_to_stream}, 12 - }; 13 - use crate::{ 14 - device::{ 15 - hardware::{Hardware, HardwareEvent, HardwareSubscribeCmd, HardwareUnsubscribeCmd}, 16 - protocol::{generic_protocol_setup, ProtocolHandler}, 17 - }, 18 - message::ButtplugServerDeviceMessage, 19 - 16 + errors::ButtplugDeviceError, 17 + message::{Endpoint, InputReadingV4, InputType}, 18 + util::{async_manager, stream::convert_broadcast_receiver_to_stream}, 20 19 }; 21 20 use dashmap::DashSet; 22 21 use futures::{ ··· 100 99 let unnormalized = (data[5] as i32) << 8 | data[6] as i32; 101 100 if stream_sensors.contains(&0) 102 101 && sender 103 - .send(InputReadingV4::new(device_index, feature_index, InputType::Pressure, vec![normalized]).into()) 102 + .send( 103 + InputReadingV4::new( 104 + device_index, 105 + feature_index, 106 + InputType::Pressure, 107 + vec![normalized], 108 + ) 109 + .into(), 110 + ) 104 111 .is_err() 105 112 { 106 113 debug!( ··· 111 118 if stream_sensors.contains(&1) 112 119 && sender 113 120 .send( 114 - InputReadingV4::new(device_index, feature_index, InputType::Pressure, vec![unnormalized]).into(), 121 + InputReadingV4::new( 122 + device_index, 123 + feature_index, 124 + InputType::Pressure, 125 + vec![unnormalized], 126 + ) 127 + .into(), 115 128 ) 116 129 .is_err() 117 130 {
+12 -8
crates/buttplug_server/src/device/protocol/kiiroo_prowand.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{self, Endpoint, InputReadingV4, InputType}, 11 - }; 12 8 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 14 - protocol::{generic_protocol_setup, ProtocolHandler}, 9 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler}, 11 + }; 12 + use buttplug_core::{ 13 + errors::ButtplugDeviceError, 14 + message::{self, Endpoint, InputReadingV4, InputType}, 15 15 }; 16 16 use futures::{future::BoxFuture, FutureExt}; 17 17 use std::{default::Default, sync::Arc}; ··· 59 59 let hw_msg = fut.await?; 60 60 let data = hw_msg.data(); 61 61 let battery_level = data[0] as i32; 62 - let battery_reading = 63 - message::InputReadingV4::new(device_index, feature_index, InputType::Battery, vec![battery_level]); 62 + let battery_reading = message::InputReadingV4::new( 63 + device_index, 64 + feature_index, 65 + InputType::Battery, 66 + vec![battery_level], 67 + ); 64 68 debug!("Got battery reading: {}", battery_level); 65 69 Ok(battery_reading) 66 70 }
+12 -8
crates/buttplug_server/src/device/protocol/kiiroo_spot.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{self, Endpoint, InputReadingV4, InputType}, 11 - }; 12 8 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 14 - protocol::{generic_protocol_setup, ProtocolHandler}, 9 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler}, 11 + }; 12 + use buttplug_core::{ 13 + errors::ButtplugDeviceError, 14 + message::{self, Endpoint, InputReadingV4, InputType}, 15 15 }; 16 16 use futures::{future::BoxFuture, FutureExt}; 17 17 use std::{default::Default, sync::Arc}; ··· 52 52 let hw_msg = fut.await?; 53 53 let data = hw_msg.data(); 54 54 let battery_level = data[0] as i32; 55 - let battery_reading = 56 - message::InputReadingV4::new(device_index, feature_index, InputType::Battery, vec![battery_level]); 55 + let battery_reading = message::InputReadingV4::new( 56 + device_index, 57 + feature_index, 58 + InputType::Battery, 59 + vec![battery_level], 60 + ); 57 61 debug!("Got battery reading: {}", battery_level); 58 62 Ok(battery_reading) 59 63 }
+14 -12
crates/buttplug_server/src/device/protocol/kiiroo_v2.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - fleshlight_launch_helper::calculate_speed, 14 - generic_protocol_initializer_setup, 15 - ProtocolHandler, 16 - ProtocolIdentifier, 17 - ProtocolInitializer, 18 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + fleshlight_launch_helper::calculate_speed, 12 + generic_protocol_initializer_setup, 13 + ProtocolHandler, 14 + ProtocolIdentifier, 15 + ProtocolInitializer, 16 + }, 19 17 }; 20 18 use async_trait::async_trait; 19 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 + use buttplug_server_device_config::{ 21 + DeviceDefinition, 22 + ProtocolCommunicationSpecifier, 23 + UserDeviceIdentifier, 24 + }; 21 25 use std::sync::{ 22 26 atomic::{AtomicU8, Ordering}, 23 27 Arc, ··· 54 58 } 55 59 56 60 impl ProtocolHandler for KiirooV2 { 57 - 58 - 59 61 fn handle_position_with_duration_cmd( 60 62 &self, 61 63 _feature_index: u32,
+28 -22
crates/buttplug_server/src/device/protocol/kiiroo_v21.rs
··· 6 6 // for full license information. 7 7 8 8 use super::fleshlight_launch_helper::calculate_speed; 9 - use buttplug_core::{ 10 - errors::ButtplugDeviceError, 11 - message::{Endpoint, InputReadingV4, InputType}, 12 - util::{async_manager, stream::convert_broadcast_receiver_to_stream}, 13 - }; 14 9 use crate::{ 15 - device::{ 16 - hardware::{ 17 - Hardware, 18 - HardwareCommand, 19 - HardwareEvent, 20 - HardwareReadCmd, 21 - HardwareSubscribeCmd, 22 - HardwareUnsubscribeCmd, 23 - HardwareWriteCmd, 24 - }, 25 - protocol::{generic_protocol_setup, ProtocolHandler}, 10 + device::{ 11 + hardware::{ 12 + Hardware, 13 + HardwareCommand, 14 + HardwareEvent, 15 + HardwareReadCmd, 16 + HardwareSubscribeCmd, 17 + HardwareUnsubscribeCmd, 18 + HardwareWriteCmd, 26 19 }, 27 - message::ButtplugServerDeviceMessage, 28 - 20 + protocol::{generic_protocol_setup, ProtocolHandler}, 21 + }, 22 + message::ButtplugServerDeviceMessage, 23 + }; 24 + use buttplug_core::{ 25 + errors::ButtplugDeviceError, 26 + message::{Endpoint, InputReadingV4, InputType}, 27 + util::{async_manager, stream::convert_broadcast_receiver_to_stream}, 29 28 }; 30 29 use dashmap::DashSet; 31 30 use futures::{ ··· 125 124 )); 126 125 } 127 126 let battery_level = data[5] as i32; 128 - let battery_reading = 129 - InputReadingV4::new(device_index, feature_index, InputType::Battery, vec![battery_level]); 127 + let battery_reading = InputReadingV4::new( 128 + device_index, 129 + feature_index, 130 + InputType::Battery, 131 + vec![battery_level], 132 + ); 130 133 debug!("Got battery reading: {}", battery_level); 131 134 Ok(battery_reading) 132 135 } ··· 141 144 142 145 fn handle_input_subscribe_cmd( 143 146 &self, 144 - device_index: u32, 147 + device_index: u32, 145 148 device: Arc<Hardware>, 146 149 feature_index: u32, 147 150 feature_id: Uuid, ··· 199 202 { 200 203 if stream_sensors.contains(&sensor_index) 201 204 && sender 202 - .send(InputReadingV4::new(device_index, sensor_index, sensor_type, sensor_data).into()) 205 + .send( 206 + InputReadingV4::new(device_index, sensor_index, sensor_type, sensor_data) 207 + .into(), 208 + ) 203 209 .is_err() 204 210 { 205 211 debug!(
+14 -12
crates/buttplug_server/src/device/protocol/kiiroo_v21_initialized.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - fleshlight_launch_helper::calculate_speed, 14 - generic_protocol_initializer_setup, 15 - ProtocolHandler, 16 - ProtocolIdentifier, 17 - ProtocolInitializer, 18 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + fleshlight_launch_helper::calculate_speed, 12 + generic_protocol_initializer_setup, 13 + ProtocolHandler, 14 + ProtocolIdentifier, 15 + ProtocolInitializer, 16 + }, 19 17 }; 20 18 use async_trait::async_trait; 19 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 + use buttplug_server_device_config::{ 21 + DeviceDefinition, 22 + ProtocolCommunicationSpecifier, 23 + UserDeviceIdentifier, 24 + }; 21 25 use std::sync::{ 22 26 atomic::{AtomicU8, Ordering}, 23 27 Arc, ··· 65 69 } 66 70 67 71 impl ProtocolHandler for KiirooV21Initialized { 68 - 69 - 70 72 fn handle_output_vibrate_cmd( 71 73 &self, 72 74 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/kiiroo_v2_vibrator.rs
··· 9 9 10 10 use uuid::Uuid; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 generic_protocol_setup!(KiirooV2Vibrator, "kiiroo-v2-vibrator"); 19 19 ··· 30 30 } 31 31 32 32 impl ProtocolHandler for KiirooV2Vibrator { 33 - 34 - 35 33 fn handle_output_vibrate_cmd( 36 34 &self, 37 35 feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/kizuna.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Kizuna, "kizuna"); 17 17 ··· 19 19 pub struct Kizuna {} 20 20 21 21 impl ProtocolHandler for Kizuna { 22 - 23 - 24 22 fn handle_output_rotate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+20 -16
crates/buttplug_server/src/device/protocol/lelo_harmony.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{ 12 - Hardware, 13 - HardwareCommand, 14 - HardwareEvent, 15 - HardwareSubscribeCmd, 16 - HardwareUnsubscribeCmd, 17 - HardwareWriteCmd, 18 - }, 19 - protocol::{ 20 - generic_protocol_initializer_setup, 21 - ProtocolHandler, 22 - ProtocolIdentifier, 23 - ProtocolInitializer, 24 - }, 9 + hardware::{ 10 + Hardware, 11 + HardwareCommand, 12 + HardwareEvent, 13 + HardwareSubscribeCmd, 14 + HardwareUnsubscribeCmd, 15 + HardwareWriteCmd, 16 + }, 17 + protocol::{ 18 + generic_protocol_initializer_setup, 19 + ProtocolHandler, 20 + ProtocolIdentifier, 21 + ProtocolInitializer, 22 + }, 25 23 }; 26 24 use async_trait::async_trait; 25 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 26 + use buttplug_server_device_config::{ 27 + DeviceDefinition, 28 + ProtocolCommunicationSpecifier, 29 + UserDeviceIdentifier, 30 + }; 27 31 use std::sync::Arc; 28 32 use uuid::{uuid, Uuid}; 29 33
+13 -9
crates/buttplug_server/src/device/protocol/lelof1s.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareSubscribeCmd, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareSubscribeCmd, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::{ 21 25 atomic::{AtomicU8, Ordering}, 22 26 Arc,
+21 -17
crates/buttplug_server/src/device/protocol/lelof1sv2.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{ 12 - Hardware, 13 - HardwareEvent, 14 - HardwareSubscribeCmd, 15 - HardwareUnsubscribeCmd, 16 - HardwareWriteCmd, 17 - }, 18 - protocol::{ 19 - generic_protocol_initializer_setup, 20 - lelo_harmony::LeloHarmony, 21 - lelof1s::LeloF1s, 22 - ProtocolHandler, 23 - ProtocolIdentifier, 24 - ProtocolInitializer, 25 - }, 9 + hardware::{ 10 + Hardware, 11 + HardwareEvent, 12 + HardwareSubscribeCmd, 13 + HardwareUnsubscribeCmd, 14 + HardwareWriteCmd, 15 + }, 16 + protocol::{ 17 + generic_protocol_initializer_setup, 18 + lelo_harmony::LeloHarmony, 19 + lelof1s::LeloF1s, 20 + ProtocolHandler, 21 + ProtocolIdentifier, 22 + ProtocolInitializer, 23 + }, 26 24 }; 27 25 use async_trait::async_trait; 26 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 27 + use buttplug_server_device_config::{ 28 + DeviceDefinition, 29 + ProtocolCommunicationSpecifier, 30 + UserDeviceIdentifier, 31 + }; 28 32 use std::sync::Arc; 29 33 use uuid::{uuid, Uuid}; 30 34
+16 -10
crates/buttplug_server/src/device/protocol/leten.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use std::time::Duration; 22 26 use uuid::{uuid, Uuid}; ··· 57 61 impl ProtocolHandler for Leten { 58 62 fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy { 59 63 // Leten keepalive is shorter 60 - super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis(LETEN_COMMAND_DELAY_MS)) 64 + super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis( 65 + LETEN_COMMAND_DELAY_MS, 66 + )) 61 67 } 62 68 63 69 fn handle_output_vibrate_cmd(
+3 -5
crates/buttplug_server/src/device/protocol/libo_elle.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(LiboElle, "libo-elle"); 17 17 ··· 19 19 pub struct LiboElle {} 20 20 21 21 impl ProtocolHandler for LiboElle { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/libo_shark.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const LIBO_SHARK_PROTOCOL_UUID: Uuid = uuid!("c0044425-b59c-4037-a702-0438afcaad3e"); 19 19 generic_protocol_setup!(LiboShark, "libo-shark"); ··· 24 24 } 25 25 26 26 impl ProtocolHandler for LiboShark { 27 - 28 - 29 27 fn handle_output_vibrate_cmd( 30 28 &self, 31 29 feature_index: u32,
+10 -7
crates/buttplug_server/src/device/protocol/libo_vibes.rs
··· 7 7 8 8 use uuid::{uuid, Uuid}; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 const LIBO_VIBES_PROTOCOL_UUID: Uuid = uuid!("72a3d029-cf33-4fff-beec-1c45b85cc8ae"); 17 17 generic_protocol_setup!(LiboVibes, "libo-vibes"); ··· 20 20 pub struct LiboVibes {} 21 21 22 22 impl ProtocolHandler for LiboVibes { 23 - 24 - 25 23 fn handle_output_vibrate_cmd( 26 24 &self, 27 25 feature_index: u32, ··· 42 40 // If this is a single vibe device, we need to send stop to TxMode too 43 41 if speed as u8 == 0 { 44 42 msg_vec.push( 45 - HardwareWriteCmd::new(&[LIBO_VIBES_PROTOCOL_UUID], Endpoint::TxMode, vec![0u8], false) 46 - .into(), 43 + HardwareWriteCmd::new( 44 + &[LIBO_VIBES_PROTOCOL_UUID], 45 + Endpoint::TxMode, 46 + vec![0u8], 47 + false, 48 + ) 49 + .into(), 47 50 ); 48 51 } 49 52 } else if feature_index == 1 {
+13 -11
crates/buttplug_server/src/device/protocol/lioness.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareSubscribeCmd, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareSubscribeCmd, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use uuid::{uuid, Uuid}; 22 26 ··· 62 66 pub struct Lioness {} 63 67 64 68 impl ProtocolHandler for Lioness { 65 - 66 - 67 69 fn handle_output_vibrate_cmd( 68 70 &self, 69 71 _feature_index: u32,
+13 -9
crates/buttplug_server/src/device/protocol/loob.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::cmp::{max, min}; 21 25 use std::sync::Arc; 22 26 use uuid::{uuid, Uuid};
+13 -11
crates/buttplug_server/src/device/protocol/lovedistance.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use uuid::{uuid, Uuid}; 22 26 ··· 55 59 pub struct LoveDistance {} 56 60 57 61 impl ProtocolHandler for LoveDistance { 58 - 59 - 60 62 fn handle_output_vibrate_cmd( 61 63 &self, 62 64 _feature_index: u32,
+62 -23
crates/buttplug_server/src/device/protocol/lovehoney_desire.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 8 + use std::sync::{ 9 + atomic::{AtomicU8, Ordering}, 10 + Arc, 11 + }; 9 12 10 13 use async_trait::async_trait; 11 14 use uuid::{uuid, Uuid}; 12 15 13 - use buttplug_core::{ 14 - errors::ButtplugDeviceError, 15 - message::Endpoint, 16 - }; 17 16 use crate::device::{ 18 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 19 - protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolInitializer, DeviceDefinition, ProtocolIdentifier, ProtocolCommunicationSpecifier, UserDeviceIdentifier}, 17 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 18 + protocol::{ 19 + generic_protocol_initializer_setup, 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + ProtocolHandler, 23 + ProtocolIdentifier, 24 + ProtocolInitializer, 25 + UserDeviceIdentifier, 26 + }, 20 27 }; 28 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 21 29 22 30 const LOVEHONEY_DESIRE_PROTOCOL_UUID: Uuid = uuid!("5dcd8487-4814-44cb-a768-13bf81d545c0"); 23 31 const LOVEHONEY_DESIRE_VIBE2_PROTOCOL_UUID: Uuid = uuid!("d44a99fe-903b-4fff-bee7-1141767c9cca"); ··· 34 42 _: Arc<Hardware>, 35 43 def: &DeviceDefinition, 36 44 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 37 - Ok(Arc::new(LovehoneyDesire::new(def 38 - .features() 39 - .iter() 40 - .filter(|x| x.output().is_some()) 41 - .count() as u8))) 45 + Ok(Arc::new(LovehoneyDesire::new( 46 + def 47 + .features() 48 + .iter() 49 + .filter(|x| x.output().is_some()) 50 + .count() as u8, 51 + ))) 42 52 } 43 53 } 44 54 45 55 pub struct LovehoneyDesire { 46 - current_commands: Vec<AtomicU8> 56 + current_commands: Vec<AtomicU8>, 47 57 } 48 58 49 59 impl LovehoneyDesire { 50 60 fn new(num_vibrators: u8) -> Self { 51 61 Self { 52 - current_commands: std::iter::repeat_with(|| AtomicU8::default()).take(num_vibrators as usize).collect() 62 + current_commands: std::iter::repeat_with(|| AtomicU8::default()) 63 + .take(num_vibrators as usize) 64 + .collect(), 53 65 } 54 66 } 55 67 } 56 68 57 69 impl ProtocolHandler for LovehoneyDesire { 58 70 fn handle_output_vibrate_cmd( 59 - &self, 60 - feature_index: u32, 61 - _feature_id: Uuid, 62 - speed: u32, 63 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 71 + &self, 72 + feature_index: u32, 73 + _feature_id: Uuid, 74 + speed: u32, 75 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 64 76 // The Lovehoney Desire has 2 types of commands 65 77 // 66 78 // - Set both motors with one command ··· 69 81 // We'll need to check what we got back and write our 70 82 // commands accordingly. 71 83 if self.current_commands.len() == 1 { 72 - Ok(vec![HardwareWriteCmd::new(&[LOVEHONEY_DESIRE_PROTOCOL_UUID], Endpoint::Tx, vec![0xF3, 0, speed as u8], true).into()]) 84 + Ok(vec![HardwareWriteCmd::new( 85 + &[LOVEHONEY_DESIRE_PROTOCOL_UUID], 86 + Endpoint::Tx, 87 + vec![0xF3, 0, speed as u8], 88 + true, 89 + ) 90 + .into()]) 73 91 } else { 74 92 self.current_commands[feature_index as usize].store(speed as u8, Ordering::Relaxed); 75 93 let speed0 = self.current_commands[0].load(Ordering::Relaxed); 76 94 let speed1 = self.current_commands[1].load(Ordering::Relaxed); 77 95 if speed0 == speed1 { 78 - Ok(vec![HardwareWriteCmd::new(&[LOVEHONEY_DESIRE_PROTOCOL_UUID, LOVEHONEY_DESIRE_VIBE2_PROTOCOL_UUID], Endpoint::Tx, vec![0xF3, 0, speed0 as u8], true).into()]) 96 + Ok(vec![HardwareWriteCmd::new( 97 + &[ 98 + LOVEHONEY_DESIRE_PROTOCOL_UUID, 99 + LOVEHONEY_DESIRE_VIBE2_PROTOCOL_UUID, 100 + ], 101 + Endpoint::Tx, 102 + vec![0xF3, 0, speed0 as u8], 103 + true, 104 + ) 105 + .into()]) 79 106 } else { 80 107 Ok(vec![ 81 - HardwareWriteCmd::new(&[LOVEHONEY_DESIRE_PROTOCOL_UUID], Endpoint::Tx, vec![0xF3, 1, speed0 as u8], true).into(), 82 - HardwareWriteCmd::new(&[LOVEHONEY_DESIRE_VIBE2_PROTOCOL_UUID], Endpoint::Tx, vec![0xF3, 2, speed1 as u8], true).into(), 108 + HardwareWriteCmd::new( 109 + &[LOVEHONEY_DESIRE_PROTOCOL_UUID], 110 + Endpoint::Tx, 111 + vec![0xF3, 1, speed0 as u8], 112 + true, 113 + ) 114 + .into(), 115 + HardwareWriteCmd::new( 116 + &[LOVEHONEY_DESIRE_VIBE2_PROTOCOL_UUID], 117 + Endpoint::Tx, 118 + vec![0xF3, 2, speed1 as u8], 119 + true, 120 + ) 121 + .into(), 83 122 ]) 84 123 } 85 124 }
+12 -11
crates/buttplug_server/src/device/protocol/lovense/lovense_max.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::InputReadingV4, 11 - }; 12 8 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand}, 14 - protocol::{lovense::{form_lovense_command, form_vibrate_command}, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{Hardware, HardwareCommand}, 10 + protocol::{ 11 + lovense::{form_lovense_command, form_vibrate_command}, 12 + ProtocolHandler, 13 + ProtocolKeepaliveStrategy, 14 + }, 15 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::InputReadingV4}; 16 17 use futures::future::BoxFuture; 17 18 use std::sync::Arc; 18 19 use uuid::Uuid; ··· 35 36 } 36 37 37 38 fn handle_output_oscillate_cmd( 38 - &self, 39 - _feature_index: u32, 40 - feature_id: Uuid, 41 - speed: u32, 42 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 39 + &self, 40 + _feature_index: u32, 41 + feature_id: Uuid, 42 + speed: u32, 43 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 43 44 form_vibrate_command(feature_id, speed) 44 45 } 45 46
+15 -13
crates/buttplug_server/src/device/protocol/lovense/lovense_multi_actuator.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{Endpoint, InputReadingV4}, 11 - }; 12 8 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 14 - protocol::{lovense::form_vibrate_command, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{lovense::form_vibrate_command, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + }; 12 + use buttplug_core::{ 13 + errors::ButtplugDeviceError, 14 + message::{Endpoint, InputReadingV4}, 15 15 }; 16 16 use futures::future::BoxFuture; 17 - use std::{sync::{atomic::AtomicU32, Arc}}; 17 + use std::sync::{atomic::AtomicU32, Arc}; 18 18 use uuid::Uuid; 19 19 20 20 #[derive(Default)] ··· 25 25 impl LovenseMultiActuator { 26 26 pub fn new(num_vibrators: u32) -> Self { 27 27 Self { 28 - _vibrator_values: std::iter::repeat_with(|| AtomicU32::new(0)).take(num_vibrators as usize).collect() 28 + _vibrator_values: std::iter::repeat_with(|| AtomicU32::new(0)) 29 + .take(num_vibrators as usize) 30 + .collect(), 29 31 } 30 32 } 31 33 } ··· 54 56 } 55 57 56 58 fn handle_output_oscillate_cmd( 57 - &self, 58 - _feature_index: u32, 59 - feature_id: Uuid, 60 - speed: u32, 61 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 59 + &self, 60 + _feature_index: u32, 61 + feature_id: Uuid, 62 + speed: u32, 63 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 62 64 form_vibrate_command(feature_id, speed) 63 65 } 64 66
+12 -8
crates/buttplug_server/src/device/protocol/lovense/lovense_rotate_vibrator.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::InputReadingV4, 11 - }; 12 8 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand}, 14 - protocol::{lovense::{form_rotate_with_direction_command, form_vibrate_command}, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{Hardware, HardwareCommand}, 10 + protocol::{ 11 + lovense::{form_rotate_with_direction_command, form_vibrate_command}, 12 + ProtocolHandler, 13 + ProtocolKeepaliveStrategy, 14 + }, 15 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::InputReadingV4}; 16 17 use futures::future::BoxFuture; 17 - use std::sync::{atomic::{AtomicBool, Ordering}, Arc}; 18 + use std::sync::{ 19 + atomic::{AtomicBool, Ordering}, 20 + Arc, 21 + }; 18 22 use uuid::Uuid; 19 23 20 24 #[derive(Default)] 21 25 pub struct LovenseRotateVibrator { 22 - clockwise: AtomicBool 26 + clockwise: AtomicBool, 23 27 } 24 28 25 29 impl ProtocolHandler for LovenseRotateVibrator {
+8 -11
crates/buttplug_server/src/device/protocol/lovense/lovense_single_actuator.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::InputReadingV4, 11 - }; 12 8 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand}, 14 - protocol::{lovense::form_vibrate_command, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{Hardware, HardwareCommand}, 10 + protocol::{lovense::form_vibrate_command, ProtocolHandler, ProtocolKeepaliveStrategy}, 15 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::InputReadingV4}; 16 13 use futures::future::BoxFuture; 17 14 use std::sync::Arc; 18 15 use uuid::Uuid; ··· 35 32 } 36 33 37 34 fn handle_output_oscillate_cmd( 38 - &self, 39 - _feature_index: u32, 40 - feature_id: Uuid, 41 - speed: u32, 42 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 35 + &self, 36 + _feature_index: u32, 37 + feature_id: Uuid, 38 + speed: u32, 39 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 43 40 form_vibrate_command(feature_id, speed) 44 41 } 45 42
+9 -11
crates/buttplug_server/src/device/protocol/lovense/lovense_stroker.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{Endpoint, InputReadingV4}, 11 - util::{async_manager, sleep}, 12 - }; 13 8 use crate::device::{ 14 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 15 - protocol::{ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ProtocolHandler, ProtocolKeepaliveStrategy}, 16 11 }; 17 - use futures::{future::BoxFuture}; 12 + use buttplug_core::{ 13 + errors::ButtplugDeviceError, 14 + message::{Endpoint, InputReadingV4}, 15 + util::{async_manager, sleep}, 16 + }; 17 + use futures::future::BoxFuture; 18 18 use std::{ 19 19 sync::{ 20 20 atomic::{AtomicU32, Ordering}, ··· 37 37 hardware.clone(), 38 38 linear_info.clone(), 39 39 )); 40 - Self { 41 - linear_info 42 - } 40 + Self { linear_info } 43 41 } 44 42 } 45 43
+88 -44
crates/buttplug_server/src/device/protocol/lovense/mod.rs
··· 6 6 // for full license information. 7 7 8 8 mod lovense_max; 9 + mod lovense_multi_actuator; 9 10 mod lovense_rotate_vibrator; 10 11 mod lovense_single_actuator; 11 - mod lovense_multi_actuator; 12 12 mod lovense_stroker; 13 13 14 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 15 - use buttplug_core::{ 16 - errors::ButtplugDeviceError, 17 - message::{self, Endpoint, FeatureType, InputReadingV4}, 18 - util::sleep 19 - }; 20 14 use crate::device::{ 21 - hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 22 - protocol::{lovense::{lovense_max::LovenseMax, lovense_multi_actuator::LovenseMultiActuator, lovense_rotate_vibrator::LovenseRotateVibrator, lovense_single_actuator::LovenseSingleActuator, lovense_stroker::LovenseStroker}, ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 15 + hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 16 + protocol::{ 17 + lovense::{ 18 + lovense_max::LovenseMax, 19 + lovense_multi_actuator::LovenseMultiActuator, 20 + lovense_rotate_vibrator::LovenseRotateVibrator, 21 + lovense_single_actuator::LovenseSingleActuator, 22 + lovense_stroker::LovenseStroker, 23 + }, 24 + ProtocolHandler, 25 + ProtocolIdentifier, 26 + ProtocolInitializer, 27 + }, 23 28 }; 24 - use regex::Regex; 25 29 use async_trait::async_trait; 26 - use futures::{future::BoxFuture, FutureExt}; 27 - use std::{ 28 - sync::{ 29 - Arc, 30 - }, 31 - time::Duration, 30 + use buttplug_core::{ 31 + errors::ButtplugDeviceError, 32 + message::{self, Endpoint, FeatureType, InputReadingV4}, 33 + util::sleep, 34 + }; 35 + use buttplug_server_device_config::{ 36 + DeviceDefinition, 37 + ProtocolCommunicationSpecifier, 38 + UserDeviceIdentifier, 32 39 }; 40 + use futures::{future::BoxFuture, FutureExt}; 41 + use regex::Regex; 42 + use std::{sync::Arc, time::Duration}; 33 43 use tokio::select; 34 44 use uuid::{uuid, Uuid}; 35 45 ··· 173 183 .filter(|x| x.output().is_some()) 174 184 .count(); 175 185 176 - let vibrator_rotator = output_count == 2 && 177 - device_definition.features().iter().filter(|x| x.feature_type() == FeatureType::Vibrate).count() == 1 && 178 - device_definition.features().iter().filter(|x| x.feature_type() == FeatureType::RotateWithDirection).count() == 1; 186 + let vibrator_rotator = output_count == 2 187 + && device_definition 188 + .features() 189 + .iter() 190 + .filter(|x| x.feature_type() == FeatureType::Vibrate) 191 + .count() 192 + == 1 193 + && device_definition 194 + .features() 195 + .iter() 196 + .filter(|x| x.feature_type() == FeatureType::RotateWithDirection) 197 + .count() 198 + == 1; 179 199 180 - let lovense_max = output_count == 2 && 181 - device_definition.features().iter().filter(|x| x.feature_type() == FeatureType::Vibrate).count() == 1 && 182 - device_definition.features().iter().filter(|x| x.feature_type() == FeatureType::Constrict).count() == 1; 200 + let lovense_max = output_count == 2 201 + && device_definition 202 + .features() 203 + .iter() 204 + .filter(|x| x.feature_type() == FeatureType::Vibrate) 205 + .count() 206 + == 1 207 + && device_definition 208 + .features() 209 + .iter() 210 + .filter(|x| x.feature_type() == FeatureType::Constrict) 211 + .count() 212 + == 1; 183 213 184 214 // This might need better tuning if other complex Lovenses are released 185 215 // Currently this only applies to the Flexer/Lapis/Solace ··· 206 236 } else if vibrator_rotator { 207 237 Ok(Arc::new(LovenseRotateVibrator::default())) 208 238 } else { 209 - Ok(Arc::new(LovenseMultiActuator::new( 210 - vibrator_count as u32, 211 - ))) 239 + Ok(Arc::new(LovenseMultiActuator::new(vibrator_count as u32))) 212 240 } 213 241 } 214 242 } ··· 410 438 */ 411 439 412 440 fn handle_battery_level_cmd( 413 - device_index: u32, 414 - device: Arc<Hardware>, 415 - feature_index: u32, 416 - feature_id: Uuid, 417 - ) -> BoxFuture<'static, Result<InputReadingV4, ButtplugDeviceError>> { 441 + device_index: u32, 442 + device: Arc<Hardware>, 443 + feature_index: u32, 444 + feature_id: Uuid, 445 + ) -> BoxFuture<'static, Result<InputReadingV4, ButtplugDeviceError>> { 418 446 let mut device_notification_receiver = device.event_stream(); 419 447 async move { 420 448 let write_fut = device.write_value(&HardwareWriteCmd::new( ··· 475 503 )) 476 504 } 477 505 478 - pub(super) fn form_lovense_command(feature_id: Uuid, command: &str) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 506 + pub(super) fn form_lovense_command( 507 + feature_id: Uuid, 508 + command: &str, 509 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 479 510 Ok(vec![HardwareWriteCmd::new( 480 511 &[feature_id], 481 512 Endpoint::Tx, ··· 485 516 .into()]) 486 517 } 487 518 488 - pub(super) fn form_vibrate_command(feature_id: Uuid, speed: u32) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 519 + pub(super) fn form_vibrate_command( 520 + feature_id: Uuid, 521 + speed: u32, 522 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 489 523 form_lovense_command(feature_id, &format!("Vibrate:{speed};")) 490 524 } 491 525 492 526 // Due to swapping direction with lovense requiring a seperate command, we have to treat these like 493 527 // two seperate outputs, otherwise we'll stomp on ourselves. Luckily Lovense devices currently only 494 - // have one rotation mechanism. 528 + // have one rotation mechanism. 495 529 const LOVENSE_ROTATE_UUID: Uuid = uuid!("4a741489-922f-4f0b-a594-175b75482849"); 496 530 const LOVENSE_ROTATE_DIRECTION_UUID: Uuid = uuid!("4ad23456-2ba8-4916-bd91-9b603811f253"); 497 531 498 - pub(super) fn form_rotate_with_direction_command(speed: u32, change_direction: bool) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 532 + pub(super) fn form_rotate_with_direction_command( 533 + speed: u32, 534 + change_direction: bool, 535 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 499 536 let mut hardware_cmds = vec![]; 500 - let lovense_cmd = format!("Rotate:{speed};").as_bytes().to_vec(); 501 - hardware_cmds.push(HardwareWriteCmd::new(&[LOVENSE_ROTATE_UUID], Endpoint::Tx, lovense_cmd, false).into()); 502 - if change_direction { 503 - hardware_cmds.push( 504 - HardwareWriteCmd::new(&[LOVENSE_ROTATE_DIRECTION_UUID], Endpoint::Tx, b"RotateChange;".to_vec(), false).into(), 505 - ); 506 - } 507 - trace!("{:?}", hardware_cmds); 508 - Ok(hardware_cmds) 509 - } 537 + let lovense_cmd = format!("Rotate:{speed};").as_bytes().to_vec(); 538 + hardware_cmds 539 + .push(HardwareWriteCmd::new(&[LOVENSE_ROTATE_UUID], Endpoint::Tx, lovense_cmd, false).into()); 540 + if change_direction { 541 + hardware_cmds.push( 542 + HardwareWriteCmd::new( 543 + &[LOVENSE_ROTATE_DIRECTION_UUID], 544 + Endpoint::Tx, 545 + b"RotateChange;".to_vec(), 546 + false, 547 + ) 548 + .into(), 549 + ); 550 + } 551 + trace!("{:?}", hardware_cmds); 552 + Ok(hardware_cmds) 553 + }
+3 -5
crates/buttplug_server/src/device/protocol/lovenuts.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(LoveNuts, "lovenuts"); 17 17 ··· 19 19 pub struct LoveNuts {} 20 20 21 21 impl ProtocolHandler for LoveNuts { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/luvmazer.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::ProtocolHandler, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::ProtocolHandler, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 use super::generic_protocol_setup; 17 17 ··· 21 21 pub struct Luvmazer {} 22 22 23 23 impl ProtocolHandler for Luvmazer { 24 - 25 - 26 24 fn handle_output_vibrate_cmd( 27 25 &self, 28 26 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/magic_motion_v1.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(MagicMotionV1, "magic-motion-1"); 17 17 ··· 19 19 pub struct MagicMotionV1 {} 20 20 21 21 impl ProtocolHandler for MagicMotionV1 { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -4
crates/buttplug_server/src/device/protocol/magic_motion_v2.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 12 use crate::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 16 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 17 18 18 const MAGIC_MOTION_2_PROTOCOL_UUID: Uuid = uuid!("4d6e9297-c57e-4ce7-a63c-24cc7d117a47"); 19 19 ··· 32 32 } 33 33 34 34 impl ProtocolHandler for MagicMotionV2 { 35 - 36 35 fn handle_output_vibrate_cmd( 37 36 &self, 38 37 feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/magic_motion_v3.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(MagicMotionV3, "magic-motion-3"); 17 17 ··· 19 19 pub struct MagicMotionV3 {} 20 20 21 21 impl ProtocolHandler for MagicMotionV3 { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+40 -37
crates/buttplug_server/src/device/protocol/magic_motion_v4.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 8 + use std::sync::{ 9 + atomic::{AtomicU8, Ordering}, 10 + Arc, 11 + }; 9 12 10 13 use async_trait::async_trait; 11 14 use uuid::{uuid, Uuid}; 12 15 13 - use buttplug_core::{ 14 - errors::ButtplugDeviceError, 15 - message::Endpoint, 16 - }; 17 16 use crate::device::{ 18 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 19 - protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolInitializer, DeviceDefinition, ProtocolIdentifier, ProtocolCommunicationSpecifier, UserDeviceIdentifier}, 17 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 18 + protocol::{ 19 + generic_protocol_initializer_setup, 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + ProtocolHandler, 23 + ProtocolIdentifier, 24 + ProtocolInitializer, 25 + UserDeviceIdentifier, 26 + }, 20 27 }; 28 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 21 29 22 30 const MAGICMOTIONV4_PROTOCOL_UUID: Uuid = uuid!("d4d62d09-c3e1-44c9-8eba-caa15de5b2a7"); 23 31 ··· 33 41 _: Arc<Hardware>, 34 42 def: &DeviceDefinition, 35 43 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 36 - Ok(Arc::new(MagicMotionV4::new(def 37 - .features() 38 - .iter() 39 - .filter(|x| x.output().is_some()) 40 - .count() as u8))) 44 + Ok(Arc::new(MagicMotionV4::new( 45 + def 46 + .features() 47 + .iter() 48 + .filter(|x| x.output().is_some()) 49 + .count() as u8, 50 + ))) 41 51 } 42 52 } 43 53 44 54 pub struct MagicMotionV4 { 45 - current_commands: Vec<AtomicU8> 55 + current_commands: Vec<AtomicU8>, 46 56 } 47 57 48 58 impl MagicMotionV4 { 49 59 fn new(num_vibrators: u8) -> Self { 50 60 Self { 51 - current_commands: std::iter::repeat_with(|| AtomicU8::default()).take(num_vibrators as usize).collect() 61 + current_commands: std::iter::repeat_with(|| AtomicU8::default()) 62 + .take(num_vibrators as usize) 63 + .collect(), 52 64 } 53 65 } 54 66 } 55 67 56 68 impl ProtocolHandler for MagicMotionV4 { 57 69 fn handle_output_vibrate_cmd( 58 - &self, 59 - feature_index: u32, 60 - _feature_id: Uuid, 61 - speed: u32, 62 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 70 + &self, 71 + feature_index: u32, 72 + _feature_id: Uuid, 73 + speed: u32, 74 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 63 75 let data = if self.current_commands.len() == 1 { 64 76 vec![ 65 77 0x10, ··· 85 97 let speed0 = self.current_commands[0].load(Ordering::Relaxed); 86 98 let speed1 = self.current_commands[1].load(Ordering::Relaxed); 87 99 vec![ 88 - 0x10, 89 - 0xff, 90 - 0x04, 91 - 0x0a, 92 - 0x32, 93 - 0x32, 94 - 0x00, 95 - 0x04, 96 - 0x08, 97 - speed0, 98 - 0x64, 99 - 0x00, 100 - 0x04, 101 - 0x08, 102 - speed1, 103 - 0x64, 104 - 0x01, 100 + 0x10, 0xff, 0x04, 0x0a, 0x32, 0x32, 0x00, 0x04, 0x08, speed0, 0x64, 0x00, 0x04, 0x08, 101 + speed1, 0x64, 0x01, 105 102 ] 106 103 }; 107 - Ok(vec![HardwareWriteCmd::new(&[MAGICMOTIONV4_PROTOCOL_UUID], Endpoint::Tx, data, true).into()]) 104 + Ok(vec![HardwareWriteCmd::new( 105 + &[MAGICMOTIONV4_PROTOCOL_UUID], 106 + Endpoint::Tx, 107 + data, 108 + true, 109 + ) 110 + .into()]) 108 111 } 109 112 }
+3 -5
crates/buttplug_server/src/device/protocol/mannuo.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(ManNuo, "mannuo"); 17 17 ··· 19 19 pub struct ManNuo {} 20 20 21 21 impl ProtocolHandler for ManNuo { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/maxpro.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Maxpro, "maxpro"); 17 17 ··· 19 19 pub struct Maxpro {} 20 20 21 21 impl ProtocolHandler for Maxpro { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/meese.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Meese, "meese"); 17 17 ··· 19 19 pub struct Meese {} 20 20 21 21 impl ProtocolHandler for Meese { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 feature_index: u32,
+51 -36
crates/buttplug_server/src/device/protocol/metaxsire.rs
··· 11 11 use async_trait::async_trait; 12 12 use uuid::{uuid, Uuid}; 13 13 14 - use buttplug_core::{errors::ButtplugDeviceError, message::{Endpoint, OutputType}}; 14 + use buttplug_core::{ 15 + errors::ButtplugDeviceError, 16 + message::{Endpoint, OutputType}, 17 + }; 15 18 use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 16 19 17 20 use crate::device::{ 18 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 19 - protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolInitializer, ProtocolIdentifier, ProtocolCommunicationSpecifier}, 21 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 22 + protocol::{ 23 + generic_protocol_initializer_setup, 24 + ProtocolCommunicationSpecifier, 25 + ProtocolHandler, 26 + ProtocolIdentifier, 27 + ProtocolInitializer, 28 + }, 20 29 }; 21 30 22 31 generic_protocol_initializer_setup!(MetaXSire, "metaxsire"); ··· 31 40 _: Arc<Hardware>, 32 41 def: &DeviceDefinition, 33 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 34 - let mut commands = vec!(); 35 - def 36 - .features() 37 - .iter() 38 - .for_each(|x| { 43 + let mut commands = vec![]; 44 + def.features().iter().for_each(|x| { 39 45 if x.output().is_some() { 40 46 commands.push((x.feature_type().try_into().unwrap(), AtomicU8::default())) 41 47 } ··· 48 54 49 55 #[derive(Default)] 50 56 pub struct MetaXSire { 51 - commands: Vec<(OutputType, AtomicU8)> 57 + commands: Vec<(OutputType, AtomicU8)>, 52 58 } 53 59 54 60 impl MetaXSire { 55 61 fn new(commands: Vec<(OutputType, AtomicU8)>) -> Self { 56 - Self { 57 - commands 58 - } 62 + Self { commands } 59 63 } 60 64 61 - fn form_command(&self, feature_index: u32, speed: u32) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 62 - self.commands[feature_index as usize].1.store(speed as u8, Ordering::Relaxed); 65 + fn form_command( 66 + &self, 67 + feature_index: u32, 68 + speed: u32, 69 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 70 + self.commands[feature_index as usize] 71 + .1 72 + .store(speed as u8, Ordering::Relaxed); 63 73 let mut data: Vec<u8> = vec![0x23, 0x07]; 64 74 data.push((self.commands.len() * 3) as u8); 65 75 ··· 84 94 } 85 95 data.push(crc); 86 96 87 - Ok(vec![HardwareWriteCmd::new(&[METAXSIRE_PROTOCOL_UUID], Endpoint::Tx, data, false).into()]) 97 + Ok(vec![HardwareWriteCmd::new( 98 + &[METAXSIRE_PROTOCOL_UUID], 99 + Endpoint::Tx, 100 + data, 101 + false, 102 + ) 103 + .into()]) 88 104 } 89 105 } 90 106 91 107 impl ProtocolHandler for MetaXSire { 92 - 93 108 fn handle_output_vibrate_cmd( 94 - &self, 95 - feature_index: u32, 96 - _feature_id: Uuid, 97 - speed: u32, 98 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 109 + &self, 110 + feature_index: u32, 111 + _feature_id: Uuid, 112 + speed: u32, 113 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 99 114 self.form_command(feature_index, speed) 100 115 } 101 116 102 117 fn handle_output_oscillate_cmd( 103 - &self, 104 - feature_index: u32, 105 - _feature_id: Uuid, 106 - speed: u32, 107 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 118 + &self, 119 + feature_index: u32, 120 + _feature_id: Uuid, 121 + speed: u32, 122 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 108 123 self.form_command(feature_index, speed) 109 124 } 110 125 111 126 fn handle_output_rotate_cmd( 112 - &self, 113 - feature_index: u32, 114 - _feature_id: Uuid, 115 - speed: u32, 116 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 127 + &self, 128 + feature_index: u32, 129 + _feature_id: Uuid, 130 + speed: u32, 131 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 117 132 self.form_command(feature_index, speed) 118 133 } 119 134 120 135 fn handle_output_constrict_cmd( 121 - &self, 122 - feature_index: u32, 123 - _feature_id: Uuid, 124 - level: u32, 125 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 136 + &self, 137 + feature_index: u32, 138 + _feature_id: Uuid, 139 + level: u32, 140 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 126 141 self.form_command(feature_index, level) 127 142 } 128 143 }
+8 -4
crates/buttplug_server/src/device/protocol/metaxsire_v2.rs
··· 7 7 8 8 use crate::device::hardware::Hardware; 9 9 use crate::device::protocol::ProtocolInitializer; 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 12 10 use crate::device::{ 13 - hardware::{HardwareCommand, HardwareWriteCmd}, 14 - protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolIdentifier}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolIdentifier}, 15 13 }; 16 14 use async_trait::async_trait; 15 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 16 + use buttplug_server_device_config::{ 17 + DeviceDefinition, 18 + ProtocolCommunicationSpecifier, 19 + UserDeviceIdentifier, 20 + }; 17 21 use std::sync::Arc; 18 22 use uuid::{uuid, Uuid}; 19 23
+28 -24
crates/buttplug_server/src/device/protocol/metaxsire_v3.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{ 12 - generic_protocol_setup, 13 - ProtocolHandler, 14 - }, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler}, 15 11 }; 16 - use uuid::Uuid; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 13 use std::time::Duration; 14 + use uuid::Uuid; 18 15 19 16 generic_protocol_setup!(MetaXSireV3, "metaxsire-v3"); 20 17 ··· 24 21 pub struct MetaXSireV3 {} 25 22 26 23 impl MetaXSireV3 { 27 - fn form_command(&self, feature_index: u32, feature_id: Uuid, speed: u32) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 24 + fn form_command( 25 + &self, 26 + feature_index: u32, 27 + feature_id: Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 28 30 Ok(vec![HardwareWriteCmd::new( 29 31 &[feature_id], 30 - Endpoint::Tx, 31 - vec![0xa1, 0x04, speed as u8, feature_index as u8 + 1], 32 - true, 33 - ) 34 - .into()]) 32 + Endpoint::Tx, 33 + vec![0xa1, 0x04, speed as u8, feature_index as u8 + 1], 34 + true, 35 + ) 36 + .into()]) 35 37 } 36 38 } 37 39 38 40 impl ProtocolHandler for MetaXSireV3 { 39 41 fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy { 40 - super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis(METAXSIRE_COMMAND_DELAY_MS)) 42 + super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis( 43 + METAXSIRE_COMMAND_DELAY_MS, 44 + )) 41 45 } 42 46 43 47 fn handle_output_vibrate_cmd( 44 - &self, 45 - feature_index: u32, 46 - feature_id: uuid::Uuid, 47 - speed: u32, 48 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 48 + &self, 49 + feature_index: u32, 50 + feature_id: uuid::Uuid, 51 + speed: u32, 52 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 49 53 self.form_command(feature_index, feature_id, speed) 50 54 } 51 55 52 56 fn handle_output_rotate_cmd( 53 - &self, 54 - feature_index: u32, 55 - feature_id: uuid::Uuid, 56 - speed: u32, 57 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 57 + &self, 58 + feature_index: u32, 59 + feature_id: uuid::Uuid, 60 + speed: u32, 61 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 58 62 self.form_command(feature_index, feature_id, speed) 59 63 } 60 64 }
+3 -5
crates/buttplug_server/src/device/protocol/metaxsire_v4.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(MetaXSireV4, "metaxsire-v4"); 17 17 ··· 19 19 pub struct MetaXSireV4 {} 20 20 21 21 impl ProtocolHandler for MetaXSireV4 { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/mizzzee.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(MizzZee, "mizzzee"); 17 17 ··· 19 19 pub struct MizzZee {} 20 20 21 21 impl ProtocolHandler for MizzZee { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/mizzzee_v2.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(MizzZeeV2, "mizzzee-v2"); 17 17 ··· 19 19 pub struct MizzZeeV2 {} 20 20 21 21 impl ProtocolHandler for MizzZeeV2 { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+6 -7
crates/buttplug_server/src/device/protocol/mizzzee_v3.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{ 12 - generic_protocol_setup, 13 - ProtocolHandler, 14 - }, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler}, 15 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 16 13 use std::time::Duration; 17 14 use uuid::Uuid; 18 15 ··· 60 57 61 58 impl ProtocolHandler for MizzZeeV3 { 62 59 fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy { 63 - super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis(MIZZZEE3_COMMAND_DELAY_MS)) 60 + super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis( 61 + MIZZZEE3_COMMAND_DELAY_MS, 62 + )) 64 63 } 65 64 66 65 fn handle_output_vibrate_cmd(
+24 -16
crates/buttplug_server/src/device/protocol/mod.rs
··· 124 124 pub mod zalo; 125 125 126 126 use buttplug_core::{ 127 - errors::ButtplugDeviceError, 128 - message::{OutputCommand, Endpoint, InputReadingV4, InputType}, 129 - }; 130 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 127 + errors::ButtplugDeviceError, 128 + message::{Endpoint, InputReadingV4, InputType, OutputCommand}, 129 + }; 130 + use buttplug_server_device_config::{ 131 + DeviceDefinition, 132 + ProtocolCommunicationSpecifier, 133 + UserDeviceIdentifier, 134 + }; 131 135 132 - use crate::{ 133 - device::{ 134 - hardware::{Hardware, HardwareCommand, HardwareReadCmd}, 135 - }, 136 - message::{ 137 - checked_output_cmd::CheckedOutputCmdV4, 138 - spec_enums::ButtplugDeviceCommandMessageUnionV4, 139 - ButtplugServerDeviceMessage, 136 + use crate::{ 137 + device::hardware::{Hardware, HardwareCommand, HardwareReadCmd}, 138 + message::{ 139 + checked_output_cmd::CheckedOutputCmdV4, 140 + spec_enums::ButtplugDeviceCommandMessageUnionV4, 141 + ButtplugServerDeviceMessage, 140 142 }, 141 143 }; 142 144 use async_trait::async_trait; ··· 144 146 future::{self, BoxFuture, FutureExt}, 145 147 StreamExt, 146 148 }; 147 - use std::{pin::Pin, time::Duration}; 148 149 use std::{collections::HashMap, sync::Arc}; 150 + use std::{pin::Pin, time::Duration}; 149 151 use uuid::Uuid; 150 152 151 153 /// Strategy for situations where hardware needs to get updates every so often in order to keep ··· 953 955 sensor_type: InputType, 954 956 ) -> BoxFuture<Result<InputReadingV4, ButtplugDeviceError>> { 955 957 match sensor_type { 956 - InputType::Battery => self.handle_battery_level_cmd(device_index, device, feature_index, feature_id), 958 + InputType::Battery => { 959 + self.handle_battery_level_cmd(device_index, device, feature_index, feature_id) 960 + } 957 961 _ => future::ready(Err(ButtplugDeviceError::UnhandledCommand( 958 962 "Command not implemented for this protocol: InputCmd (Read)".to_string(), 959 963 ))) ··· 979 983 async move { 980 984 let hw_msg = fut.await?; 981 985 let battery_level = hw_msg.data()[0] as i32; 982 - let battery_reading = 983 - InputReadingV4::new(device_index, feature_index, InputType::Battery, vec![battery_level]); 986 + let battery_reading = InputReadingV4::new( 987 + device_index, 988 + feature_index, 989 + InputType::Battery, 990 + vec![battery_level], 991 + ); 984 992 debug!("Got battery reading: {}", battery_level); 985 993 Ok(battery_reading) 986 994 }
+49 -31
crates/buttplug_server/src/device/protocol/monsterpub.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::Endpoint, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 13 8 use crate::device::{ 14 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 15 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 9 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 10 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 16 11 }; 17 12 use async_trait::async_trait; 13 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 14 + use buttplug_server_device_config::{ 15 + DeviceDefinition, 16 + ProtocolCommunicationSpecifier, 17 + UserDeviceIdentifier, 18 + }; 19 + use std::sync::{ 20 + atomic::{AtomicU8, Ordering}, 21 + Arc, 22 + }; 18 23 use uuid::{uuid, Uuid}; 19 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 20 24 21 25 pub mod setup { 22 26 use crate::device::protocol::{ProtocolIdentifier, ProtocolIdentifierFactory}; ··· 47 51 _: ProtocolCommunicationSpecifier, 48 52 ) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> { 49 53 let read_resp = hardware 50 - .read_value(&HardwareReadCmd::new(MONSTERPUB_PROTOCOL_UUID, Endpoint::RxBLEModel, 32, 500)) 54 + .read_value(&HardwareReadCmd::new( 55 + MONSTERPUB_PROTOCOL_UUID, 56 + Endpoint::RxBLEModel, 57 + 32, 58 + 500, 59 + )) 51 60 .await; 52 61 let ident = match read_resp { 53 62 Ok(data) => std::str::from_utf8(data.data()) ··· 80 89 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 81 90 if hardware.endpoints().contains(&Endpoint::Rx) { 82 91 let value = hardware 83 - .read_value(&HardwareReadCmd::new(MONSTERPUB_PROTOCOL_UUID, Endpoint::Rx, 16, 200)) 92 + .read_value(&HardwareReadCmd::new( 93 + MONSTERPUB_PROTOCOL_UUID, 94 + Endpoint::Rx, 95 + 16, 96 + 200, 97 + )) 84 98 .await?; 85 99 let keys = [ 86 100 [ ··· 112 126 ); 113 127 114 128 hardware 115 - .write_value(&HardwareWriteCmd::new(&[MONSTERPUB_PROTOCOL_UUID], Endpoint::Rx, auth, true)) 129 + .write_value(&HardwareWriteCmd::new( 130 + &[MONSTERPUB_PROTOCOL_UUID], 131 + Endpoint::Rx, 132 + auth, 133 + true, 134 + )) 116 135 .await?; 117 136 } 118 - let output_count = def.features().iter().filter(|x| x.output().is_some()).count(); 137 + let output_count = def 138 + .features() 139 + .iter() 140 + .filter(|x| x.output().is_some()) 141 + .count(); 119 142 120 143 Ok(Arc::new(MonsterPub::new( 121 144 if hardware.endpoints().contains(&Endpoint::TxVibrate) { ··· 125 148 } else { 126 149 Endpoint::Generic0 // tracy's dog 3 vibe 127 150 }, 128 - output_count as u32 151 + output_count as u32, 129 152 ))) 130 153 } 131 154 } 132 155 133 156 pub struct MonsterPub { 134 157 tx: Endpoint, 135 - speeds: Vec<AtomicU8> 158 + speeds: Vec<AtomicU8>, 136 159 } 137 160 138 161 impl MonsterPub { 139 162 pub fn new(tx: Endpoint, num_outputs: u32) -> Self { 140 163 let speeds: Vec<AtomicU8> = std::iter::repeat_with(|| AtomicU8::default()) 141 164 .take(num_outputs as usize) 142 - .collect(); 143 - Self { 144 - tx, 145 - speeds 146 - } 165 + .collect(); 166 + Self { tx, speeds } 147 167 } 148 168 149 169 fn form_command(&self) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { ··· 176 196 } 177 197 178 198 impl ProtocolHandler for MonsterPub { 179 - 180 - 181 199 fn handle_output_vibrate_cmd( 182 - &self, 183 - feature_index: u32, 184 - _feature_id: Uuid, 185 - speed: u32, 186 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 200 + &self, 201 + feature_index: u32, 202 + _feature_id: Uuid, 203 + speed: u32, 204 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 187 205 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 188 206 self.form_command() 189 207 } 190 208 191 209 fn handle_output_oscillate_cmd( 192 - &self, 193 - feature_index: u32, 194 - _feature_id: Uuid, 195 - speed: u32, 196 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 210 + &self, 211 + feature_index: u32, 212 + _feature_id: Uuid, 213 + speed: u32, 214 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 197 215 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 198 216 self.form_command() 199 217 }
+3 -5
crates/buttplug_server/src/device/protocol/motorbunny.rs
··· 14 14 15 15 use uuid::Uuid; 16 16 17 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 18 17 use crate::device::{ 19 - hardware::{HardwareCommand, HardwareWriteCmd}, 20 - protocol::{generic_protocol_setup, ProtocolHandler}, 18 + hardware::{HardwareCommand, HardwareWriteCmd}, 19 + protocol::{generic_protocol_setup, ProtocolHandler}, 21 20 }; 21 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 22 22 23 23 generic_protocol_setup!(Motorbunny, "motorbunny"); 24 24 ··· 26 26 pub struct Motorbunny {} 27 27 28 28 impl ProtocolHandler for Motorbunny { 29 - 30 - 31 29 fn handle_output_vibrate_cmd( 32 30 &self, 33 31 _feature_index: u32,
+48 -25
crates/buttplug_server/src/device/protocol/mysteryvibe.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::Endpoint, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 13 8 use crate::device::{ 14 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 15 - protocol::{ 16 - generic_protocol_initializer_setup, 17 - ProtocolHandler, 18 - ProtocolIdentifier, 19 - ProtocolInitializer, 20 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 21 16 }; 22 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 24 + use std::{ 25 + sync::{ 26 + atomic::{AtomicU8, Ordering}, 27 + Arc, 28 + }, 29 + time::Duration, 30 + }; 23 31 use uuid::{uuid, Uuid}; 24 - use std::{sync::{atomic::{AtomicU8, Ordering}, Arc}, time::Duration}; 25 32 26 33 generic_protocol_initializer_setup!(MysteryVibe, "mysteryvibe"); 27 34 ··· 37 44 hardware: Arc<Hardware>, 38 45 def: &DeviceDefinition, 39 46 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 40 - let msg = HardwareWriteCmd::new(&[MYSTERYVIBE_PROTOCOL_UUID], Endpoint::TxMode, vec![0x43u8, 0x02u8, 0x00u8], true); 47 + let msg = HardwareWriteCmd::new( 48 + &[MYSTERYVIBE_PROTOCOL_UUID], 49 + Endpoint::TxMode, 50 + vec![0x43u8, 0x02u8, 0x00u8], 51 + true, 52 + ); 41 53 hardware.write_value(&msg).await?; 42 - let vibrator_count = def.features().iter().filter(|x| x.output().is_some()).count(); 54 + let vibrator_count = def 55 + .features() 56 + .iter() 57 + .filter(|x| x.output().is_some()) 58 + .count(); 43 59 Ok(Arc::new(MysteryVibe::new(vibrator_count as u8))) 44 60 } 45 61 } ··· 60 76 pub fn new(vibrator_count: u8) -> Self { 61 77 Self { 62 78 speeds: std::iter::repeat_with(|| AtomicU8::default()) 63 - .take(vibrator_count as usize) 64 - .collect() 79 + .take(vibrator_count as usize) 80 + .collect(), 65 81 } 66 82 } 67 83 } 68 84 69 85 impl ProtocolHandler for MysteryVibe { 70 86 fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy { 71 - super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis(MYSTERYVIBE_COMMAND_DELAY_MS)) 87 + super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(Duration::from_millis( 88 + MYSTERYVIBE_COMMAND_DELAY_MS, 89 + )) 72 90 } 73 91 74 92 fn handle_output_vibrate_cmd( 75 - &self, 76 - feature_index: u32, 77 - _feature_id: Uuid, 78 - speed: u32, 79 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 93 + &self, 94 + feature_index: u32, 95 + _feature_id: Uuid, 96 + speed: u32, 97 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 80 98 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 81 99 Ok(vec![HardwareWriteCmd::new( 82 100 &[MYSTERYVIBE_PROTOCOL_UUID], 83 101 Endpoint::TxVibrate, 84 - self.speeds.iter().map(|x| x.load(Ordering::Relaxed)).collect(), 102 + self 103 + .speeds 104 + .iter() 105 + .map(|x| x.load(Ordering::Relaxed)) 106 + .collect(), 85 107 false, 86 - ).into()]) 108 + ) 109 + .into()]) 87 110 } 88 111 }
+26 -12
crates/buttplug_server/src/device/protocol/mysteryvibe_v2.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::Endpoint, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 13 8 use crate::device::{ 14 - hardware::{Hardware, HardwareWriteCmd}, 15 - protocol::{ 16 - generic_protocol_initializer_setup, mysteryvibe::MysteryVibe, ProtocolHandler, ProtocolIdentifier, ProtocolInitializer 17 - }, 9 + hardware::{Hardware, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + mysteryvibe::MysteryVibe, 13 + ProtocolHandler, 14 + ProtocolIdentifier, 15 + ProtocolInitializer, 16 + }, 18 17 }; 19 18 use async_trait::async_trait; 20 - use uuid::{uuid, Uuid}; 19 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 + use buttplug_server_device_config::{ 21 + DeviceDefinition, 22 + ProtocolCommunicationSpecifier, 23 + UserDeviceIdentifier, 24 + }; 21 25 use std::sync::Arc; 26 + use uuid::{uuid, Uuid}; 22 27 23 28 generic_protocol_initializer_setup!(MysteryVibeV2, "mysteryvibe-v2"); 24 29 ··· 36 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 37 42 // The only thing that's different about MysteryVibeV2 from v1 is the initialization packet. 38 43 // Just send that then return the older protocol version. 39 - let msg = HardwareWriteCmd::new(&[MYSTERYVIBE_V2_PROTOCOL_UUID], Endpoint::TxMode, vec![0x03u8, 0x02u8, 0x40u8], true); 44 + let msg = HardwareWriteCmd::new( 45 + &[MYSTERYVIBE_V2_PROTOCOL_UUID], 46 + Endpoint::TxMode, 47 + vec![0x03u8, 0x02u8, 0x40u8], 48 + true, 49 + ); 40 50 hardware.write_value(&msg).await?; 41 - let vibrator_count = def.features().iter().filter(|x| x.output().is_some()).count(); 51 + let vibrator_count = def 52 + .features() 53 + .iter() 54 + .filter(|x| x.output().is_some()) 55 + .count(); 42 56 Ok(Arc::new(MysteryVibe::new(vibrator_count as u8))) 43 57 } 44 58 }
+3 -3
crates/buttplug_server/src/device/protocol/nextlevelracing.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(NextLevelRacing, "nextlevelracing"); 17 17
+3 -5
crates/buttplug_server/src/device/protocol/nexus_revo.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(NexusRevo, "nexus-revo"); 17 17 ··· 19 19 pub struct NexusRevo {} 20 20 21 21 impl ProtocolHandler for NexusRevo { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+13 -4
crates/buttplug_server/src/device/protocol/nintendo_joycon.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager,}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer, generic_protocol_initializer_setup}, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 13 16 }; 14 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 15 24 use std::{ 16 25 sync::{ 17 26 atomic::{AtomicBool, AtomicU16, Ordering},
+13 -11
crates/buttplug_server/src/device/protocol/nobra.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use uuid::{uuid, Uuid}; 22 26 ··· 49 53 pub struct Nobra {} 50 54 51 55 impl ProtocolHandler for Nobra { 52 - 53 - 54 56 fn handle_output_vibrate_cmd( 55 57 &self, 56 58 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/omobo.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Omobo, "omobo"); 17 17 ··· 19 19 pub struct Omobo {} 20 20 21 21 impl ProtocolHandler for Omobo { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+33 -21
crates/buttplug_server/src/device/protocol/patoo.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::Endpoint, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 8 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 + use buttplug_server_device_config::{ 10 + DeviceDefinition, 11 + ProtocolCommunicationSpecifier, 12 + UserDeviceIdentifier, 13 + }; 13 14 14 - use crate::device::{ 15 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 16 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 17 - }; 15 + use crate::device::{ 16 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 17 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 18 + }; 18 19 use async_trait::async_trait; 20 + use std::sync::{ 21 + atomic::{AtomicU8, Ordering}, 22 + Arc, 23 + }; 19 24 use uuid::{uuid, Uuid}; 20 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 21 25 22 26 pub mod setup { 23 27 use crate::device::protocol::{ProtocolIdentifier, ProtocolIdentifierFactory}; ··· 79 83 80 84 #[derive(Default)] 81 85 pub struct Patoo { 82 - speeds: [AtomicU8; 2] 86 + speeds: [AtomicU8; 2], 83 87 } 84 88 85 89 impl ProtocolHandler for Patoo { 86 - 87 - 88 90 fn handle_output_vibrate_cmd( 89 - &self, 90 - feature_index: u32, 91 - _feature_id: uuid::Uuid, 92 - speed: u32, 93 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 91 + &self, 92 + feature_index: u32, 93 + _feature_id: uuid::Uuid, 94 + speed: u32, 95 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 94 96 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 95 97 let mut msg_vec = vec![]; 96 98 // Default to vibes ··· 109 111 } 110 112 } 111 113 112 - msg_vec.push(HardwareWriteCmd::new(&[PATOO_TX_PROTOCOL_UUID], Endpoint::Tx, vec![speed], true).into()); 113 - msg_vec.push(HardwareWriteCmd::new(&[PATOO_TX_MODE_PROTOCOL_UUID], Endpoint::TxMode, vec![mode], true).into()); 114 + msg_vec.push( 115 + HardwareWriteCmd::new(&[PATOO_TX_PROTOCOL_UUID], Endpoint::Tx, vec![speed], true).into(), 116 + ); 117 + msg_vec.push( 118 + HardwareWriteCmd::new( 119 + &[PATOO_TX_MODE_PROTOCOL_UUID], 120 + Endpoint::TxMode, 121 + vec![mode], 122 + true, 123 + ) 124 + .into(), 125 + ); 114 126 115 - Ok(msg_vec) 127 + Ok(msg_vec) 116 128 } 117 129 }
+3 -5
crates/buttplug_server/src/device/protocol/picobong.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Picobong, "picobong"); 17 17 ··· 19 19 pub struct Picobong {} 20 20 21 21 impl ProtocolHandler for Picobong { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/pink_punch.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(PinkPunch, "pink_punch"); 17 17 ··· 19 19 pub struct PinkPunch {} 20 20 21 21 impl ProtocolHandler for PinkPunch { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+8 -6
crates/buttplug_server/src/device/protocol/prettylove.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 13 11 }; 14 12 use async_trait::async_trait; 13 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 14 + use buttplug_server_device_config::{ 15 + DeviceDefinition, 16 + ProtocolCommunicationSpecifier, 17 + UserDeviceIdentifier, 18 + }; 15 19 use std::sync::Arc; 16 20 use uuid::Uuid; 17 21 ··· 70 74 pub struct PrettyLove {} 71 75 72 76 impl ProtocolHandler for PrettyLove { 73 - 74 - 75 77 fn handle_output_vibrate_cmd( 76 78 &self, 77 79 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/realov.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Realov, "realov"); 17 17 ··· 19 19 pub struct Realov {} 20 20 21 21 impl ProtocolHandler for Realov { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/sakuraneko.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Sakuraneko, "sakuraneko"); 17 17 ··· 19 19 pub struct Sakuraneko {} 20 20 21 21 impl ProtocolHandler for Sakuraneko { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+35 -17
crates/buttplug_server/src/device/protocol/satisfyer.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::Endpoint, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 13 8 use crate::device::{ 14 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 15 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 9 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 10 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 16 11 }; 17 12 use async_trait::async_trait; 18 - use uuid::{uuid, Uuid}; 13 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 14 + use buttplug_server_device_config::{ 15 + DeviceDefinition, 16 + ProtocolCommunicationSpecifier, 17 + UserDeviceIdentifier, 18 + }; 19 19 use std::{ 20 20 sync::{ 21 21 atomic::{AtomicU8, Ordering}, 22 22 Arc, 23 - }, time::Duration, 23 + }, 24 + time::Duration, 24 25 }; 26 + use uuid::{uuid, Uuid}; 25 27 26 28 const SATISFYER_PROTOCOL_UUID: Uuid = uuid!("79a0ed0d-f392-4c48-967e-f4467438c344"); 27 29 ··· 72 74 } 73 75 74 76 let result = hardware 75 - .read_value(&HardwareReadCmd::new(SATISFYER_PROTOCOL_UUID, Endpoint::RxBLEModel, 128, 500)) 77 + .read_value(&HardwareReadCmd::new( 78 + SATISFYER_PROTOCOL_UUID, 79 + Endpoint::RxBLEModel, 80 + 128, 81 + 500, 82 + )) 76 83 .await?; 77 84 let device_identifier = format!( 78 85 "{}", ··· 100 107 hardware: Arc<Hardware>, 101 108 device_definition: &DeviceDefinition, 102 109 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 103 - let msg = HardwareWriteCmd::new(&[SATISFYER_PROTOCOL_UUID], Endpoint::Command, vec![0x01], true); 110 + let msg = HardwareWriteCmd::new( 111 + &[SATISFYER_PROTOCOL_UUID], 112 + Endpoint::Command, 113 + vec![0x01], 114 + true, 115 + ); 104 116 let info_fut = hardware.write_value(&msg); 105 117 info_fut.await?; 106 118 ··· 148 160 } 149 161 150 162 fn handle_output_vibrate_cmd( 151 - &self, 152 - feature_index: u32, 153 - _feature_id: Uuid, 154 - speed: u32, 155 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 163 + &self, 164 + feature_index: u32, 165 + _feature_id: Uuid, 166 + speed: u32, 167 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 156 168 self.last_command[feature_index as usize].store(speed as u8, Ordering::Relaxed); 157 169 let data = form_command(self.feature_count, self.last_command.clone()); 158 170 159 - Ok(vec![HardwareWriteCmd::new(&[SATISFYER_PROTOCOL_UUID], Endpoint::Tx, data, false).into()]) 171 + Ok(vec![HardwareWriteCmd::new( 172 + &[SATISFYER_PROTOCOL_UUID], 173 + Endpoint::Tx, 174 + data, 175 + false, 176 + ) 177 + .into()]) 160 178 } 161 179 }
+3 -5
crates/buttplug_server/src/device/protocol/sensee.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Sensee, "sensee"); 17 17 ··· 19 19 pub struct Sensee {} 20 20 21 21 impl ProtocolHandler for Sensee { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/sensee_capsule.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SenseeCapsule, "sensee-capsule"); 17 17 ··· 19 19 pub struct SenseeCapsule {} 20 20 21 21 impl ProtocolHandler for SenseeCapsule { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+85 -50
crates/buttplug_server/src/device/protocol/sensee_v2.rs
··· 6 6 // for full license information. 7 7 8 8 use buttplug_core::{ 9 - errors::ButtplugDeviceError, 10 - message::{Endpoint, OutputType}, 11 - }; 12 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 + errors::ButtplugDeviceError, 10 + message::{Endpoint, OutputType}, 11 + }; 12 + use buttplug_server_device_config::{ 13 + DeviceDefinition, 14 + ProtocolCommunicationSpecifier, 15 + UserDeviceIdentifier, 16 + }; 13 17 14 - use crate::device::{ 15 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 16 - protocol::{ 17 - generic_protocol_initializer_setup, 18 - ProtocolHandler, 19 - ProtocolIdentifier, 20 - ProtocolInitializer, 21 - }, 18 + use crate::device::{ 19 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 20 + protocol::{ 21 + generic_protocol_initializer_setup, 22 + ProtocolHandler, 23 + ProtocolIdentifier, 24 + ProtocolInitializer, 25 + }, 22 26 }; 23 27 use async_trait::async_trait; 28 + use std::{ 29 + collections::HashMap, 30 + sync::{ 31 + atomic::{AtomicU8, Ordering}, 32 + Arc, 33 + }, 34 + }; 24 35 use uuid::{uuid, Uuid}; 25 - use std::{collections::HashMap, sync::{atomic::{AtomicU8, Ordering}, Arc}}; 26 36 27 37 generic_protocol_initializer_setup!(SenseeV2, "sensee-v2"); 28 38 ··· 39 49 device_definition: &DeviceDefinition, 40 50 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 41 51 let res = hardware 42 - .read_value(&HardwareReadCmd::new(SENSEE_V2_PROTOCOL_UUID, Endpoint::Tx, 128, 500)) 52 + .read_value(&HardwareReadCmd::new( 53 + SENSEE_V2_PROTOCOL_UUID, 54 + Endpoint::Tx, 55 + 128, 56 + 500, 57 + )) 43 58 .await?; 44 59 info!("Sensee model data: {:X?}", res.data()); 45 60 ··· 52 67 let feature_map = |output_type| { 53 68 let mut map = HashMap::new(); 54 69 device_definition 55 - .features() 56 - .iter() 57 - .enumerate() 58 - .for_each(|(i, x)| { 59 - if let Some(output_map) = x.output() { 60 - if output_map.contains_key(&output_type) { 61 - map.insert(i as u32, AtomicU8::new(0)); 70 + .features() 71 + .iter() 72 + .enumerate() 73 + .for_each(|(i, x)| { 74 + if let Some(output_map) = x.output() { 75 + if output_map.contains_key(&output_type) { 76 + map.insert(i as u32, AtomicU8::new(0)); 77 + } 62 78 } 63 - } 64 - }); 79 + }); 65 80 map 66 81 }; 67 82 ··· 69 84 let thrust_map = feature_map(OutputType::Oscillate); 70 85 let suck_map = feature_map(OutputType::Constrict); 71 86 72 - Ok(Arc::new(SenseeV2::new(device_type, vibe_map, thrust_map, suck_map))) 87 + Ok(Arc::new(SenseeV2::new( 88 + device_type, 89 + vibe_map, 90 + thrust_map, 91 + suck_map, 92 + ))) 73 93 } 74 94 } 75 95 ··· 77 97 device_type: u8, 78 98 vibe_map: HashMap<u32, AtomicU8>, 79 99 thrust_map: HashMap<u32, AtomicU8>, 80 - suck_map: HashMap<u32, AtomicU8> 100 + suck_map: HashMap<u32, AtomicU8>, 81 101 } 82 102 83 103 fn make_cmd(dtype: u8, func: u8, cmd: Vec<u8>) -> Vec<u8> { ··· 97 117 } 98 118 99 119 impl SenseeV2 { 100 - fn new(device_type: u8, vibe_map: HashMap<u32, AtomicU8>, thrust_map: HashMap<u32, AtomicU8>, suck_map: HashMap<u32, AtomicU8>) -> Self { 120 + fn new( 121 + device_type: u8, 122 + vibe_map: HashMap<u32, AtomicU8>, 123 + thrust_map: HashMap<u32, AtomicU8>, 124 + suck_map: HashMap<u32, AtomicU8>, 125 + ) -> Self { 101 126 Self { 102 127 device_type, 103 128 vibe_map, 104 129 thrust_map, 105 - suck_map 130 + suck_map, 106 131 } 107 132 } 108 133 109 - fn compile_command(&self) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 134 + fn compile_command(&self) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 110 135 let mut data = vec![]; 111 136 data.push( 112 137 if self.vibe_map.len() != 0 { 1 } else { 0 } ··· 138 163 } 139 164 140 165 impl ProtocolHandler for SenseeV2 { 141 - 142 - 143 166 fn handle_output_vibrate_cmd( 144 - &self, 145 - feature_index: u32, 146 - _feature_id: Uuid, 147 - speed: u32, 148 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 149 - self.vibe_map.get(&feature_index).unwrap().store(speed as u8, Ordering::Relaxed); 167 + &self, 168 + feature_index: u32, 169 + _feature_id: Uuid, 170 + speed: u32, 171 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 172 + self 173 + .vibe_map 174 + .get(&feature_index) 175 + .unwrap() 176 + .store(speed as u8, Ordering::Relaxed); 150 177 self.compile_command() 151 178 } 152 179 153 180 fn handle_output_oscillate_cmd( 154 - &self, 155 - feature_index: u32, 156 - _feature_id: Uuid, 157 - speed: u32, 158 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 159 - self.thrust_map.get(&feature_index).unwrap().store(speed as u8, Ordering::Relaxed); 160 - self.compile_command() 181 + &self, 182 + feature_index: u32, 183 + _feature_id: Uuid, 184 + speed: u32, 185 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 186 + self 187 + .thrust_map 188 + .get(&feature_index) 189 + .unwrap() 190 + .store(speed as u8, Ordering::Relaxed); 191 + self.compile_command() 161 192 } 162 193 163 194 fn handle_output_constrict_cmd( 164 - &self, 165 - feature_index: u32, 166 - _feature_id: Uuid, 167 - level: u32, 168 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 169 - self.suck_map.get(&feature_index).unwrap().store(level as u8, Ordering::Relaxed); 170 - self.compile_command() 195 + &self, 196 + feature_index: u32, 197 + _feature_id: Uuid, 198 + level: u32, 199 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 200 + self 201 + .suck_map 202 + .get(&feature_index) 203 + .unwrap() 204 + .store(level as u8, Ordering::Relaxed); 205 + self.compile_command() 171 206 } 172 207 }
+3 -3
crates/buttplug_server/src/device/protocol/serveu.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 use std::sync::{ 16 16 atomic::{AtomicU8, Ordering}, 17 17 Arc,
+15 -20
crates/buttplug_server/src/device/protocol/sexverse_lg389.rs
··· 9 9 10 10 use uuid::{uuid, Uuid}; 11 11 12 - use buttplug_core::{ 13 - errors::ButtplugDeviceError, 14 - message::Endpoint, 15 - }; 16 12 use crate::device::{ 17 - hardware::{HardwareCommand, HardwareWriteCmd}, 18 - protocol::{generic_protocol_setup, ProtocolHandler}, 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 19 15 }; 16 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 17 21 18 generic_protocol_setup!(SexverseLG389, "sexverse-lg389"); 22 19 ··· 25 22 #[derive(Default)] 26 23 pub struct SexverseLG389 { 27 24 vibe_speed: AtomicU8, 28 - osc_speed: AtomicU8 25 + osc_speed: AtomicU8, 29 26 } 30 27 31 28 impl SexverseLG389 { ··· 40 37 vec![0xaa, 0x05, vibe, 0x14, anchor, 0x00, range, 0x00, osc, 0x00], 41 38 true, 42 39 ) 43 - .into()]) 40 + .into()]) 44 41 } 45 42 } 46 43 47 44 impl ProtocolHandler for SexverseLG389 { 48 - 49 - 50 45 fn handle_output_vibrate_cmd( 51 - &self, 52 - _feature_index: u32, 53 - _feature_id: uuid::Uuid, 54 - speed: u32, 55 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 46 + &self, 47 + _feature_index: u32, 48 + _feature_id: uuid::Uuid, 49 + speed: u32, 50 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 56 51 self.vibe_speed.store(speed as u8, Ordering::Relaxed); 57 52 self.generate_command() 58 53 } 59 54 60 55 fn handle_output_oscillate_cmd( 61 - &self, 62 - _feature_index: u32, 63 - _feature_id: uuid::Uuid, 64 - speed: u32, 65 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 56 + &self, 57 + _feature_index: u32, 58 + _feature_id: uuid::Uuid, 59 + speed: u32, 60 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 66 61 self.osc_speed.store(speed as u8, Ordering::Relaxed); 67 62 self.generate_command() 68 63 }
+17 -6
crates/buttplug_server/src/device/protocol/svakom/mod.rs
··· 20 20 pub mod svakom_v6; 21 21 22 22 use buttplug_core::errors::ButtplugDeviceError; 23 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, UserDeviceIdentifier, DeviceDefinition}; 23 + use buttplug_server_device_config::{ 24 + DeviceDefinition, 25 + ProtocolCommunicationSpecifier, 26 + UserDeviceIdentifier, 27 + }; 24 28 25 29 use crate::device::{ 26 - hardware::Hardware, 27 - protocol::{ 28 - generic_protocol_initializer_setup, ProtocolHandler, ProtocolIdentifier, ProtocolInitializer 29 - }, 30 + hardware::Hardware, 31 + protocol::{ 32 + generic_protocol_initializer_setup, 33 + ProtocolHandler, 34 + ProtocolIdentifier, 35 + ProtocolInitializer, 36 + }, 30 37 }; 31 38 use async_trait::async_trait; 32 39 use std::sync::Arc; ··· 55 62 "svakom_iker" => Ok(Arc::new(svakom_iker::SvakomIker::default())), 56 63 "svakom_jordan" => Ok(Arc::new(svakom_jordan::SvakomJordan::default())), 57 64 "svakom_pulse" => Ok(Arc::new(svakom_pulse::SvakomPulse::default())), 58 - "svakom_sam" => svakom_sam::SvakomSamInitializer::default().initialize(hardware, def).await, 65 + "svakom_sam" => { 66 + svakom_sam::SvakomSamInitializer::default() 67 + .initialize(hardware, def) 68 + .await 69 + } 59 70 "svakom_sam2" => Ok(Arc::new(svakom_sam2::SvakomSam2::default())), 60 71 //"svakom_suitcase" => Ok(Arc::new(svakom_suitcase::SvakomSuitcase::default())), 61 72 //"svakom_tarax" => Ok(Arc::new(svakom_tarax::SvakomTaraX::default())),
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_alex.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SvakomAlex, "svakom-alex"); 17 17
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_alex_v2.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SvakomAlexV2, "svakom-alex-v2"); 17 17
+13 -13
crates/buttplug_server/src/device/protocol/svakom/svakom_barnard.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 12 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 13 14 14 generic_protocol_setup!(SvakomBarnard, "svakom-barnard"); 15 15 ··· 22 22 } 23 23 24 24 fn handle_output_vibrate_cmd( 25 - &self, 26 - _feature_index: u32, 27 - feature_id: uuid::Uuid, 28 - speed: u32, 29 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 25 + &self, 26 + _feature_index: u32, 27 + feature_id: uuid::Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 30 Ok(vec![HardwareWriteCmd::new( 31 31 &[feature_id], 32 32 Endpoint::Tx, ··· 45 45 } 46 46 47 47 fn handle_output_oscillate_cmd( 48 - &self, 49 - _feature_index: u32, 50 - feature_id: uuid::Uuid, 51 - speed: u32, 52 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 48 + &self, 49 + _feature_index: u32, 50 + feature_id: uuid::Uuid, 51 + speed: u32, 52 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 53 53 Ok(vec![HardwareWriteCmd::new( 54 54 &[feature_id], 55 55 Endpoint::Tx,
+8 -8
crates/buttplug_server/src/device/protocol/svakom/svakom_barney.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 12 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 13 14 14 generic_protocol_setup!(SvakomBarney, "svakom-barney"); 15 15 ··· 22 22 } 23 23 24 24 fn handle_output_vibrate_cmd( 25 - &self, 26 - feature_index: u32, 27 - feature_id: uuid::Uuid, 28 - speed: u32, 29 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 25 + &self, 26 + feature_index: u32, 27 + feature_id: uuid::Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 30 Ok(vec![HardwareWriteCmd::new( 31 31 &[feature_id], 32 32 Endpoint::Tx,
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_dice.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SvakomDice, "svakom-dice"); 17 17
+19 -16
crates/buttplug_server/src/device/protocol/svakom/svakom_iker.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{ProtocolHandler, ProtocolKeepaliveStrategy, generic_protocol_setup, 12 - }, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 13 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 14 13 use std::sync::atomic::{AtomicU8, Ordering}; 15 14 use std::sync::Arc; 16 15 ··· 44 43 ) 45 44 .into()]) 46 45 } else { 47 - let mut msgs = vec!(); 48 - msgs.push(HardwareWriteCmd::new( 49 - &[feature_id], 50 - Endpoint::Tx, 51 - [0x55, 0x03, 0x03, 0x00, 0x01, vibe0 as u8].to_vec(), 52 - false, 53 - ) 54 - .into()); 55 - if vibe1 > 0 { 56 - msgs.push(HardwareWriteCmd::new( 46 + let mut msgs = vec![]; 47 + msgs.push( 48 + HardwareWriteCmd::new( 57 49 &[feature_id], 58 50 Endpoint::Tx, 59 - [0x55, 0x07, 0x00, 0x00, vibe1 as u8, 0x00].to_vec(), 51 + [0x55, 0x03, 0x03, 0x00, 0x01, vibe0 as u8].to_vec(), 60 52 false, 61 53 ) 62 - .into()); 54 + .into(), 55 + ); 56 + if vibe1 > 0 { 57 + msgs.push( 58 + HardwareWriteCmd::new( 59 + &[feature_id], 60 + Endpoint::Tx, 61 + [0x55, 0x07, 0x00, 0x00, vibe1 as u8, 0x00].to_vec(), 62 + false, 63 + ) 64 + .into(), 65 + ); 63 66 } 64 67 Ok(msgs) 65 68 }
+13 -13
crates/buttplug_server/src/device/protocol/svakom/svakom_jordan.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 12 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 13 14 14 generic_protocol_setup!(SvakomJordan, "svakom-jordan"); 15 15 ··· 22 22 } 23 23 24 24 fn handle_output_vibrate_cmd( 25 - &self, 26 - _feature_index: u32, 27 - feature_id: uuid::Uuid, 28 - speed: u32, 29 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 25 + &self, 26 + _feature_index: u32, 27 + feature_id: uuid::Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 30 Ok(vec![HardwareWriteCmd::new( 31 31 &[feature_id], 32 32 Endpoint::Tx, ··· 45 45 } 46 46 47 47 fn handle_output_oscillate_cmd( 48 - &self, 49 - _feature_index: u32, 50 - feature_id: uuid::Uuid, 51 - speed: u32, 52 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 48 + &self, 49 + _feature_index: u32, 50 + feature_id: uuid::Uuid, 51 + speed: u32, 52 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 53 53 Ok(vec![HardwareWriteCmd::new( 54 54 &[feature_id], 55 55 Endpoint::Tx,
+8 -8
crates/buttplug_server/src/device/protocol/svakom/svakom_pulse.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 12 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 13 14 14 generic_protocol_setup!(SvakomPulse, "svakom-pulse"); 15 15 ··· 22 22 } 23 23 24 24 fn handle_output_vibrate_cmd( 25 - &self, 26 - _feature_index: u32, 27 - feature_id: uuid::Uuid, 28 - speed: u32, 29 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 25 + &self, 26 + _feature_index: u32, 27 + feature_id: uuid::Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 30 Ok(vec![HardwareWriteCmd::new( 31 31 &[feature_id], 32 32 Endpoint::Tx,
+44 -39
crates/buttplug_server/src/device/protocol/svakom/svakom_sam.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 8 use crate::device::protocol::ProtocolKeepaliveStrategy; 10 - use buttplug_core::{ 11 - errors::ButtplugDeviceError, 12 - message::Endpoint, 13 - }; 14 9 use crate::device::{ 15 - hardware::{Hardware, HardwareCommand, HardwareSubscribeCmd, HardwareWriteCmd}, 16 - protocol::{ 17 - generic_protocol_initializer_setup, 18 - ProtocolHandler, 19 - ProtocolIdentifier, 20 - ProtocolInitializer, 21 - }, 10 + hardware::{Hardware, HardwareCommand, HardwareSubscribeCmd, HardwareWriteCmd}, 11 + protocol::{ 12 + generic_protocol_initializer_setup, 13 + ProtocolHandler, 14 + ProtocolIdentifier, 15 + ProtocolInitializer, 16 + }, 22 17 }; 23 18 use async_trait::async_trait; 24 - use uuid::{uuid, Uuid}; 19 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 + use buttplug_server_device_config::{ 21 + DeviceDefinition, 22 + ProtocolCommunicationSpecifier, 23 + UserDeviceIdentifier, 24 + }; 25 25 use std::sync::Arc; 26 + use uuid::{uuid, Uuid}; 26 27 27 28 generic_protocol_initializer_setup!(SvakomSam, "svakom-sam"); 28 29 const SVAKOM_SAM_PROTOCOL_UUID: Uuid = uuid!("e39a6b4a-230a-4669-be94-68135f97f166"); ··· 38 39 _: &DeviceDefinition, 39 40 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 40 41 hardware 41 - .subscribe(&HardwareSubscribeCmd::new(SVAKOM_SAM_PROTOCOL_UUID, Endpoint::Rx)) 42 + .subscribe(&HardwareSubscribeCmd::new( 43 + SVAKOM_SAM_PROTOCOL_UUID, 44 + Endpoint::Rx, 45 + )) 42 46 .await?; 43 47 let mut gen2 = hardware.endpoints().contains(&Endpoint::TxMode); 44 48 if !gen2 && hardware.endpoints().contains(&Endpoint::Firmware) { ··· 66 70 } 67 71 68 72 fn handle_output_vibrate_cmd( 69 - &self, 70 - feature_index: u32, 71 - feature_id: Uuid, 72 - speed: u32, 73 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 73 + &self, 74 + feature_index: u32, 75 + feature_id: Uuid, 76 + speed: u32, 77 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 74 78 if feature_index == 0 { 75 79 Ok(vec![HardwareWriteCmd::new( 76 80 &[feature_id], 77 - Endpoint::Tx, 78 - if self.gen2 { 79 - [ 80 - 18, 81 - 1, 82 - 3, 83 - 0, 84 - if speed == 0 { 0x00 } else { 0x04 }, 85 - speed as u8, 86 - ] 87 - .to_vec() 88 - } else { 89 - [18, 1, 3, 0, 5, speed as u8].to_vec() 90 - }, 91 - false, 92 - ) 93 - .into()]) 81 + Endpoint::Tx, 82 + if self.gen2 { 83 + [ 84 + 18, 85 + 1, 86 + 3, 87 + 0, 88 + if speed == 0 { 0x00 } else { 0x04 }, 89 + speed as u8, 90 + ] 91 + .to_vec() 92 + } else { 93 + [18, 1, 3, 0, 5, speed as u8].to_vec() 94 + }, 95 + false, 96 + ) 97 + .into()]) 94 98 } else { 95 99 Ok(vec![HardwareWriteCmd::new( 96 100 &[feature_id], 97 - Endpoint::Tx, 101 + Endpoint::Tx, 98 102 [18, 6, 1, speed as u8].to_vec(), 99 - false).into(), 100 - ]) 103 + false, 104 + ) 105 + .into()]) 101 106 } 102 107 } 103 108 }
+13 -13
crates/buttplug_server/src/device/protocol/svakom/svakom_sam2.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 12 11 }; 12 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 13 13 14 14 generic_protocol_setup!(SvakomSam2, "svakom-sam2"); 15 15 ··· 22 22 } 23 23 24 24 fn handle_output_vibrate_cmd( 25 - &self, 26 - _feature_index: u32, 27 - feature_id: uuid::Uuid, 28 - speed: u32, 29 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 25 + &self, 26 + _feature_index: u32, 27 + feature_id: uuid::Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 30 30 Ok(vec![HardwareWriteCmd::new( 31 31 &[feature_id], 32 32 Endpoint::Tx, ··· 46 46 } 47 47 48 48 fn handle_output_constrict_cmd( 49 - &self, 50 - _feature_index: u32, 51 - feature_id: uuid::Uuid, 52 - level: u32, 53 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 49 + &self, 50 + _feature_index: u32, 51 + feature_id: uuid::Uuid, 52 + level: u32, 53 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 54 54 Ok(vec![HardwareWriteCmd::new( 55 55 &[feature_id], 56 56 Endpoint::Tx,
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_v1.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SvakomV1, "svakom-v1"); 17 17
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_v2.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SvakomV2, "svakom-v2"); 17 17
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_v3.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(SvakomV3, "svakom-v3"); 17 17
+8 -8
crates/buttplug_server/src/device/protocol/svakom/svakom_v4.rs
··· 6 6 // for full license information. 7 7 8 8 use crate::device::protocol::ProtocolKeepaliveStrategy; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 10 9 use crate::device::{ 11 - hardware::{HardwareCommand, HardwareWriteCmd}, 12 - protocol::{generic_protocol_setup, ProtocolHandler}, 10 + hardware::{HardwareCommand, HardwareWriteCmd}, 11 + protocol::{generic_protocol_setup, ProtocolHandler}, 13 12 }; 13 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 14 14 15 15 generic_protocol_setup!(SvakomV4, "svakom-v4"); 16 16 ··· 23 23 } 24 24 25 25 fn handle_output_vibrate_cmd( 26 - &self, 27 - feature_index: u32, 28 - feature_id: uuid::Uuid, 29 - speed: u32, 30 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 26 + &self, 27 + feature_index: u32, 28 + feature_id: uuid::Uuid, 29 + speed: u32, 30 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 31 31 Ok(vec![HardwareWriteCmd::new( 32 32 &[feature_id], 33 33 Endpoint::Tx,
+3 -3
crates/buttplug_server/src/device/protocol/svakom/svakom_v5.rs
··· 7 7 8 8 use uuid::{uuid, Uuid}; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler, ProtocolKeepaliveStrategy}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 use std::sync::atomic::{AtomicU8, Ordering}; 16 16 generic_protocol_setup!(SvakomV5, "svakom-v5"); 17 17
+34 -20
crates/buttplug_server/src/device/protocol/svakom/svakom_v6.rs
··· 9 9 use uuid::{uuid, Uuid}; 10 10 11 11 use buttplug_core::{ 12 - errors::ButtplugDeviceError, 13 - message::{Endpoint, OutputType}, 14 - }; 15 - 16 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 12 + errors::ButtplugDeviceError, 13 + message::{Endpoint, OutputType}, 14 + }; 15 + 17 16 use crate::device::{ 18 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, protocol::{ 19 - ProtocolCommunicationSpecifier, ProtocolHandler, ProtocolIdentifier, ProtocolInitializer, ProtocolKeepaliveStrategy, generic_protocol_initializer_setup, 20 - } 17 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 18 + protocol::{ 19 + generic_protocol_initializer_setup, 20 + ProtocolCommunicationSpecifier, 21 + ProtocolHandler, 22 + ProtocolIdentifier, 23 + ProtocolInitializer, 24 + ProtocolKeepaliveStrategy, 25 + }, 26 + }; 27 + use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 28 + use std::sync::{ 29 + atomic::{AtomicU8, Ordering}, 30 + Arc, 21 31 }; 22 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 23 32 24 33 const SVAKOM_V6_VIBRATOR_UUID: Uuid = uuid!("4cf33d95-a3d1-4ed4-9ac6-9ba6d6ccb091"); 25 34 ··· 35 44 _: Arc<Hardware>, 36 45 def: &DeviceDefinition, 37 46 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 38 - let num_vibrators = def.features().iter().filter(|x| { 39 - if let Some(output_map) = x.output() { 40 - output_map.contains_key(&OutputType::Vibrate) 41 - } else { 42 - false 43 - } 44 - }).count() as u8; 47 + let num_vibrators = def 48 + .features() 49 + .iter() 50 + .filter(|x| { 51 + if let Some(output_map) = x.output() { 52 + output_map.contains_key(&OutputType::Vibrate) 53 + } else { 54 + false 55 + } 56 + }) 57 + .count() as u8; 45 58 Ok(Arc::new(SvakomV6::new(num_vibrators))) 46 59 } 47 60 } ··· 56 69 fn new(num_vibrators: u8) -> Self { 57 70 Self { 58 71 num_vibrators, 59 - .. Default::default() 72 + ..Default::default() 60 73 } 61 74 } 62 75 } ··· 71 84 feature_index: u32, 72 85 feature_id: uuid::Uuid, 73 86 speed: u32, 74 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 87 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 75 88 self.last_vibrator_speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 76 89 if feature_index < 2 { 77 90 let vibe1 = self.last_vibrator_speeds[0].load(Ordering::Relaxed); ··· 96 109 0x01 97 110 }, 98 111 vibe1.max(vibe2) as u8, 99 - 0x00 112 + 0x00, 100 113 ] 101 114 .to_vec(), 102 115 false, ··· 118 131 ] 119 132 .to_vec(), 120 133 false, 121 - ).into()]) 134 + ) 135 + .into()]) 122 136 } 123 137 } 124 138 }
+3 -5
crates/buttplug_server/src/device/protocol/synchro.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Synchro, "synchro"); 17 17 ··· 19 19 pub struct Synchro {} 20 20 21 21 impl ProtocolHandler for Synchro { 22 - 23 - 24 22 fn handle_rotation_with_direction_cmd( 25 23 &self, 26 24 _feature_index: u32,
+17 -5
crates/buttplug_server/src/device/protocol/tcode_v03.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(TCodeV03, "tcode-v03"); 17 17 ··· 29 29 30 30 let command = format!("L0{position:03}\nR0{position:03}\n"); 31 31 msg_vec.push( 32 - HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, command.as_bytes().to_vec(), false).into(), 32 + HardwareWriteCmd::new( 33 + &[feature_id], 34 + Endpoint::Tx, 35 + command.as_bytes().to_vec(), 36 + false, 37 + ) 38 + .into(), 33 39 ); 34 40 35 41 Ok(msg_vec) ··· 46 52 47 53 let command = format!("L{feature_index}{position:02}I{duration}\n"); 48 54 msg_vec.push( 49 - HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, command.as_bytes().to_vec(), false).into(), 55 + HardwareWriteCmd::new( 56 + &[feature_id], 57 + Endpoint::Tx, 58 + command.as_bytes().to_vec(), 59 + false, 60 + ) 61 + .into(), 50 62 ); 51 63 52 64 Ok(msg_vec)
+13 -9
crates/buttplug_server/src/device/protocol/thehandy/mod.rs
··· 7 7 8 8 use self::handyplug::Ping; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 12 10 use crate::device::{ 13 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 14 - protocol::{ 15 - generic_protocol_initializer_setup, 16 - ProtocolHandler, 17 - ProtocolIdentifier, 18 - ProtocolInitializer, 19 - }, 11 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 + protocol::{ 13 + generic_protocol_initializer_setup, 14 + ProtocolHandler, 15 + ProtocolIdentifier, 16 + ProtocolInitializer, 17 + }, 20 18 }; 21 19 use async_trait::async_trait; 20 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 21 + use buttplug_server_device_config::{ 22 + DeviceDefinition, 23 + ProtocolCommunicationSpecifier, 24 + UserDeviceIdentifier, 25 + }; 22 26 use prost::Message; 23 27 use std::sync::Arc; 24 28 use uuid::{uuid, Uuid};
+32 -22
crates/buttplug_server/src/device/protocol/tryfun.rs
··· 8 8 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 9 10 10 use crate::device::{ 11 - hardware::{HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ProtocolHandler, generic_protocol_setup,} 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 13 13 }; 14 14 15 15 generic_protocol_setup!(TryFun, "tryfun"); ··· 18 18 pub struct TryFun {} 19 19 20 20 impl ProtocolHandler for TryFun { 21 - 22 - 23 21 fn handle_output_oscillate_cmd( 24 - &self, 25 - _feature_index: u32, 26 - feature_id: uuid::Uuid, 27 - speed: u32, 28 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 22 + &self, 23 + _feature_index: u32, 24 + feature_id: uuid::Uuid, 25 + speed: u32, 26 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 29 27 let mut sum: u8 = 0xff; 30 28 let mut data = vec![0xAA, 0x02, 0x07, speed as u8]; 31 29 let mut count = 0; ··· 36 34 sum += count; 37 35 data.push(sum); 38 36 39 - Ok(vec![HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, data, true).into()]) 37 + Ok(vec![HardwareWriteCmd::new( 38 + &[feature_id], 39 + Endpoint::Tx, 40 + data, 41 + true, 42 + ) 43 + .into()]) 40 44 } 41 45 42 46 fn handle_output_rotate_cmd( 43 - &self, 44 - _feature_index: u32, 45 - feature_id: uuid::Uuid, 46 - speed: u32, 47 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 47 + &self, 48 + _feature_index: u32, 49 + feature_id: uuid::Uuid, 50 + speed: u32, 51 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 48 52 let mut sum: u8 = 0xff; 49 53 let mut data = vec![0xAA, 0x02, 0x08, speed as u8]; 50 54 let mut count = 0; ··· 55 59 sum += count; 56 60 data.push(sum); 57 61 58 - Ok(vec![HardwareWriteCmd::new(&[feature_id], Endpoint::Tx, data, true).into()]) 62 + Ok(vec![HardwareWriteCmd::new( 63 + &[feature_id], 64 + Endpoint::Tx, 65 + data, 66 + true, 67 + ) 68 + .into()]) 59 69 } 60 70 61 71 fn handle_output_vibrate_cmd( 62 - &self, 63 - _feature_index: u32, 64 - feature_id: uuid::Uuid, 65 - speed: u32, 66 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 72 + &self, 73 + _feature_index: u32, 74 + feature_id: uuid::Uuid, 75 + speed: u32, 76 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 67 77 Ok(vec![HardwareWriteCmd::new( 68 - &[feature_id], 78 + &[feature_id], 69 79 Endpoint::Tx, 70 80 vec![ 71 81 0x00,
+3 -5
crates/buttplug_server/src/device/protocol/tryfun_blackhole.rs
··· 8 8 use uuid::Uuid; 9 9 10 10 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 - 11 + 12 12 use crate::device::{ 13 - hardware::{HardwareCommand, HardwareWriteCmd}, 14 - protocol::{ProtocolHandler,generic_protocol_setup} 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 15 15 }; 16 16 use std::sync::atomic::{AtomicU8, Ordering}; 17 17 ··· 23 23 } 24 24 25 25 impl ProtocolHandler for TryFunBlackHole { 26 - 27 - 28 26 fn handle_output_oscillate_cmd( 29 27 &self, 30 28 _feature_index: u32,
+3 -5
crates/buttplug_server/src/device/protocol/tryfun_meta2.rs
··· 8 8 use uuid::Uuid; 9 9 10 10 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 - 11 + 12 12 use crate::device::{ 13 - hardware::{HardwareCommand, HardwareWriteCmd}, 14 - protocol::{ProtocolHandler, generic_protocol_setup} 13 + hardware::{HardwareCommand, HardwareWriteCmd}, 14 + protocol::{generic_protocol_setup, ProtocolHandler}, 15 15 }; 16 16 use std::sync::atomic::{AtomicU8, Ordering}; 17 17 ··· 23 23 } 24 24 25 25 impl ProtocolHandler for TryFunMeta2 { 26 - 27 - 28 26 fn handle_output_oscillate_cmd( 29 27 &self, 30 28 _feature_index: u32,
+13 -11
crates/buttplug_server/src/device/protocol/vibcrafter.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareEvent, HardwareSubscribeCmd, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use aes::Aes128; 20 18 use async_trait::async_trait; 19 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 + use buttplug_server_device_config::{ 21 + DeviceDefinition, 22 + ProtocolCommunicationSpecifier, 23 + UserDeviceIdentifier, 24 + }; 21 25 use ecb::cipher::block_padding::Pkcs7; 22 26 use ecb::cipher::{BlockDecryptMut, BlockEncryptMut, KeyInit}; 23 27 use std::sync::{ ··· 143 147 } 144 148 145 149 impl ProtocolHandler for VibCrafter { 146 - 147 - 148 150 fn handle_output_vibrate_cmd( 149 151 &self, 150 152 feature_index: u32,
+35 -23
crates/buttplug_server/src/device/protocol/vibratissimo.rs
··· 6 6 // for full license information. 7 7 8 8 use buttplug_core::message::OutputType; 9 - use buttplug_core::{ 10 - errors::ButtplugDeviceError, 11 - message::Endpoint, 12 - }; 13 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 10 + use buttplug_server_device_config::{ 11 + DeviceDefinition, 12 + ProtocolCommunicationSpecifier, 13 + UserDeviceIdentifier, 14 + }; 14 15 15 - use crate::device::{ 16 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 17 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 16 + use crate::device::{ 17 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 18 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 18 19 }; 19 20 use async_trait::async_trait; 20 - use uuid::{uuid, Uuid}; 21 21 use std::sync::atomic::{AtomicU8, Ordering}; 22 22 use std::sync::Arc; 23 + use uuid::{uuid, Uuid}; 23 24 24 25 const VIBRATISSIMO_PROTOCOL_UUID: Uuid = uuid!("66ef7aa4-1e6a-4067-9066-dcb53c7647f2"); 25 26 ··· 50 51 _: ProtocolCommunicationSpecifier, 51 52 ) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> { 52 53 let result = hardware 53 - .read_value(&HardwareReadCmd::new(VIBRATISSIMO_PROTOCOL_UUID, Endpoint::RxBLEModel, 128, 500)) 54 + .read_value(&HardwareReadCmd::new( 55 + VIBRATISSIMO_PROTOCOL_UUID, 56 + Endpoint::RxBLEModel, 57 + 128, 58 + 500, 59 + )) 54 60 .await?; 55 61 let ident = 56 62 String::from_utf8(result.data().to_vec()).unwrap_or_else(|_| hardware.name().to_owned()); ··· 71 77 _: Arc<Hardware>, 72 78 def: &DeviceDefinition, 73 79 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 74 - let num_vibrators: u8 = def.features().iter().filter(|x| x.output().as_ref().map_or(false, |x| x.contains_key(&OutputType::Vibrate))).count() as u8; 80 + let num_vibrators: u8 = def 81 + .features() 82 + .iter() 83 + .filter(|x| { 84 + x.output() 85 + .as_ref() 86 + .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 87 + }) 88 + .count() as u8; 75 89 Ok(Arc::new(Vibratissimo::new(num_vibrators as u8))) 76 90 } 77 91 } 78 92 79 93 pub struct Vibratissimo { 80 - speeds: Vec<AtomicU8> 94 + speeds: Vec<AtomicU8>, 81 95 } 82 96 83 97 impl Vibratissimo { 84 98 fn new(num_vibrators: u8) -> Self { 85 99 let speeds: Vec<AtomicU8> = std::iter::repeat_with(|| AtomicU8::default()) 86 - .take(num_vibrators as usize) 87 - .collect(); 88 - Self { 89 - speeds 90 - } 100 + .take(num_vibrators as usize) 101 + .collect(); 102 + Self { speeds } 91 103 } 92 104 } 93 105 94 106 impl ProtocolHandler for Vibratissimo { 95 107 fn handle_output_vibrate_cmd( 96 - &self, 97 - feature_index: u32, 98 - feature_id: Uuid, 99 - speed: u32, 100 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 108 + &self, 109 + feature_index: u32, 110 + feature_id: Uuid, 111 + speed: u32, 112 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 101 113 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 102 - let mut data = vec!(); 114 + let mut data = vec![]; 103 115 for cmd in &self.speeds { 104 116 data.push(cmd.load(std::sync::atomic::Ordering::Relaxed)); 105 117 }
+18 -14
crates/buttplug_server/src/device/protocol/vorze_sa/dual_rotator.rs
··· 7 7 8 8 use uuid::{uuid, Uuid}; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{ 14 - vorze_sa::VorzeDevice, ProtocolHandler 15 - }, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{vorze_sa::VorzeDevice, ProtocolHandler}, 16 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 17 15 use std::sync::atomic::{AtomicI8, Ordering}; 18 16 19 17 // Vorze UFO needs a unified protocol UUID since we update both outputs in the same packet. ··· 21 19 22 20 #[derive(Default)] 23 21 pub struct VorzeSADualRotator { 24 - speeds: [AtomicI8; 2] 22 + speeds: [AtomicI8; 2], 25 23 } 26 24 27 25 impl ProtocolHandler for VorzeSADualRotator { 28 26 fn handle_rotation_with_direction_cmd( 29 - &self, 30 - feature_index: u32, 31 - _feature_id: uuid::Uuid, 32 - speed: u32, 33 - clockwise: bool, 34 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 35 - self.speeds[feature_index as usize].store(if clockwise { speed as i8 } else { -(speed as i8) }, Ordering::Relaxed); 27 + &self, 28 + feature_index: u32, 29 + _feature_id: uuid::Uuid, 30 + speed: u32, 31 + clockwise: bool, 32 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 33 + self.speeds[feature_index as usize].store( 34 + if clockwise { 35 + speed as i8 36 + } else { 37 + -(speed as i8) 38 + }, 39 + Ordering::Relaxed, 40 + ); 36 41 let speed_left = self.speeds[0].load(Ordering::Relaxed); 37 42 let data_left = ((speed_left >= 0) as u8) << 7 | (speed_left.unsigned_abs()); 38 43 let speed_right = self.speeds[1].load(Ordering::Relaxed); ··· 45 50 ) 46 51 .into()]) 47 52 } 48 - 49 53 }
+30 -21
crates/buttplug_server/src/device/protocol/vorze_sa/mod.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - mod vibrator; 8 + mod dual_rotator; 9 + mod piston; 9 10 mod single_rotator; 10 - mod piston; 11 - mod dual_rotator; 11 + mod vibrator; 12 12 13 - use buttplug_core::errors::ButtplugDeviceError; 14 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 15 13 use crate::device::{ 16 - hardware::Hardware, 17 - protocol::{ 18 - generic_protocol_initializer_setup, 19 - ProtocolHandler, 20 - ProtocolIdentifier, 21 - ProtocolInitializer, 22 - }, 14 + hardware::Hardware, 15 + protocol::{ 16 + generic_protocol_initializer_setup, 17 + ProtocolHandler, 18 + ProtocolIdentifier, 19 + ProtocolInitializer, 20 + }, 23 21 }; 24 22 use async_trait::async_trait; 23 + use buttplug_core::errors::ButtplugDeviceError; 24 + use buttplug_server_device_config::{ 25 + DeviceDefinition, 26 + ProtocolCommunicationSpecifier, 27 + UserDeviceIdentifier, 28 + }; 25 29 use std::sync::Arc; 26 30 27 31 generic_protocol_initializer_setup!(VorzeSA, "vorze-sa"); ··· 38 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 39 43 if let Some(variant) = def.protocol_variant() { 40 44 let hwname = hardware.name().to_ascii_lowercase(); 41 - match variant.as_str() { 45 + match variant.as_str() { 42 46 "vorze-sa-single-rotator" => { 43 47 if hwname.contains("cycsa") { 44 - Ok(Arc::new(single_rotator::VorzeSASingleRotator::new(VorzeDevice::Cyclone))) 48 + Ok(Arc::new(single_rotator::VorzeSASingleRotator::new( 49 + VorzeDevice::Cyclone, 50 + ))) 45 51 } else if hwname.contains("ufo") { 46 - Ok(Arc::new(single_rotator::VorzeSASingleRotator::new(VorzeDevice::Ufo))) 52 + Ok(Arc::new(single_rotator::VorzeSASingleRotator::new( 53 + VorzeDevice::Ufo, 54 + ))) 47 55 } else { 48 56 Err(ButtplugDeviceError::ProtocolNotImplemented(format!( 49 57 "No protocol implementation for Vorze Device {}", 50 58 hardware.name() 51 - ))) 59 + ))) 52 60 } 53 61 } 54 62 "vorze-sa-dual-rotator" => Ok(Arc::new(dual_rotator::VorzeSADualRotator::default())), ··· 56 64 if hwname.contains("bach") { 57 65 Ok(Arc::new(vibrator::VorzeSAVibrator::new(VorzeDevice::Bach))) 58 66 } else if hwname.contains("rocket") { 59 - Ok(Arc::new(vibrator::VorzeSAVibrator::new(VorzeDevice::Rocket))) 67 + Ok(Arc::new(vibrator::VorzeSAVibrator::new( 68 + VorzeDevice::Rocket, 69 + ))) 60 70 } else { 61 71 Err(ButtplugDeviceError::ProtocolNotImplemented(format!( 62 72 "No protocol implementation for Vorze Device {}", ··· 66 76 } 67 77 "vorze-sa-piston" => Ok(Arc::new(piston::VorzeSAPiston::default())), 68 78 _ => Err(ButtplugDeviceError::ProtocolNotImplemented(format!( 69 - "No protocol implementation for Vorze Device {}", 70 - hardware.name() 71 - ))) 72 - 79 + "No protocol implementation for Vorze Device {}", 80 + hardware.name() 81 + ))), 73 82 } 74 83 } else { 75 84 Err(ButtplugDeviceError::ProtocolNotImplemented(format!(
+9 -11
crates/buttplug_server/src/device/protocol/vorze_sa/piston.rs
··· 1 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 2 1 use crate::device::{ 3 - hardware::{HardwareCommand, HardwareWriteCmd}, 4 - protocol::{ 5 - vorze_sa::VorzeDevice, ProtocolHandler 6 - }, 2 + hardware::{HardwareCommand, HardwareWriteCmd}, 3 + protocol::{vorze_sa::VorzeDevice, ProtocolHandler}, 7 4 }; 5 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 8 6 use std::sync::{ 9 7 atomic::{AtomicU8, Ordering}, 10 8 Arc, ··· 42 40 43 41 impl ProtocolHandler for VorzeSAPiston { 44 42 fn handle_position_with_duration_cmd( 45 - &self, 46 - _feature_index: u32, 47 - feature_id: uuid::Uuid, 48 - position: u32, 49 - duration: u32, 50 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 43 + &self, 44 + _feature_index: u32, 45 + feature_id: uuid::Uuid, 46 + position: u32, 47 + duration: u32, 48 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 51 49 let previous_position = self.previous_position.load(Ordering::Relaxed); 52 50 let position = position as u8; 53 51 let distance = (previous_position as f64 - position as f64).abs();
+14 -15
crates/buttplug_server/src/device/protocol/vorze_sa/single_rotator.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{ 12 - vorze_sa::{VorzeActions, VorzeDevice}, ProtocolHandler, 13 - }, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + vorze_sa::{VorzeActions, VorzeDevice}, 12 + ProtocolHandler, 13 + }, 14 14 }; 15 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 16 16 17 pub struct VorzeSASingleRotator { 17 - device_type: VorzeDevice 18 + device_type: VorzeDevice, 18 19 } 19 20 20 21 impl VorzeSASingleRotator { 21 22 pub fn new(device_type: VorzeDevice) -> Self { 22 - Self { 23 - device_type 24 - } 23 + Self { device_type } 25 24 } 26 25 } 27 26 28 27 impl ProtocolHandler for VorzeSASingleRotator { 29 28 fn handle_rotation_with_direction_cmd( 30 - &self, 31 - _feature_index: u32, 32 - feature_id: uuid::Uuid, 33 - speed: u32, 34 - clockwise: bool, 35 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 29 + &self, 30 + _feature_index: u32, 31 + feature_id: uuid::Uuid, 32 + speed: u32, 33 + clockwise: bool, 34 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 36 35 let clockwise = if clockwise { 1u8 } else { 0 }; 37 36 let data: u8 = (clockwise) << 7 | (speed as u8); 38 37 Ok(vec![HardwareWriteCmd::new(
+13 -14
crates/buttplug_server/src/device/protocol/vorze_sa/vibrator.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 8 use crate::device::{ 10 - hardware::{HardwareCommand, HardwareWriteCmd}, 11 - protocol::{ 12 - vorze_sa::{VorzeActions, VorzeDevice}, ProtocolHandler, 13 - }, 9 + hardware::{HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + vorze_sa::{VorzeActions, VorzeDevice}, 12 + ProtocolHandler, 13 + }, 14 14 }; 15 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 16 16 17 pub struct VorzeSAVibrator { 17 - device_type: VorzeDevice 18 + device_type: VorzeDevice, 18 19 } 19 20 20 21 impl VorzeSAVibrator { 21 22 pub fn new(device_type: VorzeDevice) -> Self { 22 - Self { 23 - device_type 24 - } 23 + Self { device_type } 25 24 } 26 25 } 27 26 28 27 impl ProtocolHandler for VorzeSAVibrator { 29 28 fn handle_output_vibrate_cmd( 30 - &self, 31 - _feature_index: u32, 32 - feature_id: uuid::Uuid, 33 - speed: u32, 34 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 29 + &self, 30 + _feature_index: u32, 31 + feature_id: uuid::Uuid, 32 + speed: u32, 33 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 35 34 Ok(vec![{ 36 35 HardwareWriteCmd::new( 37 36 &[feature_id],
+13 -11
crates/buttplug_server/src/device/protocol/wetoy.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 18 16 }; 19 17 use async_trait::async_trait; 18 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 19 + use buttplug_server_device_config::{ 20 + DeviceDefinition, 21 + ProtocolCommunicationSpecifier, 22 + UserDeviceIdentifier, 23 + }; 20 24 use std::sync::Arc; 21 25 use uuid::{uuid, Uuid}; 22 26 ··· 49 53 pub struct WeToy {} 50 54 51 55 impl ProtocolHandler for WeToy { 52 - 53 - 54 56 fn handle_output_vibrate_cmd( 55 57 &self, 56 58 _feature_index: u32,
+37 -24
crates/buttplug_server/src/device/protocol/wevibe.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::message::OutputType; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 - use buttplug_core::{ 11 - errors::ButtplugDeviceError, 12 - message::Endpoint, 13 - }; 14 8 use crate::device::{ 15 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 16 - protocol::{ 17 - generic_protocol_initializer_setup, 18 - ProtocolHandler, 19 - ProtocolIdentifier, 20 - ProtocolInitializer, 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 21 15 }, 22 16 }; 23 17 use async_trait::async_trait; 24 - use uuid::{uuid, Uuid}; 18 + use buttplug_core::message::OutputType; 19 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 20 + use buttplug_server_device_config::{ 21 + DeviceDefinition, 22 + ProtocolCommunicationSpecifier, 23 + UserDeviceIdentifier, 24 + }; 25 25 use std::sync::atomic::{AtomicU8, Ordering}; 26 26 use std::sync::Arc; 27 + use uuid::{uuid, Uuid}; 27 28 28 29 const WEVIBE_PROTOCOL_UUID: Uuid = uuid!("3658e33d-086d-401e-9dce-8e9e88ff791f"); 29 30 generic_protocol_initializer_setup!(WeVibe, "wevibe"); ··· 55 56 true, 56 57 )) 57 58 .await?; 58 - let num_vibrators = def.features().iter().filter(|x| x.output().as_ref().map_or(false, |x| x.contains_key(&OutputType::Vibrate))).count() as u8; 59 + let num_vibrators = def 60 + .features() 61 + .iter() 62 + .filter(|x| { 63 + x.output() 64 + .as_ref() 65 + .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 66 + }) 67 + .count() as u8; 59 68 Ok(Arc::new(WeVibe::new(num_vibrators))) 60 69 } 61 70 } 62 71 63 72 pub struct WeVibe { 64 73 num_vibrators: u8, 65 - speeds: [AtomicU8; 2] 74 + speeds: [AtomicU8; 2], 66 75 } 67 76 68 77 impl WeVibe { 69 78 fn new(num_vibrators: u8) -> Self { 70 79 Self { 71 80 num_vibrators, 72 - speeds: [AtomicU8::default(), AtomicU8::default()] 81 + speeds: [AtomicU8::default(), AtomicU8::default()], 73 82 } 74 83 } 75 84 } 76 85 77 86 impl ProtocolHandler for WeVibe { 78 - 79 - 80 87 fn handle_output_vibrate_cmd( 81 - &self, 82 - feature_index: u32, 83 - _feature_id: uuid::Uuid, 84 - speed: u32, 85 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 88 + &self, 89 + feature_index: u32, 90 + _feature_id: uuid::Uuid, 91 + speed: u32, 92 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 86 93 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 87 94 let max_vibrators = if self.num_vibrators > 1 { 1 } else { 0 }; 88 95 let r_speed_int = self.speeds[0].load(Ordering::Relaxed); ··· 101 108 0x00, 102 109 ] 103 110 }; 104 - Ok(vec![HardwareWriteCmd::new(&[WEVIBE_PROTOCOL_UUID], Endpoint::Tx, data, true).into()]) 111 + Ok(vec![HardwareWriteCmd::new( 112 + &[WEVIBE_PROTOCOL_UUID], 113 + Endpoint::Tx, 114 + data, 115 + true, 116 + ) 117 + .into()]) 105 118 } 106 119 }
+40 -16
crates/buttplug_server/src/device/protocol/wevibe8bit.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 8 + use std::sync::{ 9 + atomic::{AtomicU8, Ordering}, 10 + Arc, 11 + }; 9 12 10 13 use async_trait::async_trait; 11 14 use uuid::{uuid, Uuid}; 12 15 16 + use crate::device::{ 17 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 18 + protocol::{ 19 + generic_protocol_initializer_setup, 20 + ProtocolCommunicationSpecifier, 21 + ProtocolHandler, 22 + ProtocolIdentifier, 23 + ProtocolInitializer, 24 + }, 25 + }; 13 26 use buttplug_core::{ 14 - errors::ButtplugDeviceError, 15 - message::{Endpoint, OutputType}, 16 - }; 17 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 18 - use crate::device::{ 19 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolInitializer, ProtocolCommunicationSpecifier, ProtocolIdentifier} 27 + errors::ButtplugDeviceError, 28 + message::{Endpoint, OutputType}, 20 29 }; 30 + use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 21 31 22 32 generic_protocol_initializer_setup!(WeVibe8Bit, "wevibe-8bit"); 23 33 ··· 33 43 _hardware: Arc<Hardware>, 34 44 def: &DeviceDefinition, 35 45 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 36 - let num_vibrators = def.features().iter().filter(|x| x.output().as_ref().map_or(false, |x| x.contains_key(&OutputType::Vibrate))).count() as u8; 46 + let num_vibrators = def 47 + .features() 48 + .iter() 49 + .filter(|x| { 50 + x.output() 51 + .as_ref() 52 + .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 53 + }) 54 + .count() as u8; 37 55 Ok(Arc::new(WeVibe8Bit::new(num_vibrators))) 38 56 } 39 57 } 40 58 41 59 pub struct WeVibe8Bit { 42 60 num_vibrators: u8, 43 - speeds: [AtomicU8; 2] 61 + speeds: [AtomicU8; 2], 44 62 } 45 63 46 64 impl WeVibe8Bit { 47 65 fn new(num_vibrators: u8) -> Self { 48 66 Self { 49 67 num_vibrators, 50 - speeds: [AtomicU8::default(), AtomicU8::default()] 68 + speeds: [AtomicU8::default(), AtomicU8::default()], 51 69 } 52 70 } 53 71 } 54 72 55 73 impl ProtocolHandler for WeVibe8Bit { 56 74 fn handle_output_vibrate_cmd( 57 - &self, 58 - feature_index: u32, 59 - _feature_id: uuid::Uuid, 60 - speed: u32, 61 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 75 + &self, 76 + feature_index: u32, 77 + _feature_id: uuid::Uuid, 78 + speed: u32, 79 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 62 80 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 63 81 let max_vibrators = if self.num_vibrators > 1 { 1 } else { 0 }; 64 82 let r_speed_int = self.speeds[0].load(Ordering::Relaxed); ··· 79 97 0x00, 80 98 ] 81 99 }; 82 - Ok(vec![HardwareWriteCmd::new(&[WEVIBE8BIT_PROTOCOL_UUID], Endpoint::Tx, data, true).into()]) 100 + Ok(vec![HardwareWriteCmd::new( 101 + &[WEVIBE8BIT_PROTOCOL_UUID], 102 + Endpoint::Tx, 103 + data, 104 + true, 105 + ) 106 + .into()]) 83 107 } 84 108 }
+40 -18
crates/buttplug_server/src/device/protocol/wevibe_chorus.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use std::sync::{atomic::{AtomicU8, Ordering}, Arc}; 8 + use std::sync::{ 9 + atomic::{AtomicU8, Ordering}, 10 + Arc, 11 + }; 9 12 10 13 use async_trait::async_trait; 11 14 use uuid::{uuid, Uuid}; 12 15 16 + use crate::device::{ 17 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 18 + protocol::{ 19 + generic_protocol_initializer_setup, 20 + ProtocolCommunicationSpecifier, 21 + ProtocolHandler, 22 + ProtocolIdentifier, 23 + ProtocolInitializer, 24 + }, 25 + }; 13 26 use buttplug_core::{ 14 - errors::ButtplugDeviceError, 15 - message::{Endpoint, OutputType}, 16 - }; 17 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 18 - use crate::device::{ 19 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, protocol::{generic_protocol_initializer_setup, ProtocolHandler, ProtocolInitializer, ProtocolCommunicationSpecifier, ProtocolIdentifier} 27 + errors::ButtplugDeviceError, 28 + message::{Endpoint, OutputType}, 20 29 }; 30 + use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 21 31 22 32 generic_protocol_initializer_setup!(WeVibeChorus, "wevibe-chorus"); 23 33 ··· 33 43 _hardware: Arc<Hardware>, 34 44 def: &DeviceDefinition, 35 45 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 36 - let num_vibrators = def.features().iter().filter(|x| x.output().as_ref().map_or(false, |x| x.contains_key(&OutputType::Vibrate))).count() as u8; 46 + let num_vibrators = def 47 + .features() 48 + .iter() 49 + .filter(|x| { 50 + x.output() 51 + .as_ref() 52 + .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 53 + }) 54 + .count() as u8; 37 55 Ok(Arc::new(WeVibeChorus::new(num_vibrators))) 38 56 } 39 57 } 40 58 41 59 pub struct WeVibeChorus { 42 60 num_vibrators: u8, 43 - speeds: [AtomicU8; 2] 61 + speeds: [AtomicU8; 2], 44 62 } 45 63 46 64 impl WeVibeChorus { 47 65 fn new(num_vibrators: u8) -> Self { 48 66 Self { 49 67 num_vibrators, 50 - speeds: [AtomicU8::default(), AtomicU8::default()] 68 + speeds: [AtomicU8::default(), AtomicU8::default()], 51 69 } 52 70 } 53 71 } 54 72 55 73 impl ProtocolHandler for WeVibeChorus { 56 - 57 - 58 74 fn handle_output_vibrate_cmd( 59 - &self, 60 - feature_index: u32, 61 - _feature_id: uuid::Uuid, 62 - speed: u32, 63 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 75 + &self, 76 + feature_index: u32, 77 + _feature_id: uuid::Uuid, 78 + speed: u32, 79 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 64 80 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 65 81 let max_vibrators = if self.num_vibrators > 1 { 1 } else { 0 }; 66 82 let r_speed_int = self.speeds[0].load(Ordering::Relaxed); ··· 82 98 0x00, 83 99 ] 84 100 }; 85 - Ok(vec![HardwareWriteCmd::new(&[WEVIBE_CHORUS_PROTOCOL_UUID], Endpoint::Tx, data, true).into()]) 101 + Ok(vec![HardwareWriteCmd::new( 102 + &[WEVIBE_CHORUS_PROTOCOL_UUID], 103 + Endpoint::Tx, 104 + data, 105 + true, 106 + ) 107 + .into()]) 86 108 } 87 109 }
+3 -5
crates/buttplug_server/src/device/protocol/xibao.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 use std::num::Wrapping; 16 16 17 17 generic_protocol_setup!(Xibao, "xibao"); ··· 20 20 pub struct Xibao {} 21 21 22 22 impl ProtocolHandler for Xibao { 23 - 24 - 25 23 fn handle_output_oscillate_cmd( 26 24 &self, 27 25 _feature_index: u32,
+6 -6
crates/buttplug_server/src/device/protocol/xinput.rs
··· 7 7 8 8 use byteorder::LittleEndian; 9 9 10 - use buttplug_core::{ 11 - errors::ButtplugDeviceError, 12 - message::{self, Endpoint, InputReadingV4, InputType}, 13 - }; 14 10 use crate::device::{ 15 - hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 16 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 13 + }; 14 + use buttplug_core::{ 15 + errors::ButtplugDeviceError, 16 + message::{self, Endpoint, InputReadingV4, InputType}, 17 17 }; 18 18 use byteorder::WriteBytesExt; 19 19 use futures::future::{BoxFuture, FutureExt};
+3 -5
crates/buttplug_server/src/device/protocol/xiuxiuda.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Xiuxiuda, "xiuxiuda"); 17 17 ··· 19 19 pub struct Xiuxiuda {} 20 20 21 21 impl ProtocolHandler for Xiuxiuda { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+17 -10
crates/buttplug_server/src/device/protocol/xuanhuan.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::{async_manager, sleep},}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 10 8 use crate::device::{ 11 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 12 - protocol::{ 13 - generic_protocol_initializer_setup, 14 - ProtocolHandler, 15 - ProtocolIdentifier, 16 - ProtocolInitializer, 17 - }, 18 - 9 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 10 + protocol::{ 11 + generic_protocol_initializer_setup, 12 + ProtocolHandler, 13 + ProtocolIdentifier, 14 + ProtocolInitializer, 15 + }, 19 16 }; 20 17 use async_trait::async_trait; 18 + use buttplug_core::{ 19 + errors::ButtplugDeviceError, 20 + message::Endpoint, 21 + util::{async_manager, sleep}, 22 + }; 23 + use buttplug_server_device_config::{ 24 + DeviceDefinition, 25 + ProtocolCommunicationSpecifier, 26 + UserDeviceIdentifier, 27 + }; 21 28 use std::{ 22 29 sync::{ 23 30 atomic::{AtomicU8, Ordering},
+3 -5
crates/buttplug_server/src/device/protocol/youcups.rs
··· 7 7 8 8 use uuid::Uuid; 9 9 10 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 11 10 use crate::device::{ 12 - hardware::{HardwareCommand, HardwareWriteCmd}, 13 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 14 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 15 15 16 16 generic_protocol_setup!(Youcups, "youcups"); 17 17 ··· 19 19 pub struct Youcups {} 20 20 21 21 impl ProtocolHandler for Youcups { 22 - 23 - 24 22 fn handle_output_vibrate_cmd( 25 23 &self, 26 24 _feature_index: u32,
+7 -3
crates/buttplug_server/src/device/protocol/youou.rs
··· 6 6 // for full license information. 7 7 8 8 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, DeviceDefinition, UserDeviceIdentifier}; 9 + use buttplug_server_device_config::{ 10 + DeviceDefinition, 11 + ProtocolCommunicationSpecifier, 12 + UserDeviceIdentifier, 13 + }; 10 14 11 15 use crate::device::{ 12 - hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 13 - protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 16 + hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 17 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 14 18 }; 15 19 use async_trait::async_trait; 16 20 use std::sync::{
+9 -14
crates/buttplug_server/src/device/protocol/zalo.rs
··· 7 7 8 8 use std::sync::atomic::{AtomicU8, Ordering}; 9 9 10 - use buttplug_core::{ 11 - errors::ButtplugDeviceError, 12 - message::{Endpoint}, 13 - }; 14 10 use crate::device::{ 15 - hardware::{HardwareCommand, HardwareWriteCmd}, 16 - protocol::{generic_protocol_setup, ProtocolHandler}, 11 + hardware::{HardwareCommand, HardwareWriteCmd}, 12 + protocol::{generic_protocol_setup, ProtocolHandler}, 17 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 18 15 19 16 generic_protocol_setup!(Zalo, "zalo"); 20 17 21 18 #[derive(Default)] 22 19 pub struct Zalo { 23 - speeds: [AtomicU8; 2] 20 + speeds: [AtomicU8; 2], 24 21 } 25 22 26 23 impl ProtocolHandler for Zalo { 27 - 28 - 29 24 fn handle_output_vibrate_cmd( 30 - &self, 31 - feature_index: u32, 32 - feature_id: uuid::Uuid, 33 - speed: u32, 34 - ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 25 + &self, 26 + feature_index: u32, 27 + feature_id: uuid::Uuid, 28 + speed: u32, 29 + ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> { 35 30 self.speeds[feature_index as usize].store(speed as u8, Ordering::Relaxed); 36 31 let speed0: u8 = self.speeds[0].load(Ordering::Relaxed); 37 32 let speed1: u8 = self.speeds[1].load(Ordering::Relaxed);
+55 -53
crates/buttplug_server/src/device/server_device.rs
··· 44 44 }; 45 45 46 46 use buttplug_core::{ 47 - errors::{ButtplugDeviceError, ButtplugError}, 48 - message::{ 49 - self, 50 - OutputRotateWithDirection, 51 - OutputType, 52 - OutputValue, 53 - ButtplugServerMessageV4, 54 - DeviceFeature, 55 - DeviceMessageInfoV4, 56 - InputCommandType, 57 - InputType, 58 - }, 59 - ButtplugResultFuture, 60 - util::{self, async_manager, stream::convert_broadcast_receiver_to_stream}, 61 - }; 62 - use buttplug_server_device_config::{DeviceConfigurationManager, DeviceDefinition, UserDeviceIdentifier}; 47 + errors::{ButtplugDeviceError, ButtplugError}, 48 + message::{ 49 + self, 50 + ButtplugServerMessageV4, 51 + DeviceFeature, 52 + DeviceMessageInfoV4, 53 + InputCommandType, 54 + InputType, 55 + OutputRotateWithDirection, 56 + OutputType, 57 + OutputValue, 58 + }, 59 + util::{self, async_manager, stream::convert_broadcast_receiver_to_stream}, 60 + ButtplugResultFuture, 61 + }; 62 + use buttplug_server_device_config::{ 63 + DeviceConfigurationManager, 64 + DeviceDefinition, 65 + UserDeviceIdentifier, 66 + }; 63 67 64 - use crate::{ 65 - device::{ 66 - hardware::{ 67 - Hardware, 68 - HardwareCommand, 69 - HardwareConnector, 70 - HardwareEvent, 71 - }, 72 - protocol::{ProtocolHandler, 73 - ProtocolKeepaliveStrategy, 74 - ProtocolSpecializer, 68 + use crate::{ 69 + device::{ 70 + hardware::{Hardware, HardwareCommand, HardwareConnector, HardwareEvent}, 71 + protocol::{ProtocolHandler, ProtocolKeepaliveStrategy, ProtocolSpecializer}, 75 72 }, 76 - }, 77 - message::{ 78 - checked_output_cmd::CheckedOutputCmdV4, 79 - checked_input_cmd::CheckedInputCmdV4, 80 - server_device_attributes::ServerDeviceAttributes, 81 - spec_enums::ButtplugDeviceCommandMessageUnionV4, 82 - ButtplugServerDeviceMessage, 83 - }, 84 - ButtplugServerResultFuture, 73 + message::{ 74 + checked_input_cmd::CheckedInputCmdV4, 75 + checked_output_cmd::CheckedOutputCmdV4, 76 + server_device_attributes::ServerDeviceAttributes, 77 + spec_enums::ButtplugDeviceCommandMessageUnionV4, 78 + ButtplugServerDeviceMessage, 79 + }, 80 + ButtplugServerResultFuture, 85 81 }; 86 82 use core::hash::{Hash, Hasher}; 87 83 use dashmap::DashMap; 88 84 use futures::future::{self, BoxFuture, FutureExt}; 89 85 use getset::Getters; 90 - use tokio::{select, sync::{mpsc::{channel, Sender}, Mutex}, time::Instant}; 86 + use tokio::{ 87 + select, 88 + sync::{ 89 + mpsc::{channel, Sender}, 90 + Mutex, 91 + }, 92 + time::Instant, 93 + }; 91 94 use tokio_stream::StreamExt; 92 95 use uuid::Uuid; 93 96 ··· 113 116 last_output_command: DashMap<Uuid, CheckedOutputCmdV4>, 114 117 115 118 stop_commands: Vec<ButtplugDeviceCommandMessageUnionV4>, 116 - internal_hw_msg_sender: Sender<Vec<HardwareCommand>> 119 + internal_hw_msg_sender: Sender<Vec<HardwareCommand>>, 117 120 } 118 121 impl Debug for ServerDevice { 119 122 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ··· 187 190 // put it in an unknown state if anything fails. 188 191 189 192 // Check in the DeviceConfigurationManager to make sure we have attributes for this device. 190 - let attrs = if let Some(attrs) = 191 - device_config_manager.device_definition(&identifier) 192 - { 193 + let attrs = if let Some(attrs) = device_config_manager.device_definition(&identifier) { 193 194 attrs 194 195 } else { 195 196 return Err(ButtplugDeviceError::DeviceConfigurationError(format!( ··· 216 217 && matches!( 217 218 strategy, 218 219 ProtocolKeepaliveStrategy::HardwareRequiredRepeatLastPacketStrategy 219 - )) || matches!( 220 + )) 221 + || matches!( 220 222 strategy, 221 223 ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(_) 222 224 ) ··· 250 252 { 251 253 let hardware = hardware.clone(); 252 254 let strategy = handler.keepalive_strategy(); 253 - let strategy_duration = if let ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(duration) = strategy { 254 - Some(duration) 255 - } else { 256 - None 257 - }; 255 + let strategy_duration = 256 + if let ProtocolKeepaliveStrategy::RepeatLastPacketStrategyWithTiming(duration) = strategy { 257 + Some(duration) 258 + } else { 259 + None 260 + }; 258 261 async_manager::spawn(async move { 259 262 let keepalive_packet = Mutex::new(None); 260 263 // TODO This needs to throw system error messages 261 - let send_hw_cmd = async |command| { 264 + let send_hw_cmd = async |command| { 262 265 let _ = hardware.parse_message(&command).await; 263 266 if hardware.requires_keepalive() 264 267 && matches!( ··· 282 285 } else { 283 286 future::pending::<()>().await; 284 287 }; 285 - }; 288 + }; 286 289 select! { 287 290 msg = internal_hw_msg_recv.recv() => { 288 291 if msg.is_none() { ··· 382 385 if let Some(output_map) = feature.output() { 383 386 for actuator_type in output_map.keys() { 384 387 let mut stop_cmd = |actuator_cmd| { 385 - stop_commands.push( 386 - CheckedOutputCmdV4::new(1, 0, index as u32, feature.id(), actuator_cmd).into(), 387 - ); 388 + stop_commands 389 + .push(CheckedOutputCmdV4::new(1, 0, index as u32, feature.id(), actuator_cmd).into()); 388 390 }; 389 391 390 392 // Break out of these if one is found, we only need 1 stop message per output. ··· 441 443 legacy_attributes: ServerDeviceAttributes::new(&definition.features()), 442 444 last_output_command: DashMap::new(), 443 445 stop_commands, 444 - internal_hw_msg_sender 446 + internal_hw_msg_sender, 445 447 } 446 448 } 447 449
+20 -31
crates/buttplug_server/src/device/server_device_manager.rs
··· 8 8 //! Buttplug Device Manager, manages Device Subtype (Platform/Communication bus 9 9 //! specific) Managers 10 10 11 - 12 - use buttplug_core::{ 13 - errors::{ButtplugDeviceError, ButtplugMessageError, ButtplugUnknownError}, 14 - message::{ 15 - self, 16 - ButtplugDeviceMessage, 17 - ButtplugMessage, 18 - ButtplugServerMessageV4, 19 - DeviceListV4, 20 - }, 21 - util::{async_manager, stream::convert_broadcast_receiver_to_stream}, 22 - 23 - }; 24 - use buttplug_server_device_config::{DeviceConfigurationManager, UserDeviceIdentifier}; 25 11 use crate::{ 26 - device::{ 27 - hardware::communication::{ 28 - HardwareCommunicationManager, 29 - HardwareCommunicationManagerBuilder, 30 - }, 31 - server_device_manager_event_loop::ServerDeviceManagerEventLoop, 32 - ServerDevice, 12 + device::{ 13 + hardware::communication::{HardwareCommunicationManager, HardwareCommunicationManagerBuilder}, 14 + server_device_manager_event_loop::ServerDeviceManagerEventLoop, 15 + ServerDevice, 16 + }, 17 + message::{ 18 + server_device_attributes::ServerDeviceAttributes, 19 + spec_enums::{ 20 + ButtplugCheckedClientMessageV4, 21 + ButtplugDeviceCommandMessageUnionV4, 22 + ButtplugDeviceManagerMessageUnion, 33 23 }, 34 - message::{ 35 - server_device_attributes::ServerDeviceAttributes, 36 - spec_enums::{ 37 - ButtplugCheckedClientMessageV4, 38 - ButtplugDeviceCommandMessageUnionV4, 39 - ButtplugDeviceManagerMessageUnion, 40 - }, 41 - }, 42 - ButtplugServerError, 43 - ButtplugServerResultFuture, 24 + }, 25 + ButtplugServerError, 26 + ButtplugServerResultFuture, 27 + }; 28 + use buttplug_core::{ 29 + errors::{ButtplugDeviceError, ButtplugMessageError, ButtplugUnknownError}, 30 + message::{self, ButtplugDeviceMessage, ButtplugMessage, ButtplugServerMessageV4, DeviceListV4}, 31 + util::{async_manager, stream::convert_broadcast_receiver_to_stream}, 44 32 }; 33 + use buttplug_server_device_config::{DeviceConfigurationManager, UserDeviceIdentifier}; 45 34 use dashmap::DashMap; 46 35 use futures::{ 47 36 future::{self, FutureExt},
+23 -12
crates/buttplug_server/src/device/server_device_manager_event_loop.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::{message::{ButtplugServerMessageV4, DeviceAddedV4, DeviceRemovedV0, ScanningFinishedV0}, util::async_manager}; 8 + use buttplug_core::{ 9 + message::{ButtplugServerMessageV4, DeviceAddedV4, DeviceRemovedV0, ScanningFinishedV0}, 10 + util::async_manager, 11 + }; 10 12 use buttplug_server_device_config::DeviceConfigurationManager; 11 13 use tracing::info_span; 12 14 13 - use crate::device::{ 14 - hardware::communication::{HardwareCommunicationManager, HardwareCommunicationManagerEvent}, 15 - ServerDevice, 16 - ServerDeviceEvent, 15 + use crate::device::{ 16 + hardware::communication::{HardwareCommunicationManager, HardwareCommunicationManagerEvent}, 17 + ServerDevice, 18 + ServerDeviceEvent, 17 19 }; 18 20 use dashmap::{DashMap, DashSet}; 19 21 use futures::{future, pin_mut, FutureExt, StreamExt}; ··· 50 52 /// Cancellation token for the event loop 51 53 loop_cancellation_token: CancellationToken, 52 54 /// True if stop scanning message was sent, means we won't send scanning finished. 53 - stop_scanning_received: AtomicBool 55 + stop_scanning_received: AtomicBool, 54 56 } 55 57 56 58 impl ServerDeviceManagerEventLoop { ··· 77 79 scanning_started: false, 78 80 connecting_devices: Arc::new(DashSet::new()), 79 81 loop_cancellation_token, 80 - stop_scanning_received: AtomicBool::new(false) 82 + stop_scanning_received: AtomicBool::new(false), 81 83 } 82 84 } 83 85 ··· 94 96 debug!("System already scanning, ignoring new scanning request"); 95 97 return; 96 98 } 97 - self.stop_scanning_received.store(false, std::sync::atomic::Ordering::Relaxed); 99 + self 100 + .stop_scanning_received 101 + .store(false, std::sync::atomic::Ordering::Relaxed); 98 102 info!("No scan currently in progress, starting new scan."); 99 103 self.scanning_bringup_in_progress = true; 100 104 self.scanning_started = true; ··· 110 114 } 111 115 112 116 async fn handle_stop_scanning(&mut self) { 113 - self.stop_scanning_received.store(true, std::sync::atomic::Ordering::Relaxed); 117 + self 118 + .stop_scanning_received 119 + .store(true, std::sync::atomic::Ordering::Relaxed); 114 120 let fut_vec: Vec<_> = self 115 121 .comm_managers 116 122 .iter_mut() ··· 131 137 return; 132 138 } 133 139 // Only send scanning finished if we haven't requested a stop. 134 - if !self.scanning_status() && self.scanning_started && !self.stop_scanning_received.load(std::sync::atomic::Ordering::Relaxed) { 140 + if !self.scanning_status() 141 + && self.scanning_started 142 + && !self 143 + .stop_scanning_received 144 + .load(std::sync::atomic::Ordering::Relaxed) 145 + { 135 146 debug!("All managers finished, emitting ScanningFinished"); 136 147 self.scanning_started = false; 137 148 if self ··· 185 196 .device_config_manager 186 197 .protocol_specializers(&creator.specifier()); 187 198 */ 188 - let protocol_specializers = vec!(); 199 + let protocol_specializers = vec![]; 189 200 // If we have no identifiers, then there's nothing to do here. Throw an error. 190 201 if protocol_specializers.is_empty() { 191 202 debug!(
+1 -3
crates/buttplug_server/src/message/mod.rs
··· 197 197 impl From<ButtplugServerDeviceMessage> for ButtplugServerMessageV4 { 198 198 fn from(other: ButtplugServerDeviceMessage) -> Self { 199 199 match other { 200 - ButtplugServerDeviceMessage::SensorReading(msg) => { 201 - ButtplugServerMessageV4::InputReading(msg) 202 - } 200 + ButtplugServerDeviceMessage::SensorReading(msg) => ButtplugServerMessageV4::InputReading(msg), 203 201 } 204 202 } 205 203 }
+1 -1
crates/buttplug_server/src/message/server_device_attributes.rs
··· 1 - use super::ServerDeviceMessageAttributesV3; 2 1 use super::v2::ServerDeviceMessageAttributesV2; 2 + use super::ServerDeviceMessageAttributesV3; 3 3 use buttplug_core::errors::ButtplugError; 4 4 use buttplug_server_device_config::ServerDeviceFeature; 5 5 use getset::Getters;
+9 -9
crates/buttplug_server/src/message/v0/server_info.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugMessageError, 10 - message::{ 11 - ButtplugMessage, 12 - ButtplugMessageFinalizer, 13 - ButtplugMessageSpecVersion, 14 - ButtplugMessageValidator, 15 - }, 16 - }; 17 8 use crate::message::ServerInfoV2; 9 + use buttplug_core::{ 10 + errors::ButtplugMessageError, 11 + message::{ 12 + ButtplugMessage, 13 + ButtplugMessageFinalizer, 14 + ButtplugMessageSpecVersion, 15 + ButtplugMessageValidator, 16 + }, 17 + }; 18 18 19 19 use getset::{CopyGetters, Getters}; 20 20 use serde::{Deserialize, Serialize};
+4 -4
crates/buttplug_server/src/message/v0/spec_enums.rs
··· 1 1 use std::cmp::Ordering; 2 2 3 3 use super::*; 4 - use buttplug_core::{ 5 - errors::ButtplugMessageError, 6 - message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, PingV0}, 7 - }; 8 4 use crate::message::RequestServerInfoV1; 5 + use buttplug_core::{ 6 + errors::ButtplugMessageError, 7 + message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, PingV0}, 8 + }; 9 9 10 10 use serde::{Deserialize, Serialize}; 11 11
+1 -1
crates/buttplug_server/src/message/v1/client_device_message_attributes.rs
··· 8 8 use getset::{Getters, Setters}; 9 9 use serde::{Deserialize, Serialize}; 10 10 11 - use buttplug_core::message::DeviceFeature; 12 11 use crate::message::{v2::ClientDeviceMessageAttributesV2, v3::ClientDeviceMessageAttributesV3}; 12 + use buttplug_core::message::DeviceFeature; 13 13 14 14 #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] 15 15 pub struct NullDeviceMessageAttributesV1 {}
+1 -2
crates/buttplug_server/src/message/v1/device_added.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use crate::message::v0::{DeviceAddedV0, DeviceMessageInfoV0}; 8 9 use buttplug_core::{ 9 10 errors::ButtplugMessageError, 10 11 message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator}, 11 12 }; 12 - use crate::message::v0::{DeviceAddedV0, DeviceMessageInfoV0}; 13 - 14 13 15 14 use super::{device_message_info::DeviceMessageInfoV1, ClientDeviceMessageAttributesV1}; 16 15
+4 -4
crates/buttplug_server/src/message/v1/device_list.rs
··· 6 6 // for full license information. 7 7 8 8 use super::device_message_info::DeviceMessageInfoV1; 9 - use buttplug_core::{ 10 - errors::ButtplugMessageError, 11 - message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator}, 12 - }; 13 9 use crate::message::{ 14 10 v0::{DeviceListV0, DeviceMessageInfoV0}, 15 11 v2::DeviceListV2, 12 + }; 13 + use buttplug_core::{ 14 + errors::ButtplugMessageError, 15 + message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator}, 16 16 }; 17 17 use getset::Getters; 18 18 use serde::{Deserialize, Serialize};
+24 -24
crates/buttplug_server/src/message/v1/spec_enums.rs
··· 7 7 8 8 use std::cmp::Ordering; 9 9 10 - use buttplug_core::{ 11 - errors::ButtplugMessageError, 12 - message::{ 13 - ButtplugMessage, 14 - ButtplugMessageFinalizer, 15 - ButtplugMessageValidator, 16 - DeviceRemovedV0, 17 - ErrorV0, 18 - OkV0, 19 - PingV0, 20 - RequestDeviceListV0, 21 - ScanningFinishedV0, 22 - StartScanningV0, 23 - StopAllDevicesV0, 24 - StopDeviceCmdV0, 25 - StopScanningV0, 26 - }, 27 - }; 28 10 use crate::message::v0::{ 29 - ButtplugClientMessageV0, 30 - ButtplugServerMessageV0, 31 - FleshlightLaunchFW12CmdV0, 32 - ServerInfoV0, 33 - SingleMotorVibrateCmdV0, 34 - VorzeA10CycloneCmdV0, 11 + ButtplugClientMessageV0, 12 + ButtplugServerMessageV0, 13 + FleshlightLaunchFW12CmdV0, 14 + ServerInfoV0, 15 + SingleMotorVibrateCmdV0, 16 + VorzeA10CycloneCmdV0, 17 + }; 18 + use buttplug_core::{ 19 + errors::ButtplugMessageError, 20 + message::{ 21 + ButtplugMessage, 22 + ButtplugMessageFinalizer, 23 + ButtplugMessageValidator, 24 + DeviceRemovedV0, 25 + ErrorV0, 26 + OkV0, 27 + PingV0, 28 + RequestDeviceListV0, 29 + ScanningFinishedV0, 30 + StartScanningV0, 31 + StopAllDevicesV0, 32 + StopDeviceCmdV0, 33 + StopScanningV0, 34 + }, 35 35 }; 36 36 use serde::{Deserialize, Serialize}; 37 37
+15 -16
crates/buttplug_server/src/message/v2/battery_level_cmd.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::{ 10 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 11 - message::{ 12 - ButtplugDeviceMessage, 13 - ButtplugMessage, 14 - ButtplugMessageFinalizer, 15 - ButtplugMessageValidator, 16 - InputCommandType, 17 - InputType, 18 - }, 19 - }; 20 - use crate::message::{ 21 - checked_input_cmd::CheckedInputCmdV4, 22 - ServerDeviceAttributes, 23 - TryFromDeviceAttributes, 8 + use crate::message::{ 9 + checked_input_cmd::CheckedInputCmdV4, 10 + ServerDeviceAttributes, 11 + TryFromDeviceAttributes, 12 + }; 13 + use buttplug_core::{ 14 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 15 + message::{ 16 + ButtplugDeviceMessage, 17 + ButtplugMessage, 18 + ButtplugMessageFinalizer, 19 + ButtplugMessageValidator, 20 + InputCommandType, 21 + InputType, 22 + }, 24 23 }; 25 24 use serde::{Deserialize, Serialize}; 26 25
+7 -8
crates/buttplug_server/src/message/v2/client_device_message_attributes.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::message::DeviceFeature; 10 8 use crate::message::{ 11 - v1::{ 12 - ClientDeviceMessageAttributesV1, 13 - GenericDeviceMessageAttributesV1, 14 - NullDeviceMessageAttributesV1, 15 - }, 16 - v3::ClientDeviceMessageAttributesV3, 9 + v1::{ 10 + ClientDeviceMessageAttributesV1, 11 + GenericDeviceMessageAttributesV1, 12 + NullDeviceMessageAttributesV1, 13 + }, 14 + v3::ClientDeviceMessageAttributesV3, 17 15 }; 16 + use buttplug_core::message::DeviceFeature; 18 17 use getset::{CopyGetters, Getters, Setters}; 19 18 use serde::{Deserialize, Serialize}; 20 19
+4 -5
crates/buttplug_server/src/message/v2/device_added.rs
··· 6 6 // for full license information. 7 7 8 8 use super::{device_message_info::DeviceMessageInfoV2, ClientDeviceMessageAttributesV2}; 9 + use crate::message::v1::{DeviceAddedV1, DeviceMessageInfoV1}; 9 10 use buttplug_core::{ 10 - errors::ButtplugMessageError, 11 - message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator}, 12 - }; 13 - use crate::message::v1::{DeviceAddedV1, DeviceMessageInfoV1}; 14 - 11 + errors::ButtplugMessageError, 12 + message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator}, 13 + }; 15 14 16 15 use getset::{CopyGetters, Getters}; 17 16
+7 -8
crates/buttplug_server/src/message/v2/server_device_message_attributes.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::message::{InputType, OutputType}; 10 - use crate::{message::{ 11 - v1::NullDeviceMessageAttributesV1, 12 - ServerDeviceMessageAttributesV3, 13 - ServerGenericDeviceMessageAttributesV3, 14 - }}; 8 + use crate::message::{ 9 + v1::NullDeviceMessageAttributesV1, 10 + ServerDeviceMessageAttributesV3, 11 + ServerGenericDeviceMessageAttributesV3, 12 + }; 13 + use buttplug_core::message::{InputType, OutputType}; 15 14 16 - use buttplug_server_device_config::ServerDeviceFeature; 15 + use buttplug_server_device_config::ServerDeviceFeature; 17 16 18 17 use getset::{CopyGetters, Getters, Setters}; 19 18 use serde::{Deserialize, Serialize};
+25 -31
crates/buttplug_server/src/message/v2/spec_enums.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use crate::message::v1::{ 9 + ButtplugClientMessageV1, 10 + ButtplugServerMessageV1, 11 + LinearCmdV1, 12 + RequestServerInfoV1, 13 + RotateCmdV1, 14 + VibrateCmdV1, 15 + }; 8 16 use buttplug_core::{ 9 - errors::{ButtplugError, ButtplugMessageError}, 10 - message::{ 11 - ButtplugMessage, 12 - ButtplugMessageFinalizer, 13 - ButtplugMessageValidator, 14 - DeviceRemovedV0, 15 - ErrorV0, 16 - OkV0, 17 - PingV0, 18 - RequestDeviceListV0, 19 - ScanningFinishedV0, 20 - StartScanningV0, 21 - StopAllDevicesV0, 22 - StopDeviceCmdV0, 23 - StopScanningV0, 24 - }, 25 - }; 26 - use crate::message::v1::{ 27 - ButtplugClientMessageV1, 28 - ButtplugServerMessageV1, 29 - LinearCmdV1, 30 - RequestServerInfoV1, 31 - RotateCmdV1, 32 - VibrateCmdV1, 17 + errors::{ButtplugError, ButtplugMessageError}, 18 + message::{ 19 + ButtplugMessage, 20 + ButtplugMessageFinalizer, 21 + ButtplugMessageValidator, 22 + DeviceRemovedV0, 23 + ErrorV0, 24 + OkV0, 25 + PingV0, 26 + RequestDeviceListV0, 27 + ScanningFinishedV0, 28 + StartScanningV0, 29 + StopAllDevicesV0, 30 + StopDeviceCmdV0, 31 + StopScanningV0, 32 + }, 33 33 }; 34 34 use serde::{Deserialize, Serialize}; 35 35 36 - use super::{ 37 - BatteryLevelCmdV2, 38 - BatteryLevelReadingV2, 39 - DeviceAddedV2, 40 - DeviceListV2, 41 - ServerInfoV2, 42 - }; 36 + use super::{BatteryLevelCmdV2, BatteryLevelReadingV2, DeviceAddedV2, DeviceListV2, ServerInfoV2}; 43 37 44 38 /// Represents all client-to-server messages in v2 of the Buttplug Spec 45 39 #[derive(
+3 -7
crates/buttplug_server/src/message/v3/client_device_message_attributes.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::message::{OutputType, DeviceFeature, InputCommandType, InputType}; 9 8 use crate::message::{ 10 - v1::NullDeviceMessageAttributesV1, 11 - v2::{ 12 - ClientDeviceMessageAttributesV2, 13 - GenericDeviceMessageAttributesV2, 14 - }, 9 + v1::NullDeviceMessageAttributesV1, 10 + v2::{ClientDeviceMessageAttributesV2, GenericDeviceMessageAttributesV2}, 15 11 }; 12 + use buttplug_core::message::{DeviceFeature, InputCommandType, InputType, OutputType}; 16 13 use getset::{Getters, MutGetters, Setters}; 17 14 use serde::{ser::SerializeSeq, Deserialize, Serialize, Serializer}; 18 15 use std::ops::RangeInclusive; ··· 139 136 } 140 137 141 138 impl ClientDeviceMessageAttributesV3 { 142 - 143 139 pub fn finalize(&mut self) { 144 140 if let Some(scalar_attrs) = &mut self.scalar_cmd { 145 141 for (i, attr) in scalar_attrs.iter_mut().enumerate() {
+7 -7
crates/buttplug_server/src/message/v3/device_added.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{ 9 - errors::ButtplugMessageError, 10 - message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, DeviceAddedV4}, 11 - }; 12 8 use crate::message::{ 13 - v0::DeviceMessageInfoV0, 14 - v1::DeviceMessageInfoV1, 15 - v2::{DeviceAddedV2, DeviceMessageInfoV2}, 9 + v0::DeviceMessageInfoV0, 10 + v1::DeviceMessageInfoV1, 11 + v2::{DeviceAddedV2, DeviceMessageInfoV2}, 12 + }; 13 + use buttplug_core::{ 14 + errors::ButtplugMessageError, 15 + message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, DeviceAddedV4}, 16 16 }; 17 17 18 18 use getset::{CopyGetters, Getters};
+4 -4
crates/buttplug_server/src/message/v3/device_list.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use crate::message::v2::{DeviceListV2, DeviceMessageInfoV2}; 8 9 use buttplug_core::{ 9 - errors::ButtplugMessageError, 10 - message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, DeviceListV4}, 11 - }; 12 - use crate::message::v2::{DeviceListV2, DeviceMessageInfoV2}; 10 + errors::ButtplugMessageError, 11 + message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, DeviceListV4}, 12 + }; 13 13 use getset::Getters; 14 14 use serde::{Deserialize, Serialize}; 15 15
+1 -1
crates/buttplug_server/src/message/v3/device_message_info.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::message::DeviceMessageInfoV4; 9 8 use crate::message::v2::DeviceMessageInfoV2; 9 + use buttplug_core::message::DeviceMessageInfoV4; 10 10 11 11 use super::*; 12 12 use getset::{CopyGetters, Getters, MutGetters};
+1 -1
crates/buttplug_server/src/message/v3/scalar_cmd.rs
··· 8 8 use buttplug_core::{ 9 9 errors::ButtplugMessageError, 10 10 message::{ 11 - OutputType, 12 11 ButtplugDeviceMessage, 13 12 ButtplugMessage, 14 13 ButtplugMessageFinalizer, 15 14 ButtplugMessageValidator, 15 + OutputType, 16 16 }, 17 17 }; 18 18 use getset::{CopyGetters, Getters};
+14 -14
crates/buttplug_server/src/message/v3/sensor_read_cmd.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use crate::message::{ 9 + checked_input_cmd::CheckedInputCmdV4, 10 + ServerDeviceAttributes, 11 + TryFromDeviceAttributes, 12 + }; 8 13 use buttplug_core::{ 9 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 10 - message::{ 11 - ButtplugDeviceMessage, 12 - ButtplugMessage, 13 - ButtplugMessageFinalizer, 14 - ButtplugMessageValidator, 15 - InputCommandType, 16 - InputType, 17 - }, 18 - }; 19 - use crate::message::{ 20 - checked_input_cmd::CheckedInputCmdV4, 21 - ServerDeviceAttributes, 22 - TryFromDeviceAttributes, 14 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 15 + message::{ 16 + ButtplugDeviceMessage, 17 + ButtplugMessage, 18 + ButtplugMessageFinalizer, 19 + ButtplugMessageValidator, 20 + InputCommandType, 21 + InputType, 22 + }, 23 23 }; 24 24 use getset::{CopyGetters, Getters}; 25 25 use serde::{Deserialize, Serialize};
+1 -6
crates/buttplug_server/src/message/v3/sensor_reading.rs
··· 47 47 } 48 48 49 49 impl SensorReadingV3 { 50 - pub fn new( 51 - device_index: u32, 52 - sensor_index: u32, 53 - sensor_type: InputType, 54 - data: Vec<i32>, 55 - ) -> Self { 50 + pub fn new(device_index: u32, sensor_index: u32, sensor_type: InputType, data: Vec<i32>) -> Self { 56 51 Self { 57 52 id: 0, 58 53 device_index,
+5 -8
crates/buttplug_server/src/message/v3/server_device_message_attributes.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::message::{InputType, OutputType}; 10 - use crate::{message::v1::NullDeviceMessageAttributesV1}; 11 - use buttplug_server_device_config::ServerDeviceFeature; 8 + use crate::message::v1::NullDeviceMessageAttributesV1; 9 + use buttplug_core::message::{InputType, OutputType}; 10 + use buttplug_server_device_config::ServerDeviceFeature; 12 11 13 12 use getset::{Getters, MutGetters, Setters}; 14 13 use std::ops::RangeInclusive; ··· 22 21 pub(in crate::message) linear_cmd: Option<Vec<ServerGenericDeviceMessageAttributesV3>>, 23 22 24 23 // Sensor Messages 25 - pub(in crate::message) sensor_read_cmd: 26 - Option<Vec<ServerSensorDeviceMessageAttributesV3>>, 27 - pub(in crate::message) sensor_subscribe_cmd: 28 - Option<Vec<ServerSensorDeviceMessageAttributesV3>>, 24 + pub(in crate::message) sensor_read_cmd: Option<Vec<ServerSensorDeviceMessageAttributesV3>>, 25 + pub(in crate::message) sensor_subscribe_cmd: Option<Vec<ServerSensorDeviceMessageAttributesV3>>, 29 26 30 27 // StopDeviceCmd always exists 31 28 pub(in crate::message) stop_device_cmd: NullDeviceMessageAttributesV1,
+22 -23
crates/buttplug_server/src/message/v3/spec_enums.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::{ 10 - errors::{ButtplugError, ButtplugMessageError}, 11 - message::{ 12 - ButtplugMessage, 13 - ButtplugMessageFinalizer, 14 - ButtplugMessageValidator, 15 - ButtplugServerMessageV4, 16 - DeviceRemovedV0, 17 - ErrorV0, 18 - OkV0, 19 - PingV0, 20 - RequestDeviceListV0, 21 - ScanningFinishedV0, 22 - StartScanningV0, 23 - StopAllDevicesV0, 24 - StopDeviceCmdV0, 25 - StopScanningV0, 26 - }, 27 - }; 28 - use crate::message::{ 29 - v1::{LinearCmdV1, RequestServerInfoV1, RotateCmdV1, VibrateCmdV1}, 30 - v2::{ButtplugClientMessageV2, ButtplugServerMessageV2, ServerInfoV2}, 8 + use crate::message::{ 9 + v1::{LinearCmdV1, RequestServerInfoV1, RotateCmdV1, VibrateCmdV1}, 10 + v2::{ButtplugClientMessageV2, ButtplugServerMessageV2, ServerInfoV2}, 11 + }; 12 + use buttplug_core::{ 13 + errors::{ButtplugError, ButtplugMessageError}, 14 + message::{ 15 + ButtplugMessage, 16 + ButtplugMessageFinalizer, 17 + ButtplugMessageValidator, 18 + ButtplugServerMessageV4, 19 + DeviceRemovedV0, 20 + ErrorV0, 21 + OkV0, 22 + PingV0, 23 + RequestDeviceListV0, 24 + ScanningFinishedV0, 25 + StartScanningV0, 26 + StopAllDevicesV0, 27 + StopDeviceCmdV0, 28 + StopScanningV0, 29 + }, 31 30 }; 32 31 use serde::{Deserialize, Serialize}; 33 32
+12 -12
crates/buttplug_server/src/message/v4/checked_input_cmd.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use crate::message::TryFromDeviceAttributes; 8 9 use buttplug_core::{ 9 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 10 - message::{ 11 - ButtplugDeviceMessage, 12 - ButtplugMessage, 13 - ButtplugMessageFinalizer, 14 - ButtplugMessageValidator, 15 - InputCmdV4, 16 - InputCommandType, 17 - InputType, 18 - }, 19 - }; 20 - use crate::message::TryFromDeviceAttributes; 10 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 11 + message::{ 12 + ButtplugDeviceMessage, 13 + ButtplugMessage, 14 + ButtplugMessageFinalizer, 15 + ButtplugMessageValidator, 16 + InputCmdV4, 17 + InputCommandType, 18 + InputType, 19 + }, 20 + }; 21 21 use getset::CopyGetters; 22 22 use uuid::Uuid; 23 23
+12 -13
crates/buttplug_server/src/message/v4/checked_output_cmd.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::{ 10 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 11 - message::{ 12 - OutputCmdV4, 13 - OutputCommand, 14 - ButtplugDeviceMessage, 15 - ButtplugMessage, 16 - ButtplugMessageFinalizer, 17 - ButtplugMessageValidator, 18 - }, 19 - }; 20 - use crate::message::{ServerDeviceAttributes, TryFromDeviceAttributes}; 8 + use crate::message::{ServerDeviceAttributes, TryFromDeviceAttributes}; 9 + use buttplug_core::{ 10 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 11 + message::{ 12 + ButtplugDeviceMessage, 13 + ButtplugMessage, 14 + ButtplugMessageFinalizer, 15 + ButtplugMessageValidator, 16 + OutputCmdV4, 17 + OutputCommand, 18 + }, 19 + }; 21 20 22 21 use getset::{CopyGetters, Getters}; 23 22 use uuid::Uuid;
+23 -24
crates/buttplug_server/src/message/v4/checked_output_vec_cmd.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use 9 - buttplug_core::{ 10 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 11 - message::{ 12 - OutputCommand, 13 - OutputPositionWithDuration, 14 - OutputRotateWithDirection, 15 - OutputType, 16 - OutputValue, 17 - ButtplugDeviceMessage, 18 - ButtplugMessage, 19 - ButtplugMessageFinalizer, 20 - ButtplugMessageValidator, 21 - }, 22 - }; 23 - use crate::message::{ 24 - v0::SingleMotorVibrateCmdV0, 25 - v1::VibrateCmdV1, 26 - v3::ScalarCmdV3, 27 - ButtplugDeviceMessageNameV3, 28 - LinearCmdV1, 29 - RotateCmdV1, 30 - ServerDeviceAttributes, 31 - TryFromDeviceAttributes, 8 + use crate::message::{ 9 + v0::SingleMotorVibrateCmdV0, 10 + v1::VibrateCmdV1, 11 + v3::ScalarCmdV3, 12 + ButtplugDeviceMessageNameV3, 13 + LinearCmdV1, 14 + RotateCmdV1, 15 + ServerDeviceAttributes, 16 + TryFromDeviceAttributes, 17 + }; 18 + use buttplug_core::{ 19 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 20 + message::{ 21 + ButtplugDeviceMessage, 22 + ButtplugMessage, 23 + ButtplugMessageFinalizer, 24 + ButtplugMessageValidator, 25 + OutputCommand, 26 + OutputPositionWithDuration, 27 + OutputRotateWithDirection, 28 + OutputType, 29 + OutputValue, 30 + }, 32 31 }; 33 32 use getset::{CopyGetters, Getters}; 34 33
+1 -1
crates/buttplug_server/src/message/v4/mod.rs
··· 1 + pub mod checked_input_cmd; 1 2 pub mod checked_output_cmd; 2 3 pub mod checked_output_vec_cmd; 3 - pub mod checked_input_cmd; 4 4 pub mod spec_enums;
+27 -27
crates/buttplug_server/src/message/v4/spec_enums.rs
··· 1 1 use std::{collections::HashMap, fmt::Debug}; 2 2 3 + use crate::message::{ 4 + server_device_attributes::TryFromClientMessage, 5 + v0::ButtplugClientMessageV0, 6 + v1::ButtplugClientMessageV1, 7 + v2::ButtplugClientMessageV2, 8 + v3::ButtplugClientMessageV3, 9 + ButtplugClientMessageVariant, 10 + RequestServerInfoV1, 11 + ServerDeviceAttributes, 12 + TryFromDeviceAttributes, 13 + }; 3 14 use buttplug_core::{ 4 - errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 5 - message::{ 6 - ButtplugClientMessageV4, 7 - ButtplugDeviceMessage, 8 - ButtplugMessage, 9 - ButtplugMessageFinalizer, 10 - ButtplugMessageValidator, 11 - PingV0, 12 - RequestDeviceListV0, 13 - RequestServerInfoV4, 14 - StartScanningV0, 15 - StopAllDevicesV0, 16 - StopDeviceCmdV0, 17 - StopScanningV0, 18 - }, 19 - }; 20 - use crate::message::{ 21 - server_device_attributes::TryFromClientMessage, 22 - v0::ButtplugClientMessageV0, 23 - v1::ButtplugClientMessageV1, 24 - v2::ButtplugClientMessageV2, 25 - v3::ButtplugClientMessageV3, 26 - ButtplugClientMessageVariant, 27 - RequestServerInfoV1, 28 - ServerDeviceAttributes, 29 - TryFromDeviceAttributes, 15 + errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError}, 16 + message::{ 17 + ButtplugClientMessageV4, 18 + ButtplugDeviceMessage, 19 + ButtplugMessage, 20 + ButtplugMessageFinalizer, 21 + ButtplugMessageValidator, 22 + PingV0, 23 + RequestDeviceListV0, 24 + RequestServerInfoV4, 25 + StartScanningV0, 26 + StopAllDevicesV0, 27 + StopDeviceCmdV0, 28 + StopScanningV0, 29 + }, 30 30 }; 31 31 32 32 use super::{ 33 + checked_input_cmd::CheckedInputCmdV4, 33 34 checked_output_cmd::CheckedOutputCmdV4, 34 35 checked_output_vec_cmd::CheckedOutputVecCmdV4, 35 - checked_input_cmd::CheckedInputCmdV4, 36 36 }; 37 37 38 38 /// An CheckedClientMessage has had its contents verified and should need no further error/validity
+4 -1
crates/buttplug_server/src/ping_timer.rs
··· 14 14 }, 15 15 time::Duration, 16 16 }; 17 - use tokio::{select, sync::{mpsc, Notify}}; 17 + use tokio::{ 18 + select, 19 + sync::{mpsc, Notify}, 20 + }; 18 21 19 22 pub enum PingMessage { 20 23 Ping,
+14 -14
crates/buttplug_server/src/server.rs
··· 9 9 device::ServerDeviceManager, 10 10 message::{ 11 11 server_device_attributes::TryFromClientMessage, 12 - ButtplugClientMessageVariant, 13 - ButtplugServerMessageVariant, 14 12 spec_enums::{ 15 13 ButtplugCheckedClientMessageV4, 16 14 ButtplugDeviceCommandMessageUnionV4, 17 15 ButtplugDeviceManagerMessageUnion, 18 16 }, 17 + ButtplugClientMessageVariant, 18 + ButtplugServerMessageVariant, 19 19 }, 20 20 ping_timer::PingTimer, 21 21 server_message_conversion::ButtplugServerMessageConverter, 22 22 ButtplugServerResultFuture, 23 23 }; 24 24 use buttplug_core::{ 25 - errors::*, 26 - message::{ 27 - self, 28 - ButtplugMessage, 29 - ButtplugMessageSpecVersion, 30 - ButtplugServerMessageV4, 31 - ErrorV0, 32 - StopAllDevicesV0, 33 - StopScanningV0, 34 - BUTTPLUG_CURRENT_API_MAJOR_VERSION, 35 - }, 25 + errors::*, 26 + message::{ 27 + self, 28 + ButtplugMessage, 29 + ButtplugMessageSpecVersion, 30 + ButtplugServerMessageV4, 31 + ErrorV0, 32 + StopAllDevicesV0, 33 + StopScanningV0, 34 + BUTTPLUG_CURRENT_API_MAJOR_VERSION, 35 + }, 36 36 util::stream::convert_broadcast_receiver_to_stream, 37 37 }; 38 38 use futures::{ ··· 40 40 Stream, 41 41 }; 42 42 use once_cell::sync::OnceCell; 43 - use tracing::info_span; 44 43 use std::{ 45 44 fmt, 46 45 sync::{ ··· 50 49 }; 51 50 use tokio::sync::broadcast; 52 51 use tokio_stream::StreamExt; 52 + use tracing::info_span; 53 53 use tracing_futures::Instrument; 54 54 55 55 /// The server side of the Buttplug protocol. Frontend for connection to device management and
+4 -7
crates/buttplug_server/src/server_builder.rs
··· 6 6 // for full license information. 7 7 8 8 use super::{ 9 - device::{ 10 - ServerDeviceManager, 11 - ServerDeviceManagerBuilder, 12 - }, 9 + device::{ServerDeviceManager, ServerDeviceManagerBuilder}, 13 10 ping_timer::PingTimer, 14 11 server::ButtplugServer, 15 12 ButtplugServerError, 16 13 }; 17 14 use buttplug_core::{ 18 - errors::*, 19 - message::{self, ButtplugServerMessageV4}, 20 - util::async_manager 15 + errors::*, 16 + message::{self, ButtplugServerMessageV4}, 17 + util::async_manager, 21 18 }; 22 19 use buttplug_server_device_config::DeviceConfigurationManagerBuilder; 23 20 use std::sync::{
+21 -8
crates/buttplug_server_device_config/src/device_configuration.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::{ButtplugDeviceError, ButtplugError}, message::OutputType, util::json::JSONValidator}; 9 8 use super::{ 10 - ServerBaseDeviceFeature, BaseDeviceDefinition, BaseDeviceIdentifier, DeviceConfigurationManager, DeviceConfigurationManagerBuilder, DeviceSettings, ProtocolCommunicationSpecifier, UserDeviceCustomization, UserDeviceDefinition, UserDeviceIdentifier 9 + BaseDeviceDefinition, 10 + BaseDeviceIdentifier, 11 + DeviceConfigurationManager, 12 + DeviceConfigurationManagerBuilder, 13 + DeviceSettings, 14 + ProtocolCommunicationSpecifier, 15 + ServerBaseDeviceFeature, 16 + UserDeviceCustomization, 17 + UserDeviceDefinition, 18 + UserDeviceIdentifier, 19 + }; 20 + use buttplug_core::{ 21 + errors::{ButtplugDeviceError, ButtplugError}, 22 + message::OutputType, 23 + util::json::JSONValidator, 11 24 }; 12 25 use dashmap::DashMap; 13 26 use getset::{CopyGetters, Getters, MutGetters, Setters}; ··· 57 70 identifier: Option<Vec<String>>, 58 71 name: String, 59 72 id: Uuid, 60 - #[serde(skip_serializing_if = "Option::is_none", rename="protocol-variant")] 73 + #[serde(skip_serializing_if = "Option::is_none", rename = "protocol-variant")] 61 74 protocol_variant: Option<String>, 62 75 #[serde(skip_serializing_if = "Option::is_none")] 63 76 features: Option<Vec<ServerBaseDeviceFeature>>, 64 77 #[serde(skip_serializing_if = "Option::is_none")] 65 - device_settings: Option<DeviceSettings> 78 + device_settings: Option<DeviceSettings>, 66 79 } 67 80 68 81 #[derive(Deserialize, Serialize, Debug, Clone, Default, Getters, Setters, MutGetters)] ··· 80 93 #[getset(get = "pub", set = "pub", get_mut = "pub(crate)")] 81 94 struct UserFeatureOutputCustomization { 82 95 step_limit: RangeInclusive<u32>, 83 - reverse_position: bool 96 + reverse_position: bool, 84 97 } 85 98 86 99 #[derive(Deserialize, Serialize, Debug, Clone, Getters, Setters, MutGetters)] ··· 89 102 id: Uuid, 90 103 #[serde(rename = "base-id")] 91 104 base_id: Uuid, 92 - output: HashMap<OutputType, UserFeatureOutputCustomization> 105 + output: HashMap<OutputType, UserFeatureOutputCustomization>, 93 106 } 94 107 95 108 #[derive(Deserialize, Serialize, Debug, Clone, Getters, Setters, MutGetters)] ··· 134 147 .features 135 148 .as_ref() 136 149 .expect("This is a default, therefore we'll always have features."), 137 - &defaults.device_settings 150 + &defaults.device_settings, 138 151 ); 139 152 configurations.insert(None, config_attrs); 140 153 } ··· 155 168 .as_ref() 156 169 .unwrap_or(&vec![]), 157 170 ), 158 - &config.device_settings 171 + &config.device_settings, 159 172 ); 160 173 configurations.insert(Some(identifier.to_owned()), config_attrs); 161 174 }
+86 -36
crates/buttplug_server_device_config/src/device_definitions.rs
··· 4 4 use serde::{Deserialize, Serialize}; 5 5 use uuid::Uuid; 6 6 7 - use buttplug_core::message::OutputType; 8 - use super::device_feature::{ServerBaseDeviceFeature, ServerDeviceFeature, ServerUserDeviceFeature, ServerUserDeviceFeatureOutput}; 7 + use super::device_feature::{ 8 + ServerBaseDeviceFeature, 9 + ServerDeviceFeature, 10 + ServerUserDeviceFeature, 11 + ServerUserDeviceFeatureOutput, 12 + }; 13 + use buttplug_core::message::OutputType; 9 14 10 15 #[derive(Serialize, Deserialize, Debug, Clone, Default, CopyGetters)] 11 16 pub struct DeviceSettings { 12 - #[serde(rename = "message-gap-ms", skip_serializing_if = "Option::is_none", default)] 17 + #[serde( 18 + rename = "message-gap-ms", 19 + skip_serializing_if = "Option::is_none", 20 + default 21 + )] 13 22 #[getset(get_copy = "pub")] 14 23 message_gap_ms: Option<u32>, 15 24 } ··· 22 31 23 32 #[derive(Serialize, Deserialize, Debug, Clone, Default, CopyGetters)] 24 33 pub struct BaseFeatureSettings { 25 - #[serde(rename = "alt-protocol-index", skip_serializing_if = "Option::is_none", default)] 34 + #[serde( 35 + rename = "alt-protocol-index", 36 + skip_serializing_if = "Option::is_none", 37 + default 38 + )] 26 39 #[getset(get_copy = "pub")] 27 40 alt_protocol_index: Option<u32>, 28 41 } ··· 35 48 36 49 #[derive(Serialize, Deserialize, Debug, Clone, Default)] 37 50 pub struct UserFeatureSettings { 38 - #[serde(rename = "reverse-position", skip_serializing_if = "Option::is_none", default)] 39 - reverse_position: Option<bool> 51 + #[serde( 52 + rename = "reverse-position", 53 + skip_serializing_if = "Option::is_none", 54 + default 55 + )] 56 + reverse_position: Option<bool>, 40 57 } 41 58 42 59 impl UserFeatureSettings { ··· 63 80 64 81 impl BaseDeviceDefinition { 65 82 /// Create a new instance 66 - pub fn new(name: &str, id: &Uuid, protocol_variant: &Option<String>, features: &[ServerBaseDeviceFeature], device_settings: &Option<DeviceSettings>) -> Self { 83 + pub fn new( 84 + name: &str, 85 + id: &Uuid, 86 + protocol_variant: &Option<String>, 87 + features: &[ServerBaseDeviceFeature], 88 + device_settings: &Option<DeviceSettings>, 89 + ) -> Self { 67 90 Self { 68 91 name: name.to_owned(), 69 92 features: features.into(), 70 93 id: *id, 71 94 protocol_variant: protocol_variant.clone(), 72 - device_settings: device_settings.clone().unwrap_or_default() 95 + device_settings: device_settings.clone().unwrap_or_default(), 73 96 } 74 97 } 75 98 } 76 99 77 100 #[derive(Serialize, Deserialize, Debug, Getters, CopyGetters, Default, Clone)] 78 101 pub struct UserDeviceCustomization { 79 - #[serde(rename = "display-name", default, skip_serializing_if = "Option::is_none")] 102 + #[serde( 103 + rename = "display-name", 104 + default, 105 + skip_serializing_if = "Option::is_none" 106 + )] 80 107 #[getset(get = "pub")] 81 108 display_name: Option<String>, 82 109 #[serde(default)] ··· 88 115 #[getset(get_copy = "pub")] 89 116 index: u32, 90 117 #[getset(get_copy = "pub")] 91 - #[serde(rename = "message-gap-ms", default, skip_serializing_if = "Option::is_none")] 92 - message_gap_ms: Option<u32> 118 + #[serde( 119 + rename = "message-gap-ms", 120 + default, 121 + skip_serializing_if = "Option::is_none" 122 + )] 123 + message_gap_ms: Option<u32>, 93 124 } 94 125 95 126 impl UserDeviceCustomization { 96 - pub fn new(display_name: &Option<String>, allow: bool, deny: bool, index: u32, message_gap_ms: Option<u32>) -> Self { 127 + pub fn new( 128 + display_name: &Option<String>, 129 + allow: bool, 130 + deny: bool, 131 + index: u32, 132 + message_gap_ms: Option<u32>, 133 + ) -> Self { 97 134 Self { 98 135 display_name: display_name.clone(), 99 136 allow, ··· 113 150 #[getset(get_copy = "pub")] 114 151 id: Uuid, 115 152 #[getset(get_copy = "pub")] 116 - #[serde(rename="base-id")] 153 + #[serde(rename = "base-id")] 117 154 base_id: Uuid, 118 155 #[getset(get = "pub")] 119 156 /// Message attributes for this device instance. 120 - #[getset(get = "pub", get_mut="pub")] 157 + #[getset(get = "pub", get_mut = "pub")] 121 158 features: Vec<ServerUserDeviceFeature>, 122 - #[getset(get = "pub", get_mut="pub")] 123 - #[serde(rename="user-config")] 159 + #[getset(get = "pub", get_mut = "pub")] 160 + #[serde(rename = "user-config")] 124 161 /// Per-user configurations specific to this device instance. 125 162 user_config: UserDeviceCustomization, 126 163 } ··· 131 168 id: Uuid::new_v4(), 132 169 base_id, 133 170 features: features.clone(), 134 - user_config: UserDeviceCustomization::default_with_index(index) 171 + user_config: UserDeviceCustomization::default_with_index(index), 135 172 } 136 173 } 137 174 } ··· 140 177 pub struct DeviceDefinition { 141 178 #[getset(get = "pub")] 142 179 base_device: BaseDeviceDefinition, 143 - #[getset(get = "pub", get_mut="pub")] 180 + #[getset(get = "pub", get_mut = "pub")] 144 181 user_device: UserDeviceDefinition, 145 182 } 146 183 147 184 impl DeviceDefinition { 148 185 /// Create a new instance 149 - pub fn new( 150 - base_device: &BaseDeviceDefinition, 151 - user_device: &UserDeviceDefinition 152 - ) -> Self { 186 + pub fn new(base_device: &BaseDeviceDefinition, user_device: &UserDeviceDefinition) -> Self { 153 187 Self { 154 188 base_device: base_device.clone(), 155 189 user_device: user_device.clone(), ··· 170 204 171 205 pub fn features(&self) -> Vec<ServerDeviceFeature> { 172 206 // TODO Gross way to do this. 173 - let mut features: Vec<ServerDeviceFeature> = vec!(); 174 - self.base_device 175 - .features() 176 - .iter() 177 - .for_each(|x| { 178 - if let Some(user_feature) = self.user_device.features.iter().find(|user_feature| user_feature.base_id() == x.id()) { 179 - features.push(ServerDeviceFeature::new(x, user_feature)); 180 - } 181 - }); 182 - features 207 + let mut features: Vec<ServerDeviceFeature> = vec![]; 208 + self.base_device.features().iter().for_each(|x| { 209 + if let Some(user_feature) = self 210 + .user_device 211 + .features 212 + .iter() 213 + .find(|user_feature| user_feature.base_id() == x.id()) 214 + { 215 + features.push(ServerDeviceFeature::new(x, user_feature)); 216 + } 217 + }); 218 + features 183 219 } 184 220 185 221 pub fn user_config(&self) -> &UserDeviceCustomization { ··· 197 233 } 198 234 199 235 pub fn new_from_base_definition(def: &BaseDeviceDefinition, index: u32) -> Self { 200 - let user_features = def.features().iter().map(|x| x.as_user_device_feature()).collect(); 236 + let user_features = def 237 + .features() 238 + .iter() 239 + .map(|x| x.as_user_device_feature()) 240 + .collect(); 201 241 Self::new( 202 242 def, 203 - &UserDeviceDefinition::new(index, def.id(), &user_features) 243 + &UserDeviceDefinition::new(index, def.id(), &user_features), 204 244 ) 205 245 } 206 246 207 - pub fn update_user_output(&mut self, feature_id: Uuid, output_type: OutputType, user_output: ServerUserDeviceFeatureOutput) { 208 - if let Some(feature) = self.user_device.features_mut().iter_mut().find(|x| x.id() == feature_id) { 247 + pub fn update_user_output( 248 + &mut self, 249 + feature_id: Uuid, 250 + output_type: OutputType, 251 + user_output: ServerUserDeviceFeatureOutput, 252 + ) { 253 + if let Some(feature) = self 254 + .user_device 255 + .features_mut() 256 + .iter_mut() 257 + .find(|x| x.id() == feature_id) 258 + { 209 259 feature.update_output(output_type, &user_output); 210 260 } 211 261 }
+85 -74
crates/buttplug_server_device_config/src/device_feature.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + use super::BaseFeatureSettings; 8 9 use buttplug_core::{ 9 10 errors::ButtplugDeviceError, 10 11 message::{ 11 - DeviceFeature, DeviceFeatureInput, DeviceFeatureOutput, FeatureType, InputCommandType, InputType, OutputType 12 + DeviceFeature, 13 + DeviceFeatureInput, 14 + DeviceFeatureOutput, 15 + FeatureType, 16 + InputCommandType, 17 + InputType, 18 + OutputType, 12 19 }, 13 20 }; 14 - use super::BaseFeatureSettings; 15 21 use getset::{CopyGetters, Getters, MutGetters, Setters}; 16 - use serde::{ser::{self, SerializeSeq}, Deserialize, Serialize, Serializer}; 22 + use serde::{ 23 + ser::{self, SerializeSeq}, 24 + Deserialize, 25 + Serialize, 26 + Serializer, 27 + }; 17 28 use std::{ 18 29 collections::{HashMap, HashSet}, 19 30 ops::RangeInclusive, ··· 30 41 seq.serialize_element(&range.end())?; 31 42 seq.end() 32 43 } else { 33 - Err(ser::Error::custom("shouldn't be serializing if range is None")) 44 + Err(ser::Error::custom( 45 + "shouldn't be serializing if range is None", 46 + )) 34 47 } 35 48 } 36 49 ··· 49 62 } 50 63 51 64 #[derive( 52 - Clone, 53 - Debug, 54 - Default, 55 - Getters, 56 - MutGetters, 57 - Setters, 58 - Serialize, 59 - Deserialize, 60 - CopyGetters, 65 + Clone, Debug, Default, Getters, MutGetters, Setters, Serialize, Deserialize, CopyGetters, 61 66 )] 62 67 pub struct ServerBaseDeviceFeature { 63 68 #[getset(get = "pub", get_mut = "pub(super)")] ··· 77 82 #[getset(get_copy = "pub")] 78 83 id: Uuid, 79 84 #[getset(get = "pub")] 80 - #[serde(rename = "feature-settings", skip_serializing_if = "BaseFeatureSettings::is_none", default)] 81 - feature_settings: BaseFeatureSettings 85 + #[serde( 86 + rename = "feature-settings", 87 + skip_serializing_if = "BaseFeatureSettings::is_none", 88 + default 89 + )] 90 + feature_settings: BaseFeatureSettings, 82 91 } 83 92 84 93 impl ServerBaseDeviceFeature { 85 94 pub fn as_user_device_feature(&self) -> ServerUserDeviceFeature { 86 - ServerUserDeviceFeature { id: Uuid::new_v4(), base_id: self.id, output: self.output.as_ref().and_then(|x| { 87 - Some(x.keys().map(|x| (*x, ServerUserDeviceFeatureOutput::default())).collect()) 88 - }) } 95 + ServerUserDeviceFeature { 96 + id: Uuid::new_v4(), 97 + base_id: self.id, 98 + output: self.output.as_ref().and_then(|x| { 99 + Some( 100 + x.keys() 101 + .map(|x| (*x, ServerUserDeviceFeatureOutput::default())) 102 + .collect(), 103 + ) 104 + }), 105 + } 89 106 } 90 107 } 91 108 92 109 #[derive( 93 - Clone, 94 - Debug, 95 - Default, 96 - Getters, 97 - MutGetters, 98 - Setters, 99 - Serialize, 100 - Deserialize, 101 - CopyGetters, 110 + Clone, Debug, Default, Getters, MutGetters, Setters, Serialize, Deserialize, CopyGetters, 102 111 )] 103 112 pub struct ServerUserDeviceFeature { 104 113 #[getset(get_copy = "pub")] ··· 108 117 base_id: Uuid, 109 118 #[getset(get = "pub")] 110 119 #[serde(rename = "output", skip_serializing_if = "Option::is_none")] 111 - output: Option<HashMap<OutputType, ServerUserDeviceFeatureOutput>>, 120 + output: Option<HashMap<OutputType, ServerUserDeviceFeatureOutput>>, 112 121 } 113 122 114 123 impl ServerUserDeviceFeature { ··· 121 130 } 122 131 } 123 132 124 - #[derive( 125 - Clone, 126 - Debug, 127 - Getters, 128 - MutGetters, 129 - Setters, 130 - Serialize, 131 - Deserialize, 132 - CopyGetters, 133 - )] 133 + #[derive(Clone, Debug, Getters, MutGetters, Setters, Serialize, Deserialize, CopyGetters)] 134 134 pub struct ServerBaseDeviceFeatureOutput { 135 135 #[getset(get = "pub")] 136 136 #[serde(rename = "step-range")] ··· 140 140 impl ServerBaseDeviceFeatureOutput { 141 141 pub fn new(step_range: &RangeInclusive<u32>) -> Self { 142 142 Self { 143 - step_range: step_range.clone() 143 + step_range: step_range.clone(), 144 144 } 145 145 } 146 146 } 147 147 148 148 #[derive( 149 - Clone, 150 - Debug, 151 - Default, 152 - Getters, 153 - MutGetters, 154 - Setters, 155 - Serialize, 156 - Deserialize, 157 - CopyGetters, 149 + Clone, Debug, Default, Getters, MutGetters, Setters, Serialize, Deserialize, CopyGetters, 158 150 )] 159 151 pub struct ServerUserDeviceFeatureOutput { 160 152 #[getset(get = "pub")] 161 - #[serde(rename = "step-limit", default, skip_serializing_if="Option::is_none", serialize_with = "range_serialize")] 153 + #[serde( 154 + rename = "step-limit", 155 + default, 156 + skip_serializing_if = "Option::is_none", 157 + serialize_with = "range_serialize" 158 + )] 162 159 step_limit: Option<RangeInclusive<u32>>, 163 160 #[getset(get = "pub")] 164 - #[serde(rename = "reverse-position", default, skip_serializing_if="Option::is_none")] 161 + #[serde( 162 + rename = "reverse-position", 163 + default, 164 + skip_serializing_if = "Option::is_none" 165 + )] 165 166 reverse_position: Option<bool>, 166 167 #[getset(get = "pub")] 167 - #[serde(rename = "ignore", default, skip_serializing_if="Option::is_none")] 168 + #[serde(rename = "ignore", default, skip_serializing_if = "Option::is_none")] 168 169 ignore: Option<bool>, 169 170 } 170 171 171 172 impl ServerUserDeviceFeatureOutput { 172 - pub fn new(step_limit: Option<RangeInclusive<u32>>, reverse_position: Option<bool>, ignore: Option<bool>) -> Self { 173 + pub fn new( 174 + step_limit: Option<RangeInclusive<u32>>, 175 + reverse_position: Option<bool>, 176 + ignore: Option<bool>, 177 + ) -> Self { 173 178 Self { 174 179 step_limit, 175 180 reverse_position, 176 - ignore 181 + ignore, 177 182 } 178 183 } 179 184 } 180 185 181 - #[derive( 182 - Clone, 183 - Debug, 184 - Default, 185 - Getters, 186 - MutGetters, 187 - Setters, 188 - CopyGetters, 189 - )] 186 + #[derive(Clone, Debug, Default, Getters, MutGetters, Setters, CopyGetters)] 190 187 pub struct ServerDeviceFeature { 191 188 base_feature: ServerBaseDeviceFeature, 192 189 #[getset(get_mut = "pub")] ··· 202 199 } 203 200 } 204 201 205 - impl Eq for ServerDeviceFeature {} 202 + impl Eq for ServerDeviceFeature { 203 + } 206 204 207 205 impl ServerDeviceFeature { 208 206 pub fn new( 209 207 base_feature: &ServerBaseDeviceFeature, 210 - user_feature: &ServerUserDeviceFeature 208 + user_feature: &ServerUserDeviceFeature, 211 209 ) -> Self { 212 210 if base_feature.id() != user_feature.base_id() { 213 211 // TODO panic! ··· 219 217 for (output_type, output_feature) in output_map { 220 218 // TODO What if we have a key in the user map that isn't in the base map? We should remove it. 221 219 if user_output_map.contains_key(output_type) { 222 - output.insert(*output_type, ServerDeviceFeatureOutput::new(output_feature, user_output_map.get(output_type).clone().unwrap())); 220 + output.insert( 221 + *output_type, 222 + ServerDeviceFeatureOutput::new( 223 + output_feature, 224 + user_output_map.get(output_type).clone().unwrap(), 225 + ), 226 + ); 223 227 } 224 228 } 225 229 } ··· 232 236 Self { 233 237 output, 234 238 base_feature: base_feature.clone(), 235 - user_feature: user_feature.clone() 239 + user_feature: user_feature.clone(), 236 240 } 237 241 } 238 242 ··· 241 245 } 242 246 243 247 pub fn feature_type(&self) -> FeatureType { 244 - self.base_feature.feature_type 248 + self.base_feature.feature_type 245 249 } 246 250 247 251 pub fn id(&self) -> Uuid { ··· 251 255 pub fn base_id(&self) -> Uuid { 252 256 self.base_feature.id() 253 257 } 254 - 258 + 255 259 pub fn alt_protocol_index(&self) -> Option<u32> { 256 260 self.base_feature.feature_settings().alt_protocol_index() 257 261 } ··· 293 297 pub struct ServerDeviceFeatureOutput { 294 298 base_feature: ServerBaseDeviceFeatureOutput, 295 299 #[getset(get_mut = "pub")] 296 - user_feature: ServerUserDeviceFeatureOutput 300 + user_feature: ServerUserDeviceFeatureOutput, 297 301 } 298 302 299 303 impl ServerDeviceFeatureOutput { 300 - pub fn new(base_feature: &ServerBaseDeviceFeatureOutput, user_feature: &ServerUserDeviceFeatureOutput) -> Self { 304 + pub fn new( 305 + base_feature: &ServerBaseDeviceFeatureOutput, 306 + user_feature: &ServerUserDeviceFeatureOutput, 307 + ) -> Self { 301 308 Self { 302 309 base_feature: base_feature.clone(), 303 - user_feature: user_feature.clone() 310 + user_feature: user_feature.clone(), 304 311 } 305 312 } 306 313 ··· 318 325 319 326 pub fn step_count(&self) -> u32 { 320 327 if let Some(step_limit) = self.user_feature.step_limit() { 321 - step_limit.end() - step_limit.start() 328 + step_limit.end() - step_limit.start() 322 329 } else { 323 330 self.base_feature.step_range.end() - self.base_feature.step_range.start() 324 331 } 325 332 } 326 333 327 334 pub fn reverse_position(&self) -> bool { 328 - *self.user_feature.reverse_position().as_ref().unwrap_or(&false) 335 + *self 336 + .user_feature 337 + .reverse_position() 338 + .as_ref() 339 + .unwrap_or(&false) 329 340 } 330 341 331 342 pub fn is_valid(&self) -> Result<(), ButtplugDeviceError> { ··· 342 353 } else if step_limit.start() < step_range.start() || step_limit.end() > step_range.end() { 343 354 Err(ButtplugDeviceError::DeviceConfigurationError( 344 355 "Step limit outside step range.".to_string(), 345 - )) 356 + )) 346 357 } else { 347 358 Ok(()) 348 359 }
+69 -64
crates/buttplug_server_device_config/src/lib.rs
··· 210 210 identifier: &UserDeviceIdentifier, 211 211 features: &UserDeviceDefinition, 212 212 ) -> &mut Self { 213 - if let Some((_, base_definition)) = self.base_device_definitions.iter().find(|(_, x)| x.id() == features.base_id()) { 214 - self 215 - .user_device_definitions 216 - .insert(identifier.clone(), DeviceDefinition::new(base_definition, features)); 213 + if let Some((_, base_definition)) = self 214 + .base_device_definitions 215 + .iter() 216 + .find(|(_, x)| x.id() == features.base_id()) 217 + { 218 + self.user_device_definitions.insert( 219 + identifier.clone(), 220 + DeviceDefinition::new(base_definition, features), 221 + ); 217 222 } else { 218 - error!("Cannot find protocol with base id {} for user id {}", features.base_id(), features.id()) 223 + error!( 224 + "Cannot find protocol with base id {} for user id {}", 225 + features.base_id(), 226 + features.id() 227 + ) 219 228 } 220 229 self 221 230 } 222 - /* 223 - /// Add a protocol instance factory for a [ButtplugProtocol] 224 - pub fn protocol_factory<T>(&mut self, factory: T) -> &mut Self 225 - where 226 - T: ProtocolIdentifierFactory + 'static, 227 - { 228 - self 229 - .protocols 230 - .push((factory.identifier().to_owned(), Arc::new(factory))); 231 - self 232 - } 233 - */ 231 + /* 232 + /// Add a protocol instance factory for a [ButtplugProtocol] 233 + pub fn protocol_factory<T>(&mut self, factory: T) -> &mut Self 234 + where 235 + T: ProtocolIdentifierFactory + 'static, 236 + { 237 + self 238 + .protocols 239 + .push((factory.identifier().to_owned(), Arc::new(factory))); 240 + self 241 + } 242 + */ 234 243 pub fn skip_default_protocols(&mut self) -> &mut Self { 235 244 self.skip_default_protocols = true; 236 245 self ··· 360 369 } 361 370 362 371 impl DeviceConfigurationManager { 363 - 364 372 pub fn add_user_communication_specifier( 365 373 &self, 366 374 protocol: &str, ··· 475 483 ) -> HashMap<String, Vec<ProtocolCommunicationSpecifier>> { 476 484 self.base_communication_specifiers.clone() 477 485 } 478 - /* 479 - pub fn protocol_specializers( 480 - &self, 481 - specifier: &ProtocolCommunicationSpecifier, 482 - ) -> Vec<ProtocolSpecializer> { 483 - debug!( 484 - "Looking for protocol that matches specifier: {:?}", 485 - specifier 486 - ); 487 - let mut specializers = vec![]; 486 + /* 487 + pub fn protocol_specializers( 488 + &self, 489 + specifier: &ProtocolCommunicationSpecifier, 490 + ) -> Vec<ProtocolSpecializer> { 491 + debug!( 492 + "Looking for protocol that matches specifier: {:?}", 493 + specifier 494 + ); 495 + let mut specializers = vec![]; 488 496 489 - let mut update_specializer_map = 490 - |name: &str, specifiers: &Vec<ProtocolCommunicationSpecifier>| { 491 - if specifiers.contains(specifier) { 492 - info!( 493 - "Found protocol {:?} for user specifier {:?}.", 494 - name, specifier 495 - ); 496 - 497 - if self.protocol_map.contains_key(name) { 498 - specializers.push(ProtocolSpecializer::new( 499 - specifiers.clone(), 500 - self 501 - .protocol_map 502 - .get(name) 503 - .expect("already checked existence") 504 - .create(), 505 - )); 506 - } else { 507 - warn!( 508 - "No protocol implementation for {:?} found for specifier {:?}.", 497 + let mut update_specializer_map = 498 + |name: &str, specifiers: &Vec<ProtocolCommunicationSpecifier>| { 499 + if specifiers.contains(specifier) { 500 + info!( 501 + "Found protocol {:?} for user specifier {:?}.", 509 502 name, specifier 510 503 ); 504 + 505 + if self.protocol_map.contains_key(name) { 506 + specializers.push(ProtocolSpecializer::new( 507 + specifiers.clone(), 508 + self 509 + .protocol_map 510 + .get(name) 511 + .expect("already checked existence") 512 + .create(), 513 + )); 514 + } else { 515 + warn!( 516 + "No protocol implementation for {:?} found for specifier {:?}.", 517 + name, specifier 518 + ); 519 + } 511 520 } 512 - } 513 - }; 521 + }; 514 522 515 - // Loop through both maps, as chaining between DashMap and HashMap gets kinda gross. 516 - for spec in self.user_communication_specifiers.iter() { 517 - update_specializer_map(spec.key(), spec.value()); 518 - } 519 - for (name, specifiers) in self.base_communication_specifiers.iter() { 520 - update_specializer_map(name, specifiers); 523 + // Loop through both maps, as chaining between DashMap and HashMap gets kinda gross. 524 + for spec in self.user_communication_specifiers.iter() { 525 + update_specializer_map(spec.key(), spec.value()); 526 + } 527 + for (name, specifiers) in self.base_communication_specifiers.iter() { 528 + update_specializer_map(name, specifiers); 529 + } 530 + specializers 521 531 } 522 - specializers 523 - } 524 - */ 525 - pub fn device_definition( 526 - &self, 527 - identifier: &UserDeviceIdentifier, 528 - ) -> Option<DeviceDefinition> { 532 + */ 533 + pub fn device_definition(&self, identifier: &UserDeviceIdentifier) -> Option<DeviceDefinition> { 529 534 let features = if let Some(attrs) = self.user_device_definitions.get(identifier) { 530 535 debug!("User device config found for {:?}", identifier); 531 536 attrs.clone() ··· 677 682 } 678 683 */ 679 684 } 680 - */ 685 + */
+2 -2
crates/buttplug_server_hwmgr_btleplug/src/btleplug_adapter_task.rs
··· 6 6 // for full license information. 7 7 8 8 use super::btleplug_hardware::BtleplugHardwareConnector; 9 - use buttplug_server::device::hardware::communication::HardwareCommunicationManagerEvent; 10 9 use btleplug::{ 11 10 api::{Central, CentralEvent, Manager as _, Peripheral, ScanFilter}, 12 11 platform::{Adapter, Manager, PeripheralId}, 13 12 }; 13 + use buttplug_server::device::hardware::communication::HardwareCommunicationManagerEvent; 14 14 use futures::StreamExt; 15 15 use std::{ 16 16 collections::HashMap, ··· 25 25 sync::mpsc::{Receiver, Sender}, 26 26 time::sleep, 27 27 }; 28 - use uuid::Uuid; 29 28 use tracing::info_span; 29 + use uuid::Uuid; 30 30 31 31 #[derive(Debug, Clone, Copy)] 32 32 pub enum BtleplugAdapterCommand {
+4 -4
crates/buttplug_server_hwmgr_btleplug/src/btleplug_comm_manager.rs
··· 6 6 // for full license information. 7 7 8 8 use super::btleplug_adapter_task::{BtleplugAdapterCommand, BtleplugAdapterTask}; 9 - use buttplug_core::{errors::ButtplugDeviceError, ButtplugResultFuture, util::async_manager}; 9 + use buttplug_core::{errors::ButtplugDeviceError, util::async_manager, ButtplugResultFuture}; 10 10 use buttplug_server::device::hardware::communication::{ 11 - HardwareCommunicationManager, 12 - HardwareCommunicationManagerBuilder, 13 - HardwareCommunicationManagerEvent, 11 + HardwareCommunicationManager, 12 + HardwareCommunicationManagerBuilder, 13 + HardwareCommunicationManagerEvent, 14 14 }; 15 15 use futures::future::FutureExt; 16 16 use std::sync::{
+34 -35
crates/buttplug_server_hwmgr_btleplug/src/btleplug_hardware.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 9 - use buttplug_server_device_config::{BluetoothLESpecifier, ProtocolCommunicationSpecifier}; 10 - use buttplug_server::device::{ 11 - hardware::{ 12 - Hardware, 13 - HardwareConnector, 14 - HardwareEvent, 15 - HardwareInternal, 16 - HardwareReadCmd, 17 - HardwareReading, 18 - HardwareSpecializer, 19 - communication::HardwareSpecificError, 20 - HardwareSubscribeCmd, 21 - HardwareUnsubscribeCmd, 22 - HardwareWriteCmd, 23 - }, 24 - }; 25 8 use async_trait::async_trait; 26 9 use btleplug::api::CharPropFlags; 27 10 use btleplug::{ 28 11 api::{Central, CentralEvent, Characteristic, Peripheral, ValueNotification, WriteType}, 29 12 platform::Adapter, 30 13 }; 14 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 15 + use buttplug_server::device::hardware::{ 16 + communication::HardwareSpecificError, 17 + Hardware, 18 + HardwareConnector, 19 + HardwareEvent, 20 + HardwareInternal, 21 + HardwareReadCmd, 22 + HardwareReading, 23 + HardwareSpecializer, 24 + HardwareSubscribeCmd, 25 + HardwareUnsubscribeCmd, 26 + HardwareWriteCmd, 27 + }; 28 + use buttplug_server_device_config::{BluetoothLESpecifier, ProtocolCommunicationSpecifier}; 31 29 use dashmap::DashSet; 32 30 use futures::{ 33 31 future::{self, BoxFuture, FutureExt}, ··· 38 36 collections::HashMap, 39 37 fmt::{self, Debug}, 40 38 pin::Pin, 41 - sync::Arc, time::Duration, 39 + sync::Arc, 40 + time::Duration, 42 41 }; 43 42 use tokio::{select, sync::broadcast}; 44 43 use uuid::Uuid; ··· 103 102 { 104 103 if let Err(e) = self.device.connect().await { 105 104 let return_err = ButtplugDeviceError::DeviceSpecificError( 106 - HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!( 107 - "{e:?}" 108 - )).to_string(), 105 + HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!("{e:?}")) 106 + .to_string(), 109 107 ); 110 108 return Err(return_err); 111 109 } ··· 392 390 Err(e) => { 393 391 error!("BTLEPlug device write error: {:?}", e); 394 392 Err(ButtplugDeviceError::DeviceSpecificError( 395 - HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!( 396 - "{e:?}" 397 - )).to_string()), 398 - ) 393 + HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!("{e:?}")) 394 + .to_string(), 395 + )) 399 396 } 400 397 } 401 398 } ··· 424 421 } 425 422 Err(e) => { 426 423 error!("BTLEPlug device read error: {:?}", e); 427 - Err(ButtplugDeviceError::DeviceSpecificError(HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!( 428 - "{e:?}" 429 - )).to_string()), 430 - ) 424 + Err(ButtplugDeviceError::DeviceSpecificError( 425 + HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!("{e:?}")) 426 + .to_string(), 427 + )) 431 428 } 432 429 } 433 430 } ··· 456 453 let device = self.device.clone(); 457 454 async move { 458 455 device.subscribe(&characteristic).await.map_err(|e| { 459 - ButtplugDeviceError::DeviceSpecificError(HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!( 460 - "{e:?}" 461 - )).to_string()) 456 + ButtplugDeviceError::DeviceSpecificError( 457 + HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!("{e:?}")) 458 + .to_string(), 459 + ) 462 460 })?; 463 461 endpoints.insert(endpoint); 464 462 Ok(()) ··· 488 486 let device = self.device.clone(); 489 487 async move { 490 488 device.unsubscribe(&characteristic).await.map_err(|e| { 491 - ButtplugDeviceError::DeviceSpecificError(HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!( 492 - "{e:?}" 493 - )).to_string()) 489 + ButtplugDeviceError::DeviceSpecificError( 490 + HardwareSpecificError::HardwareSpecificError("btleplug".to_owned(), format!("{e:?}")) 491 + .to_string(), 492 + ) 494 493 })?; 495 494 endpoints.remove(&endpoint); 496 495 Ok(())
+7 -7
crates/buttplug_server_hwmgr_hid/src/hid_comm_manager.rs
··· 1 + use async_trait::async_trait; 1 2 use buttplug_core::errors::ButtplugDeviceError; 2 3 use buttplug_server::device::hardware::communication::{ 3 - HardwareCommunicationManager, 4 - HardwareCommunicationManagerBuilder, 5 - HardwareCommunicationManagerEvent, 6 - TimedRetryCommunicationManager, 7 - TimedRetryCommunicationManagerImpl, 4 + HardwareCommunicationManager, 5 + HardwareCommunicationManagerBuilder, 6 + HardwareCommunicationManagerEvent, 7 + TimedRetryCommunicationManager, 8 + TimedRetryCommunicationManagerImpl, 8 9 }; 9 - use async_trait::async_trait; 10 10 use hidapi::HidApi; 11 + use log::*; 11 12 use std::sync::Arc; 12 13 use tokio::sync::mpsc::Sender; 13 - use log::*; 14 14 15 15 use super::hid_device_impl::HidHardwareConnector; 16 16
+15 -17
crates/buttplug_server_hwmgr_hid/src/hid_device_impl.rs
··· 1 1 use super::hidapi_async::HidAsyncDevice; 2 - use buttplug_core::{message::Endpoint, errors::ButtplugDeviceError}; 3 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, VIDPIDSpecifier}; 4 - use buttplug_server::device::{ 5 - hardware::{ 6 - GenericHardwareSpecializer, 7 - Hardware, 8 - HardwareConnector, 9 - HardwareEvent, 10 - HardwareInternal, 11 - HardwareReadCmd, 12 - HardwareReading, 13 - HardwareSpecializer, 14 - HardwareSubscribeCmd, 15 - HardwareUnsubscribeCmd, 16 - HardwareWriteCmd, 17 - }, 18 - }; 19 2 use async_trait::async_trait; 3 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint}; 4 + use buttplug_server::device::hardware::{ 5 + GenericHardwareSpecializer, 6 + Hardware, 7 + HardwareConnector, 8 + HardwareEvent, 9 + HardwareInternal, 10 + HardwareReadCmd, 11 + HardwareReading, 12 + HardwareSpecializer, 13 + HardwareSubscribeCmd, 14 + HardwareUnsubscribeCmd, 15 + HardwareWriteCmd, 16 + }; 17 + use buttplug_server_device_config::{ProtocolCommunicationSpecifier, VIDPIDSpecifier}; 20 18 use futures::{future::BoxFuture, AsyncWriteExt}; 21 19 use hidapi::{DeviceInfo, HidApi}; 22 20 use std::{
-1
crates/buttplug_server_hwmgr_hid/src/lib.rs
··· 6 6 mod hidapi_async; 7 7 8 8 pub use hid_comm_manager::{HidCommunicationManager, HidCommunicationManagerBuilder}; 9 -
+6 -6
crates/buttplug_server_hwmgr_lovense_connect/src/lovense_connect_service_comm_manager.rs
··· 6 6 // for full license information. 7 7 8 8 use super::lovense_connect_service_hardware::LovenseServiceHardwareConnector; 9 + use async_trait::async_trait; 9 10 use buttplug_core::errors::ButtplugDeviceError; 10 11 use buttplug_server::device::hardware::communication::{ 11 - HardwareCommunicationManager, 12 - HardwareCommunicationManagerBuilder, 13 - HardwareCommunicationManagerEvent, 14 - TimedRetryCommunicationManager, 15 - TimedRetryCommunicationManagerImpl, 12 + HardwareCommunicationManager, 13 + HardwareCommunicationManagerBuilder, 14 + HardwareCommunicationManagerEvent, 15 + TimedRetryCommunicationManager, 16 + TimedRetryCommunicationManagerImpl, 16 17 }; 17 - use async_trait::async_trait; 18 18 use dashmap::DashSet; 19 19 use reqwest::StatusCode; 20 20 use serde::{Deserialize, Deserializer};
+17 -16
crates/buttplug_server_hwmgr_lovense_connect/src/lovense_connect_service_hardware.rs
··· 6 6 // for full license information. 7 7 8 8 use super::lovense_connect_service_comm_manager::{get_local_info, LovenseServiceToyInfo}; 9 + use async_trait::async_trait; 9 10 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 10 - use buttplug_server_device_config::{LovenseConnectServiceSpecifier, ProtocolCommunicationSpecifier}; 11 - use buttplug_server::device::{ 12 - hardware::{ 13 - GenericHardwareSpecializer, 14 - Hardware, 15 - HardwareConnector, 16 - HardwareEvent, 17 - HardwareInternal, 18 - HardwareReadCmd, 19 - HardwareReading, 20 - HardwareSpecializer, 21 - HardwareSubscribeCmd, 22 - HardwareUnsubscribeCmd, 23 - HardwareWriteCmd, 24 - }, 11 + use buttplug_server::device::hardware::{ 12 + GenericHardwareSpecializer, 13 + Hardware, 14 + HardwareConnector, 15 + HardwareEvent, 16 + HardwareInternal, 17 + HardwareReadCmd, 18 + HardwareReading, 19 + HardwareSpecializer, 20 + HardwareSubscribeCmd, 21 + HardwareUnsubscribeCmd, 22 + HardwareWriteCmd, 23 + }; 24 + use buttplug_server_device_config::{ 25 + LovenseConnectServiceSpecifier, 26 + ProtocolCommunicationSpecifier, 25 27 }; 26 - use async_trait::async_trait; 27 28 use futures::future::{self, BoxFuture, FutureExt}; 28 29 use std::{ 29 30 fmt::{self, Debug},
+16 -17
crates/buttplug_server_hwmgr_lovense_dongle/src/lovense_dongle_hardware.rs
··· 12 12 LovenseDongleOutgoingMessage, 13 13 OutgoingLovenseData, 14 14 }; 15 + use async_trait::async_trait; 15 16 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 17 + use buttplug_server::device::hardware::{ 18 + GenericHardwareSpecializer, 19 + Hardware, 20 + HardwareConnector, 21 + HardwareEvent, 22 + HardwareInternal, 23 + HardwareReadCmd, 24 + HardwareReading, 25 + HardwareSpecializer, 26 + HardwareSubscribeCmd, 27 + HardwareUnsubscribeCmd, 28 + HardwareWriteCmd, 29 + }; 16 30 use buttplug_server_device_config::{BluetoothLESpecifier, ProtocolCommunicationSpecifier}; 17 - use buttplug_server::device::{ 18 - hardware::{ 19 - GenericHardwareSpecializer, 20 - Hardware, 21 - HardwareConnector, 22 - HardwareEvent, 23 - HardwareInternal, 24 - HardwareReadCmd, 25 - HardwareReading, 26 - HardwareSpecializer, 27 - HardwareSubscribeCmd, 28 - HardwareUnsubscribeCmd, 29 - HardwareWriteCmd, 30 - }, 31 - }; 32 - use async_trait::async_trait; 33 31 use futures::future::{self, BoxFuture, FutureExt}; 34 32 use std::{ 35 33 collections::HashMap, ··· 37 35 sync::{ 38 36 atomic::{AtomicBool, Ordering}, 39 37 Arc, 40 - }, time::Duration, 38 + }, 39 + time::Duration, 41 40 }; 42 41 use tokio::sync::{broadcast, mpsc}; 43 42
+1 -1
crates/buttplug_server_hwmgr_lovense_dongle/src/lovense_dongle_state_machine.rs
··· 6 6 // for full license information. 7 7 8 8 use super::{lovense_dongle_hardware::*, lovense_dongle_messages::*}; 9 - use buttplug_server::device::hardware::communication::HardwareCommunicationManagerEvent; 10 9 use async_trait::async_trait; 10 + use buttplug_server::device::hardware::communication::HardwareCommunicationManagerEvent; 11 11 use futures::{pin_mut, select, FutureExt}; 12 12 use std::sync::{ 13 13 atomic::{AtomicBool, Ordering},
+2 -2
crates/buttplug_server_hwmgr_lovense_dongle/src/lovense_hid_dongle_comm_manager.rs
··· 13 13 }, 14 14 lovense_dongle_state_machine::create_lovense_dongle_machine, 15 15 }; 16 - use buttplug_core::{errors::ButtplugDeviceError, ButtplugResultFuture, util::async_manager}; 16 + use buttplug_core::{errors::ButtplugDeviceError, util::async_manager, ButtplugResultFuture}; 17 17 use buttplug_server::device::hardware::communication::{ 18 18 HardwareCommunicationManager, 19 19 HardwareCommunicationManagerBuilder, ··· 30 30 thread, 31 31 }; 32 32 use tokio::{ 33 - select, 34 33 runtime, 34 + select, 35 35 sync::{ 36 36 mpsc::{channel, Receiver, Sender}, 37 37 Mutex,
+6 -6
crates/buttplug_server_hwmgr_serial/src/serialport_comm_manager.rs
··· 8 8 use std::time::Duration; 9 9 10 10 use super::SerialPortHardwareConnector; 11 + use async_trait::async_trait; 11 12 use buttplug_core::errors::ButtplugDeviceError; 12 13 use buttplug_server::device::hardware::communication::{ 13 - HardwareCommunicationManager, 14 - HardwareCommunicationManagerBuilder, 15 - HardwareCommunicationManagerEvent, 16 - TimedRetryCommunicationManager, 17 - TimedRetryCommunicationManagerImpl, 14 + HardwareCommunicationManager, 15 + HardwareCommunicationManagerBuilder, 16 + HardwareCommunicationManagerEvent, 17 + TimedRetryCommunicationManager, 18 + TimedRetryCommunicationManagerImpl, 18 19 }; 19 - use async_trait::async_trait; 20 20 use serialport::available_ports; 21 21 use tokio::sync::mpsc::Sender; 22 22
+19 -18
crates/buttplug_server_hwmgr_serial/src/serialport_hardware.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 - use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 9 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, SerialSpecifier}; 10 - use buttplug_server::device::{ 11 - hardware::{ 12 - Hardware, 13 - HardwareConnector, 14 - HardwareEvent, 15 - HardwareInternal, 16 - HardwareReadCmd, 17 - HardwareReading, 18 - HardwareSpecializer, 19 - communication::HardwareSpecificError, 20 - HardwareSubscribeCmd, 21 - HardwareUnsubscribeCmd, 22 - HardwareWriteCmd, 23 - }, 24 - }; 25 8 use async_trait::async_trait; 9 + use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 10 + use buttplug_server::device::hardware::{ 11 + communication::HardwareSpecificError, 12 + Hardware, 13 + HardwareConnector, 14 + HardwareEvent, 15 + HardwareInternal, 16 + HardwareReadCmd, 17 + HardwareReading, 18 + HardwareSpecializer, 19 + HardwareSubscribeCmd, 20 + HardwareUnsubscribeCmd, 21 + HardwareWriteCmd, 22 + }; 23 + use buttplug_server_device_config::{ProtocolCommunicationSpecifier, SerialSpecifier}; 26 24 use futures::future; 27 25 use futures::{future::BoxFuture, FutureExt}; 28 26 use serialport::{SerialPort, SerialPortInfo}; ··· 228 226 .await 229 227 .expect("This will always be a Some value, we're just blocking for bringup") 230 228 .map_err(|e| { 231 - ButtplugDeviceError::DeviceSpecificError(HardwareSpecificError::HardwareSpecificError("Serial".to_owned(), e.to_string()).to_string()) 229 + ButtplugDeviceError::DeviceSpecificError( 230 + HardwareSpecificError::HardwareSpecificError("Serial".to_owned(), e.to_string()) 231 + .to_string(), 232 + ) 232 233 })?; 233 234 debug!("Serial port received from thread."); 234 235 let (writer_sender, writer_receiver) = mpsc::channel(256);
+1 -1
crates/buttplug_server_hwmgr_websocket/src/lib.rs
··· 12 12 pub mod websocket_server_hardware; 13 13 14 14 pub use websocket_server_comm_manager::*; 15 - pub use websocket_server_hardware::*; 15 + pub use websocket_server_hardware::*;
+5 -5
crates/buttplug_server_hwmgr_websocket/src/websocket_server_comm_manager.rs
··· 6 6 // for full license information. 7 7 8 8 use super::websocket_server_hardware::WebsocketServerHardwareConnector; 9 - use buttplug_core::{ButtplugResultFuture, util::async_manager}; 9 + use buttplug_core::{util::async_manager, ButtplugResultFuture}; 10 10 use buttplug_server::device::hardware::communication::{ 11 - HardwareCommunicationManager, 12 - HardwareCommunicationManagerBuilder, 13 - HardwareCommunicationManagerEvent, 11 + HardwareCommunicationManager, 12 + HardwareCommunicationManagerBuilder, 13 + HardwareCommunicationManagerEvent, 14 14 }; 15 15 use futures::{FutureExt, StreamExt}; 16 16 use getset::{CopyGetters, Getters}; 17 17 use serde::{Deserialize, Serialize}; 18 - use tokio::{select, net::TcpListener, sync::mpsc::Sender}; 18 + use tokio::{net::TcpListener, select, sync::mpsc::Sender}; 19 19 use tokio_util::sync::CancellationToken; 20 20 21 21 // Packet format received from external devices.
+15 -17
crates/buttplug_server_hwmgr_websocket/src/websocket_server_hardware.rs
··· 6 6 // for full license information. 7 7 8 8 use super::websocket_server_comm_manager::WebsocketServerDeviceCommManagerInitInfo; 9 + use async_trait::async_trait; 9 10 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 10 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, WebsocketSpecifier}; 11 - use buttplug_server::device::{ 12 - hardware::{ 13 - GenericHardwareSpecializer, 14 - Hardware, 15 - HardwareConnector, 16 - HardwareEvent, 17 - HardwareInternal, 18 - HardwareReadCmd, 19 - HardwareReading, 20 - HardwareSpecializer, 21 - HardwareSubscribeCmd, 22 - HardwareUnsubscribeCmd, 23 - HardwareWriteCmd, 24 - }, 11 + use buttplug_server::device::hardware::{ 12 + GenericHardwareSpecializer, 13 + Hardware, 14 + HardwareConnector, 15 + HardwareEvent, 16 + HardwareInternal, 17 + HardwareReadCmd, 18 + HardwareReading, 19 + HardwareSpecializer, 20 + HardwareSubscribeCmd, 21 + HardwareUnsubscribeCmd, 22 + HardwareWriteCmd, 25 23 }; 26 - use async_trait::async_trait; 24 + use buttplug_server_device_config::{ProtocolCommunicationSpecifier, WebsocketSpecifier}; 27 25 use futures::{ 28 26 future::{self, BoxFuture}, 29 27 FutureExt, ··· 39 37 time::Duration, 40 38 }; 41 39 use tokio::{ 42 - select, 43 40 net::TcpStream, 41 + select, 44 42 sync::{ 45 43 broadcast, 46 44 mpsc::{channel, Receiver, Sender},
+6 -6
crates/buttplug_server_hwmgr_xinput/src/xinput_device_comm_manager.rs
··· 6 6 // for full license information. 7 7 8 8 use super::xinput_hardware::XInputHardwareConnector; 9 + use async_trait::async_trait; 9 10 use buttplug_core::errors::ButtplugDeviceError; 10 11 use buttplug_server::device::hardware::communication::{ 11 - HardwareCommunicationManager, 12 - HardwareCommunicationManagerBuilder, 13 - HardwareCommunicationManagerEvent, 14 - TimedRetryCommunicationManager, 15 - TimedRetryCommunicationManagerImpl, 12 + HardwareCommunicationManager, 13 + HardwareCommunicationManagerBuilder, 14 + HardwareCommunicationManagerEvent, 15 + TimedRetryCommunicationManager, 16 + TimedRetryCommunicationManagerImpl, 16 17 }; 17 - use async_trait::async_trait; 18 18 use rusty_xinput::XInputHandle; 19 19 use std::string::ToString; 20 20 use tokio::sync::mpsc;
+22 -16
crates/buttplug_server_hwmgr_xinput/src/xinput_hardware.rs
··· 6 6 // for full license information. 7 7 8 8 use super::xinput_device_comm_manager::XInputControllerIndex; 9 + use async_trait::async_trait; 9 10 use buttplug_core::{errors::ButtplugDeviceError, message::Endpoint, util::async_manager}; 10 - use buttplug_server_device_config::{ProtocolCommunicationSpecifier, XInputSpecifier}; 11 11 use buttplug_server::device::hardware::{ 12 - communication::HardwareSpecificError, 13 - GenericHardwareSpecializer, 14 - Hardware, 15 - HardwareConnector, 16 - HardwareEvent, 17 - HardwareInternal, 18 - HardwareReadCmd, 19 - HardwareReading, 20 - HardwareSpecializer, 21 - HardwareSubscribeCmd, 22 - HardwareUnsubscribeCmd, 23 - HardwareWriteCmd, 12 + communication::HardwareSpecificError, 13 + GenericHardwareSpecializer, 14 + Hardware, 15 + HardwareConnector, 16 + HardwareEvent, 17 + HardwareInternal, 18 + HardwareReadCmd, 19 + HardwareReading, 20 + HardwareSpecializer, 21 + HardwareSubscribeCmd, 22 + HardwareUnsubscribeCmd, 23 + HardwareWriteCmd, 24 24 }; 25 - use async_trait::async_trait; 25 + use buttplug_server_device_config::{ProtocolCommunicationSpecifier, XInputSpecifier}; 26 26 use byteorder::{LittleEndian, ReadBytesExt}; 27 27 use futures::future::{self, BoxFuture, FutureExt}; 28 28 use rusty_xinput::{XInputHandle, XInputUsageError}; ··· 144 144 let battery = handle 145 145 .get_gamepad_battery_information(index as u32) 146 146 .map_err(|e| { 147 - ButtplugDeviceError::from(ButtplugDeviceError::DeviceSpecificError(HardwareSpecificError::HardwareSpecificError("Xinput".to_string(), format!("{e:?}")).to_string())) 147 + ButtplugDeviceError::from(ButtplugDeviceError::DeviceSpecificError( 148 + HardwareSpecificError::HardwareSpecificError("Xinput".to_string(), format!("{e:?}")) 149 + .to_string(), 150 + )) 148 151 })?; 149 152 Ok(HardwareReading::new( 150 153 Endpoint::Rx, ··· 172 175 handle 173 176 .set_state(index as u32, left_motor_speed, right_motor_speed) 174 177 .map_err(|e: XInputUsageError| { 175 - ButtplugDeviceError::from(ButtplugDeviceError::DeviceSpecificError(HardwareSpecificError::HardwareSpecificError("Xinput".to_string(), format!("{e:?}")).to_string())) 178 + ButtplugDeviceError::from(ButtplugDeviceError::DeviceSpecificError( 179 + HardwareSpecificError::HardwareSpecificError("Xinput".to_string(), format!("{e:?}")) 180 + .to_string(), 181 + )) 176 182 }) 177 183 } 178 184 .boxed()
+13 -12
crates/buttplug_transport_websocket_tungstenite/src/websocket_client.rs
··· 8 8 //! Handling of websockets using async-tungstenite 9 9 10 10 use buttplug_core::{ 11 - connector::{ 12 - transport::{ 13 - ButtplugConnectorTransport, 14 - ButtplugConnectorTransportSpecificError, 15 - ButtplugTransportIncomingMessage, 16 - }, 17 - ButtplugConnectorError, 18 - ButtplugConnectorResultFuture, 11 + connector::{ 12 + transport::{ 13 + ButtplugConnectorTransport, 14 + ButtplugConnectorTransportSpecificError, 15 + ButtplugTransportIncomingMessage, 19 16 }, 20 - message::serializer::ButtplugSerializedMessage, 17 + ButtplugConnectorError, 18 + ButtplugConnectorResultFuture, 19 + }, 20 + message::serializer::ButtplugSerializedMessage, 21 21 util::async_manager, 22 22 }; 23 23 use futures::{future::BoxFuture, FutureExt, SinkExt, StreamExt}; ··· 30 30 use tokio::{ 31 31 select, 32 32 sync::{ 33 - mpsc::{Receiver, Sender}, 34 - Notify, 35 - }}; 33 + mpsc::{Receiver, Sender}, 34 + Notify, 35 + }, 36 + }; 36 37 use tokio_tungstenite::{ 37 38 connect_async, 38 39 connect_async_tls_with_config,
+10 -10
crates/buttplug_transport_websocket_tungstenite/src/websocket_server.rs
··· 6 6 // for full license information. 7 7 8 8 use buttplug_core::{ 9 - connector::{ 10 - transport::{ 11 - ButtplugConnectorTransport, 12 - ButtplugConnectorTransportSpecificError, 13 - ButtplugTransportIncomingMessage, 14 - }, 15 - ButtplugConnectorError, 16 - ButtplugConnectorResultFuture, 9 + connector::{ 10 + transport::{ 11 + ButtplugConnectorTransport, 12 + ButtplugConnectorTransportSpecificError, 13 + ButtplugTransportIncomingMessage, 17 14 }, 18 - message::serializer::ButtplugSerializedMessage, 15 + ButtplugConnectorError, 16 + ButtplugConnectorResultFuture, 17 + }, 18 + message::serializer::ButtplugSerializedMessage, 19 19 util::async_manager, 20 20 }; 21 21 use futures::{future::BoxFuture, FutureExt, SinkExt, StreamExt}; 22 22 use std::{sync::Arc, time::Duration}; 23 23 use tokio::{ 24 - select, 25 24 net::{TcpListener, TcpStream}, 25 + select, 26 26 sync::{ 27 27 mpsc::{Receiver, Sender}, 28 28 Notify,