Buttplug sex toy control library

chore: Start converting server to using new ServerDeviceDefinition

+177 -149
+3 -3
crates/buttplug_server/src/device/protocol.rs
··· 13 13 }; 14 14 use buttplug_server_device_config::{ 15 15 Endpoint, 16 - DeviceDefinition, 16 + ServerDeviceDefinition, 17 17 ProtocolCommunicationSpecifier, 18 18 UserDeviceIdentifier, 19 19 }; ··· 125 125 async fn initialize( 126 126 &mut self, 127 127 hardware: Arc<Hardware>, 128 - device_definition: &DeviceDefinition, 128 + device_definition: &ServerDeviceDefinition, 129 129 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError>; 130 130 } 131 131 ··· 181 181 async fn initialize( 182 182 &mut self, 183 183 _: Arc<Hardware>, 184 - _: &DeviceDefinition, 184 + _: &ServerDeviceDefinition, 185 185 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 186 186 Ok(self.handler.take().unwrap()) 187 187 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/amorelie_joy.rs
··· 7 7 8 8 use buttplug_core::errors::ButtplugDeviceError; 9 9 use buttplug_server_device_config::Endpoint; 10 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier}; 10 + use buttplug_server_device_config::{ServerDeviceDefinition, UserDeviceIdentifier}; 11 11 12 12 use crate::device::{ 13 13 hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, ··· 35 35 async fn initialize( 36 36 &mut self, 37 37 hardware: Arc<Hardware>, 38 - _: &DeviceDefinition, 38 + _: &ServerDeviceDefinition, 39 39 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 40 40 hardware 41 41 .write_value(&HardwareWriteCmd::new(
+2 -2
crates/buttplug_server/src/device/protocol_impl/ankni.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 37 37 async fn initialize( 38 38 &mut self, 39 39 hardware: Arc<Hardware>, 40 - _: &DeviceDefinition, 40 + _: &ServerDeviceDefinition, 41 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 42 42 let msg = HardwareReadCmd::new(ANKNI_PROTOCOL_UUID, Endpoint::Generic0, 16, 100); 43 43 let reading = hardware.read_value(&msg).await?;
+2 -2
crates/buttplug_server/src/device/protocol_impl/cowgirl_cone.rs
··· 17 17 use async_trait::async_trait; 18 18 use buttplug_core::{errors::ButtplugDeviceError, util::sleep}; 19 19 use buttplug_server_device_config::{ 20 - DeviceDefinition, 20 + ServerDeviceDefinition, 21 21 ProtocolCommunicationSpecifier, 22 22 UserDeviceIdentifier, 23 23 Endpoint, ··· 37 37 async fn initialize( 38 38 &mut self, 39 39 hardware: Arc<Hardware>, 40 - _: &DeviceDefinition, 40 + _: &ServerDeviceDefinition, 41 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 42 42 hardware 43 43 .write_value(&HardwareWriteCmd::new(
+2 -2
crates/buttplug_server/src/device/protocol_impl/foreo.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 35 35 async fn initialize( 36 36 &mut self, 37 37 hardware: Arc<Hardware>, 38 - _: &DeviceDefinition, 38 + _: &ServerDeviceDefinition, 39 39 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 40 40 let lname = hardware.name().to_lowercase(); 41 41 let mut ph = Foreo::default();
+2 -2
crates/buttplug_server/src/device/protocol_impl/fredorch.rs
··· 18 18 use buttplug_core::{errors::ButtplugDeviceError, util::sleep}; 19 19 use buttplug_server_device_config::{ 20 20 Endpoint, 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 89 89 async fn initialize( 90 90 &mut self, 91 91 hardware: Arc<Hardware>, 92 - _: &DeviceDefinition, 92 + _: &ServerDeviceDefinition, 93 93 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 94 94 let mut event_receiver = hardware.event_stream(); 95 95 hardware
+2 -2
crates/buttplug_server/src/device/protocol_impl/fredorch_rotary.rs
··· 21 21 }; 22 22 use buttplug_server_device_config::{ 23 23 Endpoint, 24 - DeviceDefinition, 24 + ServerDeviceDefinition, 25 25 ProtocolCommunicationSpecifier, 26 26 UserDeviceIdentifier, 27 27 }; ··· 48 48 async fn initialize( 49 49 &mut self, 50 50 hardware: Arc<Hardware>, 51 - _: &DeviceDefinition, 51 + _: &ServerDeviceDefinition, 52 52 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 53 53 warn!( 54 54 "FredorchRotary device doesn't provide state feedback. If the device beeps twice, it is powered off and must be reconnected before it can be controlled!"
+2 -2
crates/buttplug_server/src/device/protocol_impl/galaku.rs
··· 18 18 use buttplug_server_device_config::Endpoint; 19 19 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 107 107 async fn initialize( 108 108 &mut self, 109 109 hardware: Arc<Hardware>, 110 - _: &DeviceDefinition, 110 + _: &ServerDeviceDefinition, 111 111 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 112 112 let mut protocol = Galaku::default(); 113 113 protocol.is_caiping_pump_device = false;
+2 -2
crates/buttplug_server/src/device/protocol_impl/hgod.rs
··· 21 21 }; 22 22 use buttplug_server_device_config::{ 23 23 Endpoint, 24 - DeviceDefinition, 24 + ServerDeviceDefinition, 25 25 ProtocolCommunicationSpecifier, 26 26 UserDeviceIdentifier, 27 27 }; ··· 48 48 async fn initialize( 49 49 &mut self, 50 50 hardware: Arc<Hardware>, 51 - _: &DeviceDefinition, 51 + _: &ServerDeviceDefinition, 52 52 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 53 53 Ok(Arc::new(Hgod::new(hardware))) 54 54 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/hismith.rs
··· 14 14 use buttplug_core::errors::ButtplugDeviceError; 15 15 use buttplug_server_device_config::Endpoint; 16 16 use buttplug_server_device_config::{ 17 - DeviceDefinition, 17 + ServerDeviceDefinition, 18 18 ProtocolCommunicationSpecifier, 19 19 UserDeviceIdentifier, 20 20 }; ··· 90 90 async fn initialize( 91 91 &mut self, 92 92 _: Arc<Hardware>, 93 - _: &DeviceDefinition, 93 + _: &ServerDeviceDefinition, 94 94 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 95 95 Ok(Arc::new(Hismith::default())) 96 96 }
+4 -4
crates/buttplug_server/src/device/protocol_impl/hismith_mini.rs
··· 15 15 }; 16 16 use buttplug_server_device_config::{ 17 17 Endpoint, 18 - DeviceDefinition, 18 + ServerDeviceDefinition, 19 19 ProtocolCommunicationSpecifier, 20 20 UserDeviceIdentifier, 21 21 }; ··· 81 81 async fn initialize( 82 82 &mut self, 83 83 _: Arc<Hardware>, 84 - device_definition: &DeviceDefinition, 84 + device_definition: &ServerDeviceDefinition, 85 85 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 86 86 Ok(Arc::new(HismithMini { 87 87 dual_vibe: device_definition 88 88 .features() 89 89 .iter() 90 - .filter(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::Vibrate))) 90 + .filter(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::Vibrate))) 91 91 .count() 92 92 >= 2, 93 93 second_constrict: device_definition 94 94 .features() 95 95 .iter() 96 - .position(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::Constrict))) 96 + .position(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::Constrict))) 97 97 .unwrap_or(0) 98 98 == 1, 99 99 }))
+2 -2
crates/buttplug_server/src/device/protocol_impl/kiiroo_v2.rs
··· 19 19 use buttplug_core::errors::ButtplugDeviceError; 20 20 use buttplug_server_device_config::Endpoint; 21 21 use buttplug_server_device_config::{ 22 - DeviceDefinition, 22 + ServerDeviceDefinition, 23 23 ProtocolCommunicationSpecifier, 24 24 UserDeviceIdentifier, 25 25 }; ··· 40 40 async fn initialize( 41 41 &mut self, 42 42 hardware: Arc<Hardware>, 43 - _: &DeviceDefinition, 43 + _: &ServerDeviceDefinition, 44 44 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 45 45 let msg = HardwareWriteCmd::new( 46 46 &[KIIROO_V2_PROTOCOL_UUID],
+2 -2
crates/buttplug_server/src/device/protocol_impl/kiiroo_v21_initialized.rs
··· 20 20 use buttplug_core::errors::ButtplugDeviceError; 21 21 use buttplug_server_device_config::Endpoint; 22 22 use buttplug_server_device_config::{ 23 - DeviceDefinition, 23 + ServerDeviceDefinition, 24 24 ProtocolCommunicationSpecifier, 25 25 UserDeviceIdentifier, 26 26 }; ··· 42 42 async fn initialize( 43 43 &mut self, 44 44 hardware: Arc<Hardware>, 45 - _: &DeviceDefinition, 45 + _: &ServerDeviceDefinition, 46 46 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 47 47 debug!("calling Onyx+ init"); 48 48 hardware
+2 -2
crates/buttplug_server/src/device/protocol_impl/lelo_harmony.rs
··· 25 25 use buttplug_core::errors::ButtplugDeviceError; 26 26 use buttplug_server_device_config::Endpoint; 27 27 use buttplug_server_device_config::{ 28 - DeviceDefinition, 28 + ServerDeviceDefinition, 29 29 ProtocolCommunicationSpecifier, 30 30 UserDeviceIdentifier, 31 31 }; ··· 43 43 async fn initialize( 44 44 &mut self, 45 45 hardware: Arc<Hardware>, 46 - _: &DeviceDefinition, 46 + _: &ServerDeviceDefinition, 47 47 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 48 48 // The Lelo Harmony has a very specific pairing flow: 49 49 // * First the device is turned on in BLE mode (long press)
+2 -2
crates/buttplug_server/src/device/protocol_impl/lelof1s.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 39 39 async fn initialize( 40 40 &mut self, 41 41 hardware: Arc<Hardware>, 42 - _: &DeviceDefinition, 42 + _: &ServerDeviceDefinition, 43 43 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 44 44 // The Lelo F1s needs you to hit the power button after connection 45 45 // before it'll accept any commands. Unless we listen for event on
+2 -2
crates/buttplug_server/src/device/protocol_impl/lelof1sv2.rs
··· 28 28 use buttplug_core::errors::ButtplugDeviceError; 29 29 use buttplug_server_device_config::Endpoint; 30 30 use buttplug_server_device_config::{ 31 - DeviceDefinition, 31 + ServerDeviceDefinition, 32 32 ProtocolCommunicationSpecifier, 33 33 UserDeviceIdentifier, 34 34 }; ··· 46 46 async fn initialize( 47 47 &mut self, 48 48 hardware: Arc<Hardware>, 49 - _: &DeviceDefinition, 49 + _: &ServerDeviceDefinition, 50 50 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 51 51 let use_harmony = !hardware.endpoints().contains(&Endpoint::Whitelist); 52 52 let sec_endpoint = if use_harmony {
+2 -2
crates/buttplug_server/src/device/protocol_impl/leten.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 37 37 async fn initialize( 38 38 &mut self, 39 39 hardware: Arc<Hardware>, 40 - _: &DeviceDefinition, 40 + _: &ServerDeviceDefinition, 41 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 42 42 // There's a more complex auth flow that the app "sometimes" goes through where it 43 43 // sends [0x04, 0x00] and waits for [0x01] on Rx before calling [0x04, 0x01]
+2 -2
crates/buttplug_server/src/device/protocol_impl/lioness.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 36 36 async fn initialize( 37 37 &mut self, 38 38 hardware: Arc<Hardware>, 39 - _: &DeviceDefinition, 39 + _: &ServerDeviceDefinition, 40 40 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 41 41 hardware 42 42 .subscribe(&HardwareSubscribeCmd::new(
+2 -2
crates/buttplug_server/src/device/protocol_impl/loob.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 37 37 async fn initialize( 38 38 &mut self, 39 39 hardware: Arc<Hardware>, 40 - _: &DeviceDefinition, 40 + _: &ServerDeviceDefinition, 41 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 42 42 let msg = HardwareWriteCmd::new( 43 43 &[LOOB_PROTOCOL_UUID],
+2 -2
crates/buttplug_server/src/device/protocol_impl/lovedistance.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 36 36 async fn initialize( 37 37 &mut self, 38 38 hardware: Arc<Hardware>, 39 - _: &DeviceDefinition, 39 + _: &ServerDeviceDefinition, 40 40 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 41 41 let msg = HardwareWriteCmd::new( 42 42 &[LOVEDISTANCE_PROTOCOL_UUID],
+2 -2
crates/buttplug_server/src/device/protocol_impl/lovehoney_desire.rs
··· 24 24 }; 25 25 use buttplug_core::errors::ButtplugDeviceError; 26 26 use buttplug_server_device_config::Endpoint; 27 - use buttplug_server_device_config::{DeviceDefinition, ProtocolCommunicationSpecifier, UserDeviceIdentifier}; 27 + use buttplug_server_device_config::{ServerDeviceDefinition, ProtocolCommunicationSpecifier, UserDeviceIdentifier}; 28 28 const LOVEHONEY_DESIRE_PROTOCOL_UUID: Uuid = uuid!("5dcd8487-4814-44cb-a768-13bf81d545c0"); 29 29 const LOVEHONEY_DESIRE_VIBE2_PROTOCOL_UUID: Uuid = uuid!("d44a99fe-903b-4fff-bee7-1141767c9cca"); 30 30 ··· 38 38 async fn initialize( 39 39 &mut self, 40 40 _: Arc<Hardware>, 41 - def: &DeviceDefinition, 41 + def: &ServerDeviceDefinition, 42 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 43 43 Ok(Arc::new(LovehoneyDesire::new( 44 44 def
+7 -7
crates/buttplug_server/src/device/protocol_impl/lovense/mod.rs
··· 33 33 util::sleep, 34 34 }; 35 35 use buttplug_server_device_config::{ 36 - DeviceDefinition, 36 + ServerDeviceDefinition, 37 37 ProtocolCommunicationSpecifier, 38 38 UserDeviceIdentifier, 39 39 Endpoint ··· 168 168 async fn initialize( 169 169 &mut self, 170 170 hardware: Arc<Hardware>, 171 - device_definition: &DeviceDefinition, 171 + device_definition: &ServerDeviceDefinition, 172 172 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 173 173 let device_type = self.device_type.clone(); 174 174 175 175 let vibrator_count = device_definition 176 176 .features() 177 177 .iter() 178 - .filter(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::Vibrate) || x.contains_key(&OutputType::Oscillate))) 178 + .filter(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::Vibrate) || x.contains(OutputType::Oscillate))) 179 179 .count(); 180 180 181 181 let output_count = device_definition ··· 188 188 && device_definition 189 189 .features() 190 190 .iter() 191 - .filter(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::Vibrate))) 191 + .filter(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::Vibrate))) 192 192 .count() 193 193 == 1 194 194 && device_definition 195 195 .features() 196 196 .iter() 197 - .filter(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::RotateWithDirection))) 197 + .filter(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::RotateWithDirection))) 198 198 .count() 199 199 == 1; 200 200 ··· 202 202 && device_definition 203 203 .features() 204 204 .iter() 205 - .filter(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::Vibrate))) 205 + .filter(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::Vibrate))) 206 206 .count() 207 207 == 1 208 208 && device_definition 209 209 .features() 210 210 .iter() 211 - .filter(|x| x.output().as_ref().is_some_and(|x| x.contains_key(&OutputType::Constrict))) 211 + .filter(|x| x.output().as_ref().is_some_and(|x| x.contains(OutputType::Constrict))) 212 212 .count() 213 213 == 1; 214 214
+2 -2
crates/buttplug_server/src/device/protocol_impl/magic_motion_v4.rs
··· 13 13 use async_trait::async_trait; 14 14 use uuid::{uuid, Uuid}; 15 15 16 - use buttplug_server_device_config::DeviceDefinition; 16 + use buttplug_server_device_config::ServerDeviceDefinition; 17 17 use crate::device::{ 18 18 hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, 19 19 protocol::{ ··· 38 38 async fn initialize( 39 39 &mut self, 40 40 _: Arc<Hardware>, 41 - def: &DeviceDefinition, 41 + def: &ServerDeviceDefinition, 42 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 43 43 Ok(Arc::new(MagicMotionV4::new( 44 44 def
+4 -4
crates/buttplug_server/src/device/protocol_impl/metaxsire.rs
··· 15 15 errors::ButtplugDeviceError, 16 16 message::OutputType, 17 17 }; 18 - use buttplug_server_device_config::{DeviceDefinition, Endpoint, ProtocolCommunicationSpecifier, UserDeviceIdentifier}; 18 + use buttplug_server_device_config::{ServerDeviceDefinition, Endpoint, ProtocolCommunicationSpecifier, UserDeviceIdentifier}; 19 19 20 20 use crate::device::{ 21 21 hardware::{Hardware, HardwareCommand, HardwareWriteCmd}, ··· 37 37 async fn initialize( 38 38 &mut self, 39 39 _: Arc<Hardware>, 40 - def: &DeviceDefinition, 40 + def: &ServerDeviceDefinition, 41 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 42 42 let mut commands = vec![]; 43 43 def.features().iter().for_each(|x| { 44 44 if let Some(m) = x.output() { 45 - for output in m.keys() { 46 - commands.push((*output, AtomicU8::default())) 45 + for output in m.output_types() { 46 + commands.push((output, AtomicU8::default())) 47 47 } 48 48 } 49 49 });
+2 -2
crates/buttplug_server/src/device/protocol_impl/metaxsire_v2.rs
··· 15 15 use buttplug_core::errors::ButtplugDeviceError; 16 16 use buttplug_server_device_config::Endpoint; 17 17 use buttplug_server_device_config::{ 18 - DeviceDefinition, 18 + ServerDeviceDefinition, 19 19 ProtocolCommunicationSpecifier, 20 20 UserDeviceIdentifier, 21 21 }; ··· 33 33 async fn initialize( 34 34 &mut self, 35 35 hardware: Arc<Hardware>, 36 - _: &DeviceDefinition, 36 + _: &ServerDeviceDefinition, 37 37 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 38 38 hardware 39 39 .write_value(&HardwareWriteCmd::new(
+2 -2
crates/buttplug_server/src/device/protocol_impl/monsterpub.rs
··· 13 13 use buttplug_core::errors::ButtplugDeviceError; 14 14 use buttplug_server_device_config::Endpoint; 15 15 use buttplug_server_device_config::{ 16 - DeviceDefinition, 16 + ServerDeviceDefinition, 17 17 ProtocolCommunicationSpecifier, 18 18 UserDeviceIdentifier, 19 19 }; ··· 86 86 async fn initialize( 87 87 &mut self, 88 88 hardware: Arc<Hardware>, 89 - def: &DeviceDefinition, 89 + def: &ServerDeviceDefinition, 90 90 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 91 91 if hardware.endpoints().contains(&Endpoint::Rx) { 92 92 let value = hardware
+2 -2
crates/buttplug_server/src/device/protocol_impl/mysteryvibe.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 43 43 async fn initialize( 44 44 &mut self, 45 45 hardware: Arc<Hardware>, 46 - def: &DeviceDefinition, 46 + def: &ServerDeviceDefinition, 47 47 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 48 48 let msg = HardwareWriteCmd::new( 49 49 &[MYSTERYVIBE_PROTOCOL_UUID],
+2 -2
crates/buttplug_server/src/device/protocol_impl/mysteryvibe_v2.rs
··· 19 19 use buttplug_core::errors::ButtplugDeviceError; 20 20 use buttplug_server_device_config::Endpoint; 21 21 use buttplug_server_device_config::{ 22 - DeviceDefinition, 22 + ServerDeviceDefinition, 23 23 ProtocolCommunicationSpecifier, 24 24 UserDeviceIdentifier, 25 25 }; ··· 38 38 async fn initialize( 39 39 &mut self, 40 40 hardware: Arc<Hardware>, 41 - def: &DeviceDefinition, 41 + def: &ServerDeviceDefinition, 42 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 43 43 // The only thing that's different about MysteryVibeV2 from v1 is the initialization packet. 44 44 // Just send that then return the older protocol version.
+2 -2
crates/buttplug_server/src/device/protocol_impl/nintendo_joycon.rs
··· 18 18 use buttplug_core::{errors::ButtplugDeviceError, util::{self, async_manager}}; 19 19 use buttplug_server_device_config::{ 20 20 Endpoint, 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 244 244 async fn initialize( 245 245 &mut self, 246 246 hardware: Arc<Hardware>, 247 - _: &DeviceDefinition, 247 + _: &ServerDeviceDefinition, 248 248 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 249 249 send_sub_command(hardware.clone(), 0, 72, &[0x01]) 250 250 .await
+2 -2
crates/buttplug_server/src/device/protocol_impl/nobra.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 36 36 async fn initialize( 37 37 &mut self, 38 38 hardware: Arc<Hardware>, 39 - _: &DeviceDefinition, 39 + _: &ServerDeviceDefinition, 40 40 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 41 41 hardware 42 42 .write_value(&HardwareWriteCmd::new(
+2 -2
crates/buttplug_server/src/device/protocol_impl/patoo.rs
··· 8 8 use buttplug_core::errors::ButtplugDeviceError; 9 9 use buttplug_server_device_config::Endpoint; 10 10 use buttplug_server_device_config::{ 11 - DeviceDefinition, 11 + ServerDeviceDefinition, 12 12 ProtocolCommunicationSpecifier, 13 13 UserDeviceIdentifier, 14 14 }; ··· 73 73 async fn initialize( 74 74 &mut self, 75 75 _: Arc<Hardware>, 76 - _: &DeviceDefinition, 76 + _: &ServerDeviceDefinition, 77 77 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 78 78 Ok(Arc::new(Patoo::default())) 79 79 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/prettylove.rs
··· 13 13 use buttplug_core::errors::ButtplugDeviceError; 14 14 use buttplug_server_device_config::Endpoint; 15 15 use buttplug_server_device_config::{ 16 - DeviceDefinition, 16 + ServerDeviceDefinition, 17 17 ProtocolCommunicationSpecifier, 18 18 UserDeviceIdentifier, 19 19 }; ··· 65 65 async fn initialize( 66 66 &mut self, 67 67 _: Arc<Hardware>, 68 - _: &DeviceDefinition, 68 + _: &ServerDeviceDefinition, 69 69 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 70 70 Ok(Arc::new(PrettyLove::default())) 71 71 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/satisfyer.rs
··· 13 13 use buttplug_core::errors::ButtplugDeviceError; 14 14 use buttplug_server_device_config::Endpoint; 15 15 use buttplug_server_device_config::{ 16 - DeviceDefinition, 16 + ServerDeviceDefinition, 17 17 ProtocolCommunicationSpecifier, 18 18 UserDeviceIdentifier, 19 19 }; ··· 106 106 async fn initialize( 107 107 &mut self, 108 108 hardware: Arc<Hardware>, 109 - device_definition: &DeviceDefinition, 109 + device_definition: &ServerDeviceDefinition, 110 110 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 111 111 let msg = HardwareWriteCmd::new( 112 112 &[SATISFYER_PROTOCOL_UUID],
+3 -3
crates/buttplug_server/src/device/protocol_impl/sensee_v2.rs
··· 10 10 message::OutputType, 11 11 }; 12 12 use buttplug_server_device_config::{ 13 - DeviceDefinition, Endpoint, ProtocolCommunicationSpecifier, UserDeviceIdentifier 13 + ServerDeviceDefinition, Endpoint, ProtocolCommunicationSpecifier, UserDeviceIdentifier 14 14 }; 15 15 16 16 use crate::device::{ ··· 44 44 async fn initialize( 45 45 &mut self, 46 46 hardware: Arc<Hardware>, 47 - device_definition: &DeviceDefinition, 47 + device_definition: &ServerDeviceDefinition, 48 48 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 49 49 let res = hardware 50 50 .read_value(&HardwareReadCmd::new( ··· 70 70 .enumerate() 71 71 .for_each(|(i, x)| { 72 72 if let Some(output_map) = x.output() { 73 - if output_map.contains_key(&output_type) { 73 + if output_map.contains(output_type) { 74 74 map.insert(i as u32, AtomicU8::new(0)); 75 75 } 76 76 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/svakom/mod.rs
··· 21 21 22 22 use buttplug_core::errors::ButtplugDeviceError; 23 23 use buttplug_server_device_config::{ 24 - DeviceDefinition, 24 + ServerDeviceDefinition, 25 25 ProtocolCommunicationSpecifier, 26 26 UserDeviceIdentifier, 27 27 }; ··· 48 48 async fn initialize( 49 49 &mut self, 50 50 hardware: Arc<Hardware>, 51 - def: &DeviceDefinition, 51 + def: &ServerDeviceDefinition, 52 52 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 53 53 if let Some(variant) = def.protocol_variant() { 54 54 match variant.as_str() {
+2 -2
crates/buttplug_server/src/device/protocol_impl/svakom/svakom_sam.rs
··· 19 19 use buttplug_core::errors::ButtplugDeviceError; 20 20 use buttplug_server_device_config::Endpoint; 21 21 use buttplug_server_device_config::{ 22 - DeviceDefinition, 22 + ServerDeviceDefinition, 23 23 ProtocolCommunicationSpecifier, 24 24 UserDeviceIdentifier, 25 25 }; ··· 37 37 async fn initialize( 38 38 &mut self, 39 39 hardware: Arc<Hardware>, 40 - _: &DeviceDefinition, 40 + _: &ServerDeviceDefinition, 41 41 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 42 42 hardware 43 43 .subscribe(&HardwareSubscribeCmd::new(
+3 -3
crates/buttplug_server/src/device/protocol_impl/svakom/svakom_v6.rs
··· 23 23 ProtocolKeepaliveStrategy, 24 24 }, 25 25 }; 26 - use buttplug_server_device_config::{DeviceDefinition, UserDeviceIdentifier, ProtocolCommunicationSpecifier, Endpoint}; 26 + use buttplug_server_device_config::{ServerDeviceDefinition, UserDeviceIdentifier, ProtocolCommunicationSpecifier, Endpoint}; 27 27 use std::sync::{ 28 28 atomic::{AtomicU8, Ordering}, 29 29 Arc, ··· 41 41 async fn initialize( 42 42 &mut self, 43 43 _: Arc<Hardware>, 44 - def: &DeviceDefinition, 44 + def: &ServerDeviceDefinition, 45 45 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 46 46 let num_vibrators = def 47 47 .features() 48 48 .iter() 49 49 .filter(|x| { 50 50 if let Some(output_map) = x.output() { 51 - output_map.contains_key(&OutputType::Vibrate) 51 + output_map.contains(OutputType::Vibrate) 52 52 } else { 53 53 false 54 54 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/thehandy/mod.rs
··· 20 20 use buttplug_core::errors::ButtplugDeviceError; 21 21 use buttplug_server_device_config::Endpoint; 22 22 use buttplug_server_device_config::{ 23 - DeviceDefinition, 23 + ServerDeviceDefinition, 24 24 ProtocolCommunicationSpecifier, 25 25 UserDeviceIdentifier, 26 26 }; ··· 47 47 async fn initialize( 48 48 &mut self, 49 49 _hardware: Arc<Hardware>, 50 - _: &DeviceDefinition, 50 + _: &ServerDeviceDefinition, 51 51 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 52 52 // Ok, somehow this whole function has been basically a no-op. The read/write lines never had an 53 53 // await on them, so they were never run. But only now, in Rust 1.75/Buttplug 7.1.15, have we
+2 -2
crates/buttplug_server/src/device/protocol_impl/vibcrafter.rs
··· 19 19 use buttplug_core::errors::ButtplugDeviceError; 20 20 use buttplug_server_device_config::Endpoint; 21 21 use buttplug_server_device_config::{ 22 - DeviceDefinition, 22 + ServerDeviceDefinition, 23 23 ProtocolCommunicationSpecifier, 24 24 UserDeviceIdentifier, 25 25 }; ··· 68 68 async fn initialize( 69 69 &mut self, 70 70 hardware: Arc<Hardware>, 71 - _: &DeviceDefinition, 71 + _: &ServerDeviceDefinition, 72 72 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 73 73 let mut event_receiver = hardware.event_stream(); 74 74 hardware
+3 -3
crates/buttplug_server/src/device/protocol_impl/vibratissimo.rs
··· 9 9 use buttplug_core::errors::ButtplugDeviceError; 10 10 use buttplug_server_device_config::Endpoint; 11 11 use buttplug_server_device_config::{ 12 - DeviceDefinition, 12 + ServerDeviceDefinition, 13 13 ProtocolCommunicationSpecifier, 14 14 UserDeviceIdentifier, 15 15 }; ··· 76 76 async fn initialize( 77 77 &mut self, 78 78 _: Arc<Hardware>, 79 - def: &DeviceDefinition, 79 + def: &ServerDeviceDefinition, 80 80 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 81 81 let num_vibrators: u8 = def 82 82 .features() ··· 84 84 .filter(|x| { 85 85 x.output() 86 86 .as_ref() 87 - .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 87 + .map_or(false, |x| x.contains(OutputType::Vibrate)) 88 88 }) 89 89 .count() as u8; 90 90 Ok(Arc::new(Vibratissimo::new(num_vibrators as u8)))
+2 -2
crates/buttplug_server/src/device/protocol_impl/vorze_sa/mod.rs
··· 22 22 use async_trait::async_trait; 23 23 use buttplug_core::errors::ButtplugDeviceError; 24 24 use buttplug_server_device_config::{ 25 - DeviceDefinition, 25 + ServerDeviceDefinition, 26 26 ProtocolCommunicationSpecifier, 27 27 UserDeviceIdentifier, 28 28 }; ··· 38 38 async fn initialize( 39 39 &mut self, 40 40 hardware: Arc<Hardware>, 41 - def: &DeviceDefinition, 41 + def: &ServerDeviceDefinition, 42 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 43 43 if let Some(variant) = def.protocol_variant() { 44 44 let hwname = hardware.name().to_ascii_lowercase();
+2 -2
crates/buttplug_server/src/device/protocol_impl/wetoy.rs
··· 18 18 use buttplug_core::errors::ButtplugDeviceError; 19 19 use buttplug_server_device_config::Endpoint; 20 20 use buttplug_server_device_config::{ 21 - DeviceDefinition, 21 + ServerDeviceDefinition, 22 22 ProtocolCommunicationSpecifier, 23 23 UserDeviceIdentifier, 24 24 }; ··· 36 36 async fn initialize( 37 37 &mut self, 38 38 hardware: Arc<Hardware>, 39 - _: &DeviceDefinition, 39 + _: &ServerDeviceDefinition, 40 40 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 41 41 hardware 42 42 .write_value(&HardwareWriteCmd::new(
+3 -3
crates/buttplug_server/src/device/protocol_impl/wevibe.rs
··· 19 19 use buttplug_core::errors::ButtplugDeviceError; 20 20 use buttplug_server_device_config::Endpoint; 21 21 use buttplug_server_device_config::{ 22 - DeviceDefinition, 22 + ServerDeviceDefinition, 23 23 ProtocolCommunicationSpecifier, 24 24 UserDeviceIdentifier, 25 25 }; ··· 38 38 async fn initialize( 39 39 &mut self, 40 40 hardware: Arc<Hardware>, 41 - def: &DeviceDefinition, 41 + def: &ServerDeviceDefinition, 42 42 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 43 43 debug!("calling WeVibe init"); 44 44 hardware ··· 63 63 .filter(|x| { 64 64 x.output() 65 65 .as_ref() 66 - .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 66 + .map_or(false, |x| x.contains(OutputType::Vibrate)) 67 67 }) 68 68 .count() as u8; 69 69 Ok(Arc::new(WeVibe::new(num_vibrators)))
+3 -3
crates/buttplug_server/src/device/protocol_impl/wevibe8bit.rs
··· 26 26 errors::ButtplugDeviceError, 27 27 message::OutputType, 28 28 }; 29 - use buttplug_server_device_config::{Endpoint, DeviceDefinition, UserDeviceIdentifier, ProtocolCommunicationSpecifier}; 29 + use buttplug_server_device_config::{Endpoint, ServerDeviceDefinition, UserDeviceIdentifier, ProtocolCommunicationSpecifier}; 30 30 31 31 generic_protocol_initializer_setup!(WeVibe8Bit, "wevibe-8bit"); 32 32 ··· 40 40 async fn initialize( 41 41 &mut self, 42 42 _hardware: Arc<Hardware>, 43 - def: &DeviceDefinition, 43 + def: &ServerDeviceDefinition, 44 44 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 45 45 let num_vibrators = def 46 46 .features() ··· 48 48 .filter(|x| { 49 49 x.output() 50 50 .as_ref() 51 - .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 51 + .map_or(false, |x| x.contains(OutputType::Vibrate)) 52 52 }) 53 53 .count() as u8; 54 54 Ok(Arc::new(WeVibe8Bit::new(num_vibrators)))
+3 -3
crates/buttplug_server/src/device/protocol_impl/wevibe_chorus.rs
··· 26 26 errors::ButtplugDeviceError, 27 27 message::OutputType, 28 28 }; 29 - use buttplug_server_device_config::{DeviceDefinition, Endpoint, ProtocolCommunicationSpecifier, UserDeviceIdentifier}; 29 + use buttplug_server_device_config::{ServerDeviceDefinition, Endpoint, ProtocolCommunicationSpecifier, UserDeviceIdentifier}; 30 30 31 31 generic_protocol_initializer_setup!(WeVibeChorus, "wevibe-chorus"); 32 32 ··· 40 40 async fn initialize( 41 41 &mut self, 42 42 _hardware: Arc<Hardware>, 43 - def: &DeviceDefinition, 43 + def: &ServerDeviceDefinition, 44 44 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 45 45 let num_vibrators = def 46 46 .features() ··· 48 48 .filter(|x| { 49 49 x.output() 50 50 .as_ref() 51 - .map_or(false, |x| x.contains_key(&OutputType::Vibrate)) 51 + .map_or(false, |x| x.contains(OutputType::Vibrate)) 52 52 }) 53 53 .count() as u8; 54 54 Ok(Arc::new(WeVibeChorus::new(num_vibrators)))
+2 -2
crates/buttplug_server/src/device/protocol_impl/xuanhuan.rs
··· 21 21 }; 22 22 use buttplug_server_device_config::{ 23 23 Endpoint, 24 - DeviceDefinition, 24 + ServerDeviceDefinition, 25 25 ProtocolCommunicationSpecifier, 26 26 UserDeviceIdentifier, 27 27 }; ··· 45 45 async fn initialize( 46 46 &mut self, 47 47 hardware: Arc<Hardware>, 48 - _: &DeviceDefinition, 48 + _: &ServerDeviceDefinition, 49 49 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 50 50 Ok(Arc::new(Xuanhuan::new(hardware))) 51 51 }
+2 -2
crates/buttplug_server/src/device/protocol_impl/youou.rs
··· 8 8 use buttplug_core::errors::ButtplugDeviceError; 9 9 use buttplug_server_device_config::Endpoint; 10 10 use buttplug_server_device_config::{ 11 - DeviceDefinition, 11 + ServerDeviceDefinition, 12 12 ProtocolCommunicationSpecifier, 13 13 UserDeviceIdentifier, 14 14 }; ··· 65 65 async fn initialize( 66 66 &mut self, 67 67 _: Arc<Hardware>, 68 - _: &DeviceDefinition, 68 + _: &ServerDeviceDefinition, 69 69 ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 70 70 Ok(Arc::new(Youou::default())) 71 71 }
+7 -7
crates/buttplug_server/src/device/server_device.rs
··· 61 61 }; 62 62 use buttplug_server_device_config::{ 63 63 DeviceConfigurationManager, 64 - DeviceDefinition, 64 + ServerDeviceDefinition, 65 65 UserDeviceIdentifier, 66 66 }; 67 67 ··· 106 106 hardware: Arc<Hardware>, 107 107 handler: Arc<dyn ProtocolHandler>, 108 108 #[getset(get = "pub")] 109 - definition: DeviceDefinition, 109 + definition: ServerDeviceDefinition, 110 110 //output_command_manager: ActuatorCommandManager, 111 111 /// Unique identifier for the device 112 112 #[getset(get = "pub")] ··· 238 238 identifier: UserDeviceIdentifier, 239 239 handler: Arc<dyn ProtocolHandler>, 240 240 hardware: Arc<Hardware>, 241 - definition: &DeviceDefinition, 241 + definition: &ServerDeviceDefinition, 242 242 ) -> Self { 243 243 let (internal_hw_msg_sender, mut internal_hw_msg_recv) = channel::<Vec<HardwareCommand>>(1024); 244 244 245 - let device_wait_duration = if definition.message_gap().is_some() { 246 - definition.message_gap() 245 + let device_wait_duration = if let Some(gap) = definition.message_gap_ms() { 246 + Some(Duration::from_millis(gap as u64)) 247 247 } else { 248 248 hardware.message_gap() 249 249 }; ··· 413 413 // calculate stop commands. 414 414 for (index, feature) in definition.features().iter().enumerate() { 415 415 if let Some(output_map) = feature.output() { 416 - for actuator_type in output_map.keys() { 416 + for actuator_type in output_map.output_types() { 417 417 let mut stop_cmd = |actuator_cmd| { 418 418 stop_commands 419 419 .push(CheckedOutputCmdV4::new(1, 0, index as u32, feature.id(), actuator_cmd).into()); ··· 522 522 DeviceMessageInfoV4::new( 523 523 index, 524 524 &self.name(), 525 - self.definition().user_config().display_name(), 525 + self.definition().display_name(), 526 526 100, 527 527 &self 528 528 .definition
-1
crates/buttplug_server/src/device/server_device_manager.rs
··· 297 297 display_name: device 298 298 .value() 299 299 .definition() 300 - .user_config() 301 300 .display_name() 302 301 .clone(), 303 302 })
+1 -1
crates/buttplug_server/src/device/server_device_manager_event_loop.rs
··· 277 277 let _enter = span.enter(); 278 278 279 279 // Get the index from the device 280 - let device_index = device.definition().user_config().index(); 280 + let device_index = device.definition().index(); 281 281 // Since we can now reuse device indexes, this means we might possibly 282 282 // stomp on devices already in the map if they don't register a 283 283 // disconnect before we try to insert the new device. If we have a
+1 -6
crates/buttplug_server/src/message/v2/battery_level_cmd.rs
··· 77 77 .iter() 78 78 .enumerate() 79 79 .find(|(_, p)| { 80 - if let Some(sensor_map) = p.input() { 81 - if sensor_map.contains_key(&InputType::Battery) { 82 - return true; 83 - } 84 - } 85 - false 80 + p.input().as_ref().map_or(false, |x| x.battery().is_some()) 86 81 }) 87 82 .expect("Already found matching battery feature, can unwrap this.") 88 83 .0;
+2 -2
crates/buttplug_server/src/message/v2/server_device_message_attributes.rs
··· 17 17 use getset::{CopyGetters, Getters, Setters}; 18 18 use serde::{Deserialize, Serialize}; 19 19 20 - #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Getters, Setters)] 20 + #[derive(Clone, Debug, PartialEq, Eq, Serialize, Getters, Setters)] 21 21 pub struct ServerDeviceMessageAttributesV2 { 22 22 // Generic commands 23 23 #[getset(get = "pub")] ··· 72 72 pub(in crate::message) features: Vec<ServerDeviceFeature>, 73 73 } 74 74 75 - #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize, Getters, Setters)] 75 + #[derive(Clone, Debug, PartialEq, Eq, Serialize, Getters, Setters)] 76 76 pub struct ServerSensorDeviceMessageAttributesV2 { 77 77 #[getset(get = "pub")] 78 78 #[serde(skip)]
+1 -6
crates/buttplug_server/src/message/v3/sensor_read_cmd.rs
··· 79 79 )) 80 80 } else if let Some((feature_index, feature)) = 81 81 features.features().iter().enumerate().find(|(_, p)| { 82 - if let Some(sensor_map) = p.input() { 83 - if sensor_map.contains_key(&InputType::Battery) { 84 - return true; 85 - } 86 - } 87 - false 82 + p.input().as_ref().map_or(false, |x| x.battery().is_some()) 88 83 }) 89 84 { 90 85 Ok(CheckedInputCmdV4::new(
+1 -7
crates/buttplug_server/src/message/v4/checked_input_cmd.rs
··· 67 67 ) -> Result<Self, buttplug_core::errors::ButtplugError> { 68 68 if let Some(feature) = features.features().get(msg.feature_index() as usize) { 69 69 if let Some(sensor_map) = feature.input() { 70 - if let Some(sensor) = sensor_map.get(&msg.input_type()) { 71 - if sensor.input_commands().contains(&msg.input_command()) { 70 + if sensor_map.contains(msg.input_type()) { 72 71 Ok(CheckedInputCmdV4::new( 73 72 msg.device_index(), 74 73 msg.feature_index(), ··· 76 75 msg.input_command(), 77 76 feature.id(), 78 77 )) 79 - } else { 80 - Err(ButtplugError::from( 81 - ButtplugDeviceError::DeviceNoSensorError("InputCmd".to_string()), 82 - )) 83 - } 84 78 } else { 85 79 Err(ButtplugError::from( 86 80 ButtplugDeviceError::DeviceNoSensorError("InputCmd".to_string()),
+5 -3
crates/buttplug_server_device_config/src/device_config_manager.rs
··· 12 12 13 13 #[derive(Default, Clone)] 14 14 pub struct DeviceConfigurationManagerBuilder { 15 - communication_specifiers: HashMap<String, Vec<ProtocolCommunicationSpecifier>>, 15 + base_communication_specifiers: HashMap<String, Vec<ProtocolCommunicationSpecifier>>, 16 16 user_communication_specifiers: DashMap<String, Vec<ProtocolCommunicationSpecifier>>, 17 17 base_device_definitions: HashMap<BaseDeviceIdentifier, ServerDeviceDefinition>, 18 18 user_device_definitions: DashMap<UserDeviceIdentifier, ServerDeviceDefinition>, ··· 25 25 specifier: &[ProtocolCommunicationSpecifier], 26 26 ) -> &mut Self { 27 27 self 28 - .communication_specifiers 28 + .base_communication_specifiers 29 29 .entry(protocol_name.to_owned()) 30 30 .or_default() 31 31 .extend(specifier.iter().cloned()); ··· 99 99 } 100 100 101 101 Ok(DeviceConfigurationManager { 102 - base_communication_specifiers: self.communication_specifiers.clone(), 102 + base_communication_specifiers: self.base_communication_specifiers.clone(), 103 103 user_communication_specifiers: self.user_communication_specifiers.clone(), 104 104 base_device_definitions: attribute_tree_map, 105 105 user_device_definitions: user_attribute_tree_map, ··· 124 124 pub struct DeviceConfigurationManager { 125 125 /// Communication specifiers from the base device config, mapped from protocol name to vector of 126 126 /// specifiers. Should not change/update during a session. 127 + #[getset(get = "pub")] 127 128 base_communication_specifiers: HashMap<String, Vec<ProtocolCommunicationSpecifier>>, 128 129 /// Device definitions from the base device config. Should not change/update during a session. 129 130 base_device_definitions: HashMap<BaseDeviceIdentifier, ServerDeviceDefinition>, 130 131 /// Communication specifiers provided by the user, mapped from protocol name to vector of 131 132 /// specifiers. Loaded at session start, may change over life of session. 133 + #[getset(get = "pub")] 132 134 user_communication_specifiers: DashMap<String, Vec<ProtocolCommunicationSpecifier>>, 133 135 /// Device definitions from the user device config. Loaded at session start, may change over life 134 136 /// of session.
+48 -5
crates/buttplug_server_device_config/src/device_feature.rs
··· 7 7 8 8 use crate::ButtplugDeviceConfigError; 9 9 10 - use buttplug_core::{ 11 - message::{ 10 + use buttplug_core::message::{ 12 11 DeviceFeature, 13 12 DeviceFeatureInput, 14 - InputCommandType, 15 - }, 16 - }; 13 + InputCommandType, InputType, OutputType, 14 + }; 17 15 use getset::{CopyGetters, Getters, Setters}; 18 16 use serde::{ 19 17 Deserialize, ··· 187 185 spray: Option<ServerDeviceFeatureOutputValueProperties>, 188 186 } 189 187 188 + impl ServerDeviceFeatureOutput { 189 + pub fn contains(&self, output_type: OutputType) -> bool { 190 + match output_type { 191 + OutputType::Constrict => self.constrict.is_some(), 192 + OutputType::Heater => self.heater.is_some(), 193 + OutputType::Led => self.led.is_some(), 194 + OutputType::Oscillate => self.oscillate.is_some(), 195 + OutputType::Position => self.position.is_some(), 196 + OutputType::PositionWithDuration => self.position_with_duration.is_some(), 197 + OutputType::Rotate => self.rotate.is_some(), 198 + OutputType::RotateWithDirection => self.rotate_with_direction.is_some(), 199 + OutputType::Spray => self.spray.is_some(), 200 + OutputType::Unknown => false, 201 + OutputType::Vibrate => self.vibrate.is_some() 202 + } 203 + } 204 + 205 + pub fn output_types(&self) -> Vec<OutputType> { 206 + let mut types = vec!(); 207 + self.constrict.is_some().then(|| types.push(OutputType::Constrict)); 208 + self.heater.is_some().then(|| types.push(OutputType::Heater)); 209 + self.led.is_some().then(|| types.push(OutputType::Led)); 210 + self.oscillate.is_some().then(|| types.push(OutputType::Oscillate)); 211 + self.position.is_some().then(|| types.push(OutputType::Position)); 212 + self.position_with_duration.is_some().then(|| types.push(OutputType::PositionWithDuration)); 213 + self.rotate.is_some().then(|| types.push(OutputType::Rotate)); 214 + self.rotate_with_direction.is_some().then(|| types.push(OutputType::RotateWithDirection)); 215 + self.spray.is_some().then(|| types.push(OutputType::Spray)); 216 + self.vibrate.is_some().then(|| types.push(OutputType::Vibrate)); 217 + types 218 + } 219 + } 220 + 190 221 #[derive(Clone, Debug, Getters)] 191 222 #[getset(get = "pub")] 192 223 pub struct ServerDeviceFeatureInputProperties { ··· 213 244 rssi: Option<ServerDeviceFeatureInputProperties>, 214 245 pressure: Option<ServerDeviceFeatureInputProperties>, 215 246 button: Option<ServerDeviceFeatureInputProperties>, 247 + } 248 + 249 + impl ServerDeviceFeatureInput { 250 + pub fn contains(&self, input_type: InputType) -> bool { 251 + match input_type { 252 + InputType::Battery => self.battery.is_some(), 253 + InputType::Rssi => self.rssi.is_some(), 254 + InputType::Pressure => self.pressure.is_some(), 255 + InputType::Button => self.button.is_some(), 256 + InputType::Unknown => false, 257 + } 258 + } 216 259 } 217 260 218 261 #[derive(Clone, Debug, Getters, CopyGetters)]
+1 -1
crates/buttplug_tests/tests/test_client_device.rs
··· 178 178 dcm 179 179 .add_user_device_definition( 180 180 &identifier, 181 - &DeviceDefinition::new( 181 + &ServerDeviceDefinition::new( 182 182 "Massage Demo", 183 183 &Uuid::new_v4(), 184 184 &None,