Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"update:bc": "(cd ../Bondage-College/ && git pull origin master)"
},
"dependencies": {
"buttplug": "^3.2.2",
"buttplug": "^4.0.0",
"idb": "^8.0.3",
"rolldown": "^1.0.0-rc.2"
},
Expand Down
4 changes: 3 additions & 1 deletion src/functions/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export async function fbcDebug(copy: boolean): Promise<string> {
if (toySyncState.client?.connected) {
info.set(
"Buttplug.io Devices",
toySyncState.client.devices.map(d => `${d.name} (${d.vibrateAttributes.map(a => a.FeatureDescriptor).join(",")})`).join(", ")
Array.from(toySyncState.client.devices.values())
.map(d => `${d.displayName} (${d.eventNames().join(",")})`)
.join(", ")
);
}
info.set(
Expand Down
4 changes: 1 addition & 3 deletions src/functions/confirmLeave.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export default function confirmLeave() {
e => {
if (toySyncState.client?.connected) {
// Stop vibrating toys
for (const device of toySyncState.client.devices.filter(d => d.vibrateAttributes.length > 0)) {
device.vibrate(0);
}
toySyncState.client.stopAllDevices();
}
if (fbcSettings.confirmLeave) {
e.preventDefault();
Expand Down
8 changes: 6 additions & 2 deletions src/functions/settingsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { fbcSettings, defaultSettings, bceSaveSettings, isDefaultSettingKey, typ
import { waitFor, drawTooltip } from "../util/utils";
import { toySyncState } from "./toySync";

export declare enum OutputType {
Vibrate = "Vibrate",
}

const SelectButtonOffset = 900;
const SelectButtonWidth = 200;

Expand Down Expand Up @@ -158,7 +162,7 @@ export default async function settingsPage(): Promise<void> {
DrawText(displayText("Device Name"), 300, 420, "Black", "Gray");
DrawText(displayText("Synchronized Slot"), 800, 420, "Black", "Gray");
y = 500;
for (const d of toySyncState.client.devices.filter(dev => dev.vibrateAttributes.length > 0)) {
for (const d of Array.from(toySyncState.client.devices.values()).filter(dev => dev.hasOutput(OutputType.Vibrate))) {
let deviceSettings = toySyncState.deviceSettings.get(d.name);
if (!deviceSettings) {
deviceSettings = { Name: d.name, SlotName: "None" };
Expand Down Expand Up @@ -280,7 +284,7 @@ export default async function settingsPage(): Promise<void> {
return;
}
y = 500;
for (const d of toySyncState.client.devices.filter(dev => dev.vibrateAttributes.length > 0)) {
for (const d of Array.from(toySyncState.client.devices.values()).filter(dev => dev.hasOutput(OutputType.Vibrate))) {
if (!MouseIn(800, y - 32, 450, 64)) {
y += settingsYIncrement;
continue;
Expand Down
16 changes: 8 additions & 8 deletions src/functions/toySync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function toySync(): Promise<void> {
return;
}

const { ButtplugClient, ButtplugBrowserWebsocketClientConnector } = await import("buttplug");
const { ButtplugClient, ButtplugBrowserWebsocketClientConnector, DeviceOutput, InputType, OutputType } = await import("buttplug");

logInfo("Loaded Buttplug.io");

Expand Down Expand Up @@ -67,7 +67,7 @@ export default async function toySync(): Promise<void> {
removeTimer();
return;
}
for (const d of client.devices.filter(dev => dev.vibrateAttributes.length > 0)) {
for (const d of Array.from(client.devices.values()).filter(dev => dev.hasOutput(OutputType.Vibrate))) {
const deviceSettings = toySyncState.deviceSettings?.get(d.name);
if (!deviceSettings) continue;

Expand All @@ -78,23 +78,23 @@ export default async function toySync(): Promise<void> {
deviceSettings.LastIntensity = intensity;

if (typeof intensity !== "number" || intensity < 0) {
d.vibrate(0);
d.runOutput(DeviceOutput.Vibrate.percent(0));
} else {
switch (intensity) {
case 0:
d.vibrate(0.1);
d.runOutput(DeviceOutput.Vibrate.percent(0.1));
debug(d.name, slot, "intensity 0.1");
break;
case 1:
d.vibrate(0.4);
d.runOutput(DeviceOutput.Vibrate.percent(0.4));
debug(d.name, slot, "intensity 0.4");
break;
case 2:
d.vibrate(0.75);
d.runOutput(DeviceOutput.Vibrate.percent(0.75));
debug(d.name, slot, "intensity 0.75");
break;
case 3:
d.vibrate(1);
d.runOutput(DeviceOutput.Vibrate.percent(1));
debug(d.name, slot, "intensity 1");
break;
default:
Expand All @@ -114,7 +114,7 @@ export default async function toySync(): Promise<void> {
fbcChatNotify("buttplug.io is not connected");
return;
}
const batteryDevices: ButtplugClientDevice[] = client.devices.filter(dev => dev.hasBattery);
const batteryDevices: ButtplugClientDevice[] = Array.from(client.devices.values()).filter(dev => dev.hasInput(InputType.Battery));
if (batteryDevices.length === 0) {
fbcChatNotify("No battery devices connected");
return;
Expand Down