diff --git a/package-lock.json b/package-lock.json index 7ce4e73..03c0d2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "name": "wce", "license": "GPL-3.0-or-later", "dependencies": { - "buttplug": "^3.2.2", + "buttplug": "^4.0.0", "idb": "^8.0.3", "rolldown": "^1.0.0-rc.2" }, @@ -660,23 +660,15 @@ "license": "MIT" }, "node_modules/buttplug": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/buttplug/-/buttplug-3.2.2.tgz", - "integrity": "sha512-TGkQzG6dxEjuFX29eRoWkh82vsQhGQ+E98tZtN8fWn1NOG7v/9H0FFkNXrpmeRt9FFS0GdHTvubfZ8dcIPGSAA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/buttplug/-/buttplug-4.0.0.tgz", + "integrity": "sha512-9fO055gmZbHp7lI5C95pNbvjHye/n5cKNxv//ObW7Vh8R6UULE5tz8/dpYXJDcjy64DbX1+M5KnUgr40ygafsQ==", "license": "BSD-3-Clause", "dependencies": { - "class-transformer": "^0.5.1", "eventemitter3": "^5.0.1", - "reflect-metadata": "^0.2.1", - "ws": "^8.16.0" + "ws": "^8.18.3" } }, - "node_modules/class-transformer": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", - "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", - "license": "MIT" - }, "node_modules/debug": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", @@ -859,12 +851,6 @@ "@oxlint-tsgolint/win32-x64": "0.11.4" } }, - "node_modules/reflect-metadata": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", - "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", - "license": "Apache-2.0" - }, "node_modules/rolldown": { "version": "1.0.0-rc.2", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.2.tgz", diff --git a/package.json b/package.json index 7ceb4a0..20d5c00 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/functions/commands.ts b/src/functions/commands.ts index 88eef2f..fa6db43 100644 --- a/src/functions/commands.ts +++ b/src/functions/commands.ts @@ -28,7 +28,9 @@ export async function fbcDebug(copy: boolean): Promise { 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( diff --git a/src/functions/confirmLeave.js b/src/functions/confirmLeave.js index ffd115a..ca9851f 100644 --- a/src/functions/confirmLeave.js +++ b/src/functions/confirmLeave.js @@ -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(); diff --git a/src/functions/settingsPage.ts b/src/functions/settingsPage.ts index e06177f..97fb917 100644 --- a/src/functions/settingsPage.ts +++ b/src/functions/settingsPage.ts @@ -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; @@ -158,7 +162,7 @@ export default async function settingsPage(): Promise { 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" }; @@ -280,7 +284,7 @@ export default async function settingsPage(): Promise { 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; diff --git a/src/functions/toySync.ts b/src/functions/toySync.ts index c729c5e..45c38ef 100644 --- a/src/functions/toySync.ts +++ b/src/functions/toySync.ts @@ -24,7 +24,7 @@ export default async function toySync(): Promise { return; } - const { ButtplugClient, ButtplugBrowserWebsocketClientConnector } = await import("buttplug"); + const { ButtplugClient, ButtplugBrowserWebsocketClientConnector, DeviceOutput, InputType, OutputType } = await import("buttplug"); logInfo("Loaded Buttplug.io"); @@ -67,7 +67,7 @@ export default async function toySync(): Promise { 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; @@ -78,23 +78,23 @@ export default async function toySync(): Promise { 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: @@ -114,7 +114,7 @@ export default async function toySync(): Promise { 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;