Skip to content

Commit

Permalink
fix: Correct identification of early Satisfyer devices
Browse files Browse the repository at this point in the history
This change passes the ProtocolCommunicationSpecifier down into
ProtocolIdentifier::identify(), which affects all protocols, but
means that the identify() method can access the same data that
was used to decide that this was a suitable protocol implementation
in the first place.

Fixes #547
  • Loading branch information
blackspherefollower committed May 24, 2024
1 parent a08e255 commit 275d8d6
Show file tree
Hide file tree
Showing 48 changed files with 151 additions and 26 deletions.
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/ankni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/foreo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/fredorch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/fredorch_rotary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/hgod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
2 changes: 2 additions & 0 deletions buttplug/src/server/device/protocol/hismith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down Expand Up @@ -40,6 +41,7 @@ impl ProtocolIdentifier for HismithIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
let result = hardware
.read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500))
Expand Down
2 changes: 2 additions & 0 deletions buttplug/src/server/device/protocol/hismith_mini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down Expand Up @@ -43,6 +44,7 @@ impl ProtocolIdentifier for HismithMiniIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
let result = hardware
.read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500))
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/joyhub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/joyhub_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/kiiroo_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/lelo_harmony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/lelof1s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/lelof1sv2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/leten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/lioness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/longlosttouch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::util::async_manager;
use crate::{
core::{errors::ButtplugDeviceError, message, message::Endpoint},
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/lovedistance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
6 changes: 5 additions & 1 deletion buttplug/src/server/device/protocol/lovense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down Expand Up @@ -84,6 +87,7 @@ impl ProtocolIdentifier for LovenseIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
let mut event_receiver = hardware.event_stream();
let mut count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/metaxsire_repeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use crate::core::message::ActuatorType;
use crate::core::message::ActuatorType::{Constrict, Rotate, Vibrate};
use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/metaxsire_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
// for full license information.

use crate::core::message::ActuatorType;
use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::server::device::hardware::Hardware;
use crate::server::device::protocol::ProtocolInitializer;
use crate::{
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/metaxsire_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/mizzzee_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
3 changes: 3 additions & 0 deletions buttplug/src/server/device/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ pub trait ProtocolIdentifier: Sync + Send {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
specifier: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError>;
}

Expand Down Expand Up @@ -611,6 +612,7 @@ impl ProtocolIdentifier for GenericProtocolIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
let device_identifier = UserDeviceIdentifier::new(
hardware.address(),
Expand Down Expand Up @@ -935,6 +937,7 @@ macro_rules! generic_protocol_initializer_setup {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
Ok((UserDeviceIdentifier::new(hardware.address(), $protocol_identifier, &Some(hardware.name().to_owned())), Box::new([< $protocol_name Initializer >]::default())))
}
Expand Down
2 changes: 2 additions & 0 deletions buttplug/src/server/device/protocol/monsterpub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolCommunicationSpecifier;
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down Expand Up @@ -44,6 +45,7 @@ impl ProtocolIdentifier for MonsterPubIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
let read_resp = hardware
.read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 32, 500))
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/mysteryvibe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/mysteryvibe_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down
1 change: 1 addition & 0 deletions buttplug/src/server/device/protocol/nintendo_joycon.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::server::device::configuration::ProtocolCommunicationSpecifier;
#[cfg(feature = "wasm")]
use crate::util;
use crate::{
Expand Down
5 changes: 4 additions & 1 deletion buttplug/src/server/device/protocol/nobra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down
6 changes: 5 additions & 1 deletion buttplug/src/server/device/protocol/patoo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{
errors::ButtplugDeviceError,
Expand Down Expand Up @@ -44,6 +47,7 @@ impl ProtocolIdentifier for PatooIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
// Patoo Love devices have wildcarded names of ([A-Z]+)\d*
// Force the identifier lookup to the non-numeric portion
Expand Down
6 changes: 5 additions & 1 deletion buttplug/src/server/device/protocol/prettylove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::server::device::configuration::{
ProtocolCommunicationSpecifier,
ProtocolDeviceAttributes,
};
use crate::{
core::{errors::ButtplugDeviceError, message::Endpoint},
server::device::{
Expand Down Expand Up @@ -41,6 +44,7 @@ impl ProtocolIdentifier for PrettyLoveIdentifier {
async fn identify(
&mut self,
hardware: Arc<Hardware>,
_: ProtocolCommunicationSpecifier,
) -> Result<(UserDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> {
Ok((
UserDeviceIdentifier::new(
Expand Down
Loading

0 comments on commit 275d8d6

Please sign in to comment.