@@ -259,202 +259,6 @@ impl ProtocolInitializer for LovenseInitializer {
259259 }
260260 }
261261}
262- /*
263- pub struct Lovense {
264- rotation_direction: AtomicBool,
265- vibrator_values: Vec<AtomicU32>,
266- use_mply: bool,
267- use_lvs: bool,
268- device_type: String,
269- value_cache: DashMap<Uuid, u32>,
270- linear_info: Arc<(AtomicU32, AtomicU32)>,
271- }
272-
273- impl Lovense {
274- pub fn new(
275- device_type: &str,
276- vibrator_count: usize,
277- use_mply: bool,
278- use_lvs: bool,
279- ) -> Self {
280- let linear_info = Arc::new((AtomicU32::new(0), AtomicU32::new(0)));
281-
282- let mut vibrator_values = vec![];
283- for _ in 0..vibrator_count {
284- vibrator_values.push(AtomicU32::new(0));
285- }
286-
287- Self {
288- rotation_direction: AtomicBool::new(false),
289- vibrator_values,
290- use_mply,
291- use_lvs,
292- device_type: device_type.to_owned(),
293- value_cache: DashMap::new(),
294- linear_info,
295- }
296- }
297-
298- fn handle_lvs_cmd(&self) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
299- let mut speeds = "LVS:{}".as_bytes().to_vec();
300- for i in self.vibrator_values.iter() {
301- speeds.push(i.load(Ordering::Relaxed) as u8);
302- }
303- speeds.push(0x3b);
304-
305- Ok(vec![HardwareWriteCmd::new(
306- LOVENSE_PROTOCOL_UUID,
307- Endpoint::Tx,
308- speeds,
309- false,
310- )
311- .into()])
312- }
313-
314- fn handle_mply_cmd(&self) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
315- /*
316- let mut speeds = cmds
317- .iter()
318- .map(|x| {
319- if let Some(val) = x {
320- val.1.to_string()
321- } else {
322- "-1".to_string()
323- }
324- })
325- .collect::<Vec<_>>();
326-
327- if speeds.len() == 1 && self.device_type == "H" {
328- // Max range unless stopped
329- speeds.push(if speeds[0] == "0" {
330- "0".to_string()
331- } else {
332- "20".to_string()
333- });
334- }
335-
336- let lovense_cmd = format!("Mply:{};", speeds.join(":")).as_bytes().to_vec();
337-
338- Ok(vec![HardwareWriteCmd::new(
339- Endpoint::Tx,
340- lovense_cmd,
341- false,
342- )
343- .into()])
344- */
345- Ok(vec![])
346- }
347- }
348-
349- impl ProtocolHandler for Lovense {
350- fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
351- // For Lovense, we'll just repeat the device type packet and drop the result.
352- super::ProtocolKeepaliveStrategy::HardwareRequiredRepeatPacketStrategy(HardwareWriteCmd::new(
353- LOVENSE_PROTOCOL_UUID,
354- Endpoint::Tx,
355- b"DeviceType;".to_vec(),
356- false,
357- ))
358- }
359-
360- fn handle_output_vibrate_cmd(
361- &self,
362- feature_index: u32,
363- feature_id: Uuid,
364- speed: u32,
365- ) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
366- let current_vibrator_value =
367- self.vibrator_values[feature_index as usize].load(Ordering::Relaxed);
368- if current_vibrator_value == speed {
369- Ok(vec![])
370- } else {
371- self.vibrator_values[feature_index as usize].store(speed, Ordering::Relaxed);
372- let speeds: Vec<u32> = self
373- .vibrator_values
374- .iter()
375- .map(|v| v.load(Ordering::Relaxed))
376- .collect();
377- if self.use_lvs {
378- self.handle_lvs_cmd()
379- } else if self.use_mply {
380- self.handle_mply_cmd()
381- } else {
382- let lovense_cmd = if self.vibrator_values.len() == 1 {
383- format!("Vibrate:{speed};").as_bytes().to_vec()
384- } else {
385- format!("Vibrate{}:{};", feature_index + 1, speed)
386- .as_bytes()
387- .to_vec()
388- };
389- Ok(vec![HardwareWriteCmd::new(
390- &[feature_id],
391- Endpoint::Tx,
392- lovense_cmd,
393- false,
394- )
395- .into()])
396- }
397- }
398- /*
399- if self.use_lvs {
400- self.handle_lvs_cmd(cmd)
401- } else if self.use_mply {
402- self.handle_mply_cmd(cmd)
403- } else {
404- // Handle vibration commands, these will be by far the most common. Fucking machine oscillation
405- // uses lovense vibrate commands internally too, so we can include them here.
406- let vibrate_cmds: Vec<> = cmds
407- .iter()
408- .filter(|x| {
409- if let Some(val) = x {
410- [ActuatorType::Vibrate, ActuatorType::Oscillate].contains(&val.0)
411- } else {
412- false
413- }
414- })
415- .map(|x| x.as_ref().expect("Already verified is some"))
416- .collect();
417- if !vibrate_cmds.is_empty() {
418- // Lovense is the same situation as the Lovehoney Desire, where commands
419- // are different if we're addressing all motors or seperate motors.
420- // Difference here being that there's Lovense variants with different
421- // numbers of motors.
422- //
423- // Neat way of checking if everything is the same via
424- // https://sts10.github.io/2019/06/06/is-all-equal-function.html.
425- //
426- // Just make sure we're not matching on None, 'cause if that's the case
427- // we ain't got shit to do.
428- //
429- // Note that the windowed comparison causes mixed types as well as mixed
430- // speeds to fall back to separate commands. This is because the Gravity's
431- // thruster on Vibrate2 is independent of Vibrate
432- if self.vibrator_count == vibrate_cmds.len()
433- && (self.vibrator_count == 1
434- || vibrate_cmds
435- .windows(2)
436- .all(|w| w[0].0 == w[1].0 && w[0].1 == w[1].1))
437- {
438- let lovense_cmd = format!("Vibrate:{};", vibrate_cmds[0].1)
439- .as_bytes()
440- .to_vec();
441- hardware_cmds.push(HardwareWriteCmd::new(Endpoint::Tx, lovense_cmd, false).into());
442- } else {
443- for (i, cmd) in cmds.iter().enumerate() {
444- if let Some((actuator, speed)) = cmd {
445- if ![ActuatorType::Vibrate, ActuatorType::Oscillate].contains(actuator) {
446- continue;
447- }
448- let lovense_cmd = format!("Vibrate{}:{};", i + 1, speed).as_bytes().to_vec();
449- hardware_cmds.push(HardwareWriteCmd::new(Endpoint::Tx, lovense_cmd, false).into());
450- }
451- }
452- }
453- }
454- */
455- }
456- }
457- */
458262
459263fn handle_battery_level_cmd (
460264 device_index : u32 ,
0 commit comments