buttplug connection, losing my mind over dotnet
This commit is contained in:
parent
73c65893e8
commit
a28bebc626
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
BepInEx
|
BepInEx
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
12
FodyWeavers.xml
Normal file
12
FodyWeavers.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||||
|
<Costura>
|
||||||
|
<IncludeAssemblies>
|
||||||
|
System.*
|
||||||
|
deniszykov.WebSocketListener
|
||||||
|
Buttplug
|
||||||
|
Buttplug.Client.Connectors.WebsocketConnector
|
||||||
|
Newtonsoft.Json
|
||||||
|
</IncludeAssemblies>
|
||||||
|
</Costura>
|
||||||
|
</Weavers>
|
|
@ -13,11 +13,15 @@
|
||||||
</RestoreAdditionalProjectSources>
|
</RestoreAdditionalProjectSources>
|
||||||
<RootNamespace>MetalButtplug</RootNamespace>
|
<RootNamespace>MetalButtplug</RootNamespace>
|
||||||
<NoWarn>$(NoWarn);NU1603</NoWarn>
|
<NoWarn>$(NoWarn);NU1603</NoWarn>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.*" IncludeAssets="compile" />
|
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.*" IncludeAssets="compile" />
|
||||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
|
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
|
||||||
|
<PackageReference Include="Buttplug" Version="3.0.1" />
|
||||||
|
<PackageReference Include="Buttplug.Client.Connectors.WebsocketConnector" Version="3.0.1" />
|
||||||
|
|
||||||
<Reference Include="UnityEngine.CoreModule">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>./BepInEx/interop/UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>./BepInEx/interop/UnityEngine.CoreModule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -27,5 +31,20 @@
|
||||||
<Reference Include="Il2Cppmscorlib">
|
<Reference Include="Il2Cppmscorlib">
|
||||||
<HintPath>./BepInEx/interop/Il2Cppmscorlib.dll</HintPath>
|
<HintPath>./BepInEx/interop/Il2Cppmscorlib.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Buttplug">
|
||||||
|
<HintPath>./deps/Buttplug.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Buttplug.Client.Connectors.WebsocketConnector">
|
||||||
|
<HintPath>./deps/Buttplug.Client.Connectors.WebsocketConnector.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
|
||||||
|
<!-- the crap that makes this fucking thing work -->
|
||||||
|
<PackageReference Include="Costura.Fody" Version="5.7.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Fody" Version="6.8.0">
|
||||||
|
<IncludeAssets>runtime; build; compile; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using BepInEx.Logging;
|
using BepInEx.Logging;
|
||||||
using BepInEx.Unity.IL2CPP;
|
using BepInEx.Unity.IL2CPP;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using MetalButtplug.Utils;
|
||||||
|
|
||||||
namespace MetalButtplug;
|
namespace MetalButtplug;
|
||||||
|
|
||||||
|
@ -13,7 +14,10 @@ public class Plugin : BasePlugin {
|
||||||
Plugin.Log = base.Log;
|
Plugin.Log = base.Log;
|
||||||
|
|
||||||
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
|
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
|
||||||
Log.LogInfo("GAY SEX!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
harmony.PatchAll(typeof(Patches.UpdateBeatPatch));
|
harmony.PatchAll(typeof(Patches.UpdateBeatPatch));
|
||||||
|
Log.LogInfo("Applied patches");
|
||||||
|
|
||||||
|
ButtplugManager.Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
42
Utils/ButtplugManager.cs
Normal file
42
Utils/ButtplugManager.cs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
using Buttplug.Client;
|
||||||
|
using Buttplug.Client.Connectors.WebsocketConnector;
|
||||||
|
|
||||||
|
namespace MetalButtplug.Utils;
|
||||||
|
|
||||||
|
internal static class ButtplugManager {
|
||||||
|
public static bool enabled = false;
|
||||||
|
static ButtplugClient client;
|
||||||
|
|
||||||
|
public async static void Init() {
|
||||||
|
ButtplugManager.client = new ButtplugClient("Metal: Hellsinger");
|
||||||
|
|
||||||
|
Plugin.Log.LogInfo("Attempting buttplug connection");
|
||||||
|
|
||||||
|
try {
|
||||||
|
var connector = new ButtplugWebsocketConnector(new Uri("ws://localhost:12345"));
|
||||||
|
await client.ConnectAsync(connector);
|
||||||
|
Plugin.Log.LogInfo("Connected to buttplug server!");
|
||||||
|
enabled = true;
|
||||||
|
} catch(Exception ex) {
|
||||||
|
Plugin.Log.LogWarning($"Failed to connect: {ex.Message}\nDisabling buttplug integration - Is Intiface running?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
client.DeviceAdded += OnDeviceAdd;
|
||||||
|
client.DeviceRemoved += OnDeviceRemove;
|
||||||
|
|
||||||
|
Plugin.Log.LogInfo($"Found devices:");
|
||||||
|
foreach (ButtplugClientDevice device in client.Devices) {
|
||||||
|
Plugin.Log.LogInfo($"- ${device.DisplayName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnDeviceAdd(object sender, DeviceAddedEventArgs e) {
|
||||||
|
Plugin.Log.LogInfo($"Device added: {e.Device.DisplayName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnDeviceRemove(object sender, DeviceRemovedEventArgs e) {
|
||||||
|
Plugin.Log.LogInfo($"Device removed: {e.Device.DisplayName}");
|
||||||
|
}
|
||||||
|
}
|
7
dev-build.sh
Executable file
7
dev-build.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dotnet build
|
||||||
|
rm -vrf BepInEx/plugins/MetalButtplug
|
||||||
|
mkdir -v BepInEx/plugins/MetalButtplug
|
||||||
|
#cp bin/Debug/net6.0/{MetalButtplug,Buttplug,Buttplug.Client.Connectors.WebsocketConnector,System.Threading.Channels}.dll BepInEx/plugins/MetalButtplug
|
||||||
|
cp -v bin/Debug/net6.0/MetalButtplug.{pdb,dll} BepInEx/plugins/MetalButtplug/
|
Loading…
Reference in a new issue