Skip to content

Commit 6771675

Browse files
blackspherefollowerqdot
authored andcommitted
fix: Youou never sends vibe speeds of 0
The _vibrationSpeed variable isn't updated, so on stop the device already thinks it's stopped.
1 parent d37454d commit 6771675

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// <copyright file="YououTests.cs" company="Nonpolynomial Labs LLC">
2+
// Buttplug C# Source Code File - Visit https://buttplug.io for more info about the project.
3+
// Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
4+
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root for full license information.
5+
// </copyright>
6+
7+
// Test file, disable ConfigureAwait checking.
8+
// ReSharper disable ConsiderUsingConfigureAwait
9+
10+
usingSystem.Collections.Generic;
11+
usingSystem.Diagnostics.CodeAnalysis;
12+
usingSystem.Text;
13+
usingSystem.Threading.Tasks;
14+
usingButtplug.Core.Messages;
15+
usingButtplug.Devices;
16+
usingButtplug.Devices.Configuration;
17+
usingButtplug.Devices.Protocols;
18+
usingButtplug.Test.Devices.Protocols.Utils;
19+
usingJetBrains.Annotations;
20+
usingNUnit.Framework;
21+
22+
namespaceButtplug.Test.Devices.Protocols
23+
{
24+
[SuppressMessage("StyleCop.CSharp.DocumentationRules","SA1600:ElementsMustBeDocumented",Justification="Test classes can skip documentation requirements")]
25+
[TestFixture]
26+
publicclassYououTests
27+
{
28+
[NotNull]
29+
privateProtocolTestUtilstestUtil;
30+
31+
[SetUp]
32+
publicasyncTaskInit()
33+
{
34+
testUtil=newProtocolTestUtils();
35+
awaittestUtil.SetupTest<YououProtocol>("Youou",newList<DeviceConfiguration>());
36+
}
37+
38+
[Test]
39+
publicvoidTestAllowedMessages()
40+
{
41+
testUtil.TestDeviceAllowedMessages(newDictionary<System.Type,uint>()
42+
{
43+
{typeof(StopDeviceCmd),0},
44+
{typeof(SingleMotorVibrateCmd),0},
45+
{typeof(VibrateCmd),1},
46+
});
47+
}
48+
49+
// StopDeviceCmd noop test handled in GeneralDeviceTests
50+
51+
[Test]
52+
publicasyncTaskTestStopDeviceCmd()
53+
{
54+
varexpected=
55+
newList<(byte[],string)>()
56+
{
57+
(newbyte[]{0xAA,0x55,0x00,0x02,0x03,0x01,0x7B,0x01,0x85,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00},Endpoints.Tx),
58+
};
59+
60+
awaittestUtil.TestDeviceMessage(newSingleMotorVibrateCmd(4,0.5),expected,false);
61+
62+
expected=
63+
newList<(byte[],string)>()
64+
{
65+
(newbyte[]{0xAA,0x55,0x01,0x02,0x03,0x01,0x0,0x00,0xFE,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00},Endpoints.Tx),
66+
};
67+
68+
awaittestUtil.TestDeviceMessage(newStopDeviceCmd(4),expected,false);
69+
}
70+
71+
[Test]
72+
publicasyncTaskTestSingleMotorVibrateCmd()
73+
{
74+
varexpected=
75+
newList<(byte[],string)>()
76+
{
77+
(newbyte[]{0xAA,0x55,0x00,0x02,0x03,0x01,0x7B,0x01,0x85,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00},Endpoints.Tx),
78+
};
79+
80+
awaittestUtil.TestDeviceMessage(newSingleMotorVibrateCmd(4,0.5),expected,false);
81+
}
82+
83+
[Test]
84+
publicasyncTaskTestVibrateCmd()
85+
{
86+
varexpected=
87+
newList<(byte[],string)>()
88+
{
89+
(newbyte[]{0xAA,0x55,0x00,0x02,0x03,0x01,0x7B,0x01,0x85,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00},Endpoints.Tx),
90+
};
91+
92+
awaittestUtil.TestDeviceMessage(VibrateCmd.Create(4,1,0.5,1),expected,false);
93+
}
94+
95+
[Test]
96+
publicvoidTestInvalidVibrateCmd()
97+
{
98+
testUtil.TestInvalidVibrateCmd(1);
99+
}
100+
}
101+
}

Buttplug/Devices/Protocols/YououProtocol.cs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private async Task<ButtplugMessage> HandleVibrateCmd(ButtplugDeviceMessage aMsg,
5353
returnnewOk(cmdMsg.Id);
5454
}
5555

56+
_vibratorSpeed=v.Speed;
5657
SentVibration=true;
5758

5859
// Byte 2 seems to be a monotonically increasing packet id of some kind Speed seems to be

0 commit comments

Comments
 (0)
close