buttplugio / buttplug

Rust Implementation of the Buttplug Sex Toy Control Protocol
https://buttplug.io
Other
846 stars 63 forks source link

fix: Correct VibrateCmd -> ScalarCmd conversion when the devices has non-vibrate features #636

Closed blackspherefollower closed 2 months ago

blackspherefollower commented 2 months ago

This change reworks the conversion from VibrateCmd to ScalarCmd by building a map of indexes of vibrate features on a devices that supports ScalarCmd so that devices that have non-vibrators before or embedded between vibrators don't try to send vibrate commands to the those features.

VibrateCmd( 0, [1.0, 0.5] ) for a device with ScalarCmd(Vibrate, Rotate, Vibrate) now generates ScalarCmd( 0, [ {0, 1.0, Vibrate}, {2, 0.5, Vibrate}] ) vs previously just copying the feature index, which would have produced the invalid: ScalarCmd( 0, [ {0, 1.0, Vibrate}, {1, 0.5, Vibrate}] )