Skip to content

Commit 600f69a

Browse files
blackspherefollowerqdot
authored andcommitted
feat: Adding support for 5 more LiBo devices
- Gugudai # Carlos - Suction Chicken - ShaYu # Shark - Enflating Rabbit - Yuyi # Lina - Leaf - LuWuShuang # Adel - Curved Rabbit - Libo # Lily - Double ended mini wand
1 parent 38b3ae8 commit 600f69a

3 files changed

Lines changed: 77 additions & 5 deletions

File tree

Buttplug.Test/Devices/Protocols/LiBoLuLuTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public async Task TestStopDeviceCmd()
5959
expected =
6060
new List<(byte[], string)>()
6161
{
62+
(new byte[] { 0 }, Endpoints.Tx),
6263
(new byte[] { 0 }, Endpoints.TxMode),
6364
};
6465

Buttplug/Devices/Protocols/LiBoProtocol.cs

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
using System;
88
using System.Collections.Generic;
9+
using System.Linq;
910
using System.Threading;
1011
using System.Threading.Tasks;
1112
using Buttplug.Core.Logging;
@@ -20,6 +21,7 @@ internal class LiBoType
2021
public string Name;
2122
public uint VibeCount;
2223
public uint[] VibeOrder = new uint[] { 0, 1 };
24+
public bool MultiCharacteristic = true;
2325
}
2426

2527
internal static readonly Dictionary<string, LiBoType> DevInfos =
@@ -74,6 +76,47 @@ internal class LiBoType
7476
VibeCount = 1,
7577
}
7678
},
79+
{
80+
"Gugudai",
81+
new LiBoType()
82+
{
83+
Name = "Carlos",
84+
VibeCount = 2, // Suction as vibe
85+
}
86+
},
87+
{
88+
"ShaYu",
89+
new LiBoType()
90+
{
91+
Name = "Shark",
92+
VibeCount = 2,
93+
MultiCharacteristic = false,
94+
}
95+
},
96+
{
97+
"Yuyi",
98+
new LiBoType()
99+
{
100+
Name = "Lina",
101+
VibeCount = 1,
102+
}
103+
},
104+
{
105+
"LuWuShuang",
106+
new LiBoType()
107+
{
108+
Name = "Adel",
109+
VibeCount = 1,
110+
}
111+
},
112+
{
113+
"LiBo",
114+
new LiBoType()
115+
{
116+
Name = "Lily",
117+
VibeCount = 2,
118+
}
119+
},
77120
};
78121

79122
private readonly LiBoType _devInfo;
@@ -145,20 +188,43 @@ private async Task<ButtplugMessage> HandleVibrateCmd(ButtplugDeviceMessage aMsg,
145188
_vibratorSpeed[v.Index] = v.Speed;
146189
}
147190

148-
if (changed[_devInfo.VibeOrder[0]] || !SentVibration)
191+
// Shark specific handling
192+
if (_devInfo.VibeCount == 2 && !_devInfo.MultiCharacteristic)
149193
{
150-
var ep = Endpoints.Tx;
151-
if (_devInfo.VibeCount == 1 && (uint)Math.Ceiling(_vibratorSpeed[_devInfo.VibeOrder[0]] * 0x64) == 0)
194+
if (!changed.Select(x => x).Any() && SentVibration)
152195
{
153-
ep = Endpoints.TxMode;
196+
return new Ok(aMsg.Id);
154197
}
155198

199+
SentVibration = true;
200+
byte data = 0x00;
201+
data |= (byte)((byte)Math.Ceiling(_vibratorSpeed[_devInfo.VibeOrder[0]] * 0x03) << 4);
202+
data |= (byte)Math.Ceiling(_vibratorSpeed[_devInfo.VibeOrder[1]] * 0x03);
203+
await Interface.WriteValueAsync(
204+
new[] { data },
205+
new ButtplugDeviceWriteOptions { Endpoint = Endpoints.Tx },
206+
aToken).ConfigureAwait(false);
207+
208+
return new Ok(aMsg.Id);
209+
}
210+
211+
if (changed[_devInfo.VibeOrder[0]] || !SentVibration)
212+
{
156213
// Map a 0 - 100% value to a 0 - 0x64 value since 0 * x == 0 this will turn off the vibe if
157214
// speed is 0.00
158215
await Interface.WriteValueAsync(
159216
new[] { Convert.ToByte((uint)Math.Ceiling(_vibratorSpeed[_devInfo.VibeOrder[0]] * 0x64)) },
160-
new ButtplugDeviceWriteOptions { Endpoint = ep },
217+
new ButtplugDeviceWriteOptions { Endpoint = Endpoints.Tx },
161218
aToken).ConfigureAwait(false);
219+
220+
// Some devices don't really stop unless both characteristics are set to 0
221+
if (_devInfo.VibeCount == 1 && (uint)Math.Ceiling(_vibratorSpeed[_devInfo.VibeOrder[0]] * 0x64) == 0)
222+
{
223+
await Interface.WriteValueAsync(
224+
new[] { Convert.ToByte((uint)Math.Ceiling(_vibratorSpeed[_devInfo.VibeOrder[0]] * 0x64)) },
225+
new ButtplugDeviceWriteOptions { Endpoint = Endpoints.TxMode },
226+
aToken).ConfigureAwait(false);
227+
}
162228
}
163229

164230
if (_devInfo.VibeCount < 2 ||

dependencies/buttplug-device-config/buttplug-device-config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ protocols:
191191
- SuoYinQiu # Karen - Kegel
192192
- BaiHu # LaLa - Suction Rabbit
193193
- MonsterPub # Sistalk MonsterPub (all 6?)
194+
- Gugudai # Carlos - Suction Chicken
195+
- ShaYu # Shark - Enflating Rabbit
196+
- Yuyi # Lina - Leaf
197+
- LuWuShuang # Adel - Curved Rabbit
198+
- LiBo # Lily - Double ended mini wand
194199
services:
195200
# Write Service
196201
00006000-0000-1000-8000-00805f9b34fb:

0 commit comments

Comments
 (0)