Skip to content
Merged
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
Binary file added Docs/Images/StopCommands.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 18 additions & 11 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Buttplug UE

![ButtplugUE Icon](./Resources/Icon128.png)

An Unreal Engine integration for the [Buttplug.io](https://buttplug.io/) framework.

If you use this in your project(s), please consider supporting its continued development on my [Patreon](https://www.patreon.com/DeviantdVeloper) or [SubscribeStar](https://subscribestar.adult/deviant-dveloper).
Expand All @@ -16,17 +18,18 @@ Buttplug UE is a plugin for the Unreal Engine that implements the [Buttplug.io](

It provides both a Blueprint and a C++ interface (via a [Game Instance Subsystem](https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/Subsystems/UGameInstanceSubsystem?application_version=5.3)) which allows you to directly manage individual devices, as well as providing basic support for "fire-and-forget" device commands.

Tested with Intiface Central v2.5.6+24
Tested with Intiface Central v2.6.4+30

### Supported Engine Versions

| Engine | Supported | Notes |
| ------ | --------- | ------------------ |
| 5.1 | Yes | No Example Content |
| 5.2 | Yes | |
| 5.3 | Yes | |
| 5.4 | Yes | |
| <= 5.0 | No | |
| Engine | Supported | Notes |
| ------ | ---------------- | ----------------------------------- |
| <= 5.0 | No | |
| 5.1 | Deprecated | Check Releases, No Example Content |
| 5.2 | Deprecated | Check Releases |
| 5.3 | Yes | No Example Content (check releases) |
| 5.4 | Yes | |
| 5.5 | Yes | |

### Supported Platforms

Expand Down Expand Up @@ -84,13 +87,17 @@ Finally, you can now send commands to the devices in question. Each device stru

![Sending commands to devices](./Docs/Images/SendCommands.png)

This is a single command, and as such you will also need to tell it when to stop; sending a strenth of 0 or using the `StopAllDevices` command will achieve this.
This is a single command, and as such you will also need to tell it when to stop; sending a strength of 0 or using one of the Stop commands will achieve this.

![Sending stop commands to devices](./Docs/Images/StopCommands.png)

These functions behave as you would expect: stopping a given device, or stopping all devices (wise to do on quit, close, exit, etc). They optionally also can either ignore or include currently ongoing Pattern Commands, as these are handled locally in the plugin.

A simpler approach is to use the "Pattern Command"

![Sending pattern commands to devices](./Docs/Images/SendPatternCommands.png)

These pattern commands take a Duration and a Float Curve as arguments. The Curve dictates the strength and will loop for the duration, self-ending.
These pattern commands take a Duration and a Float Curve as arguments. The Curve dictates the strength and will loop for the duration, self-ending. These essentially sample the given curve at the set rate, sending updates to the device per-update.

### Example Procedure

Expand Down Expand Up @@ -160,4 +167,4 @@ In no particular order:

If you use this in your project(s), please consider supporting its continued development on my [Patreon](https://www.patreon.com/DeviantdVeloper) or [SubscribeStar](https://subscribestar.adult/deviant-dveloper), as well as that of the official [Buttplug.io](https://www.patreon.com/qdot) development.

You can contact me here, on [Twitter/X](https://twitter.com/DeviantDveloper), or Discord (\_ddev\_).
You can contact me here, on [Bluesky](https://bsky.app/profile/ddev.games), or Discord (\_ddev\_).
Binary file modified Resources/Icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions Source/ButtplugUE/Private/BPDeviceSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,14 @@ int32 UBPDeviceSubsystem::StopDevice(const FBPDeviceObject& Device, FBPInstanced
}
if(bStopPatterns)
{
for(const TPair<FGuid, UBPManagedCommand*> Command : ManagedCommands)
//for(const TPair<FGuid, UBPManagedCommand*> Command : ManagedCommands)
TArray<UBPManagedCommand*> Commands;
ManagedCommands.GenerateValueArray(Commands);
for(int i = 0; i < Commands.Num(); i++)
{
if(Command.Value->GetDevice() == Device)
if(Commands[i]->GetDevice() == Device)
{
Command.Value->StopCommand();
Commands[i]->StopCommand();
}
}
}
Expand All @@ -289,8 +292,11 @@ int32 UBPDeviceSubsystem::StopAllDevices(FBPInstancedResponseDelegate Response,
{
for (const TPair<FGuid, UBPManagedCommand*> Command : ManagedCommands)
{
Command.Value->StopCommand();
//Do not broadcast on stop completion to avoid changing the array while we are iterating through it.
Command.Value->StopCommand(false);
Command.Value->MarkAsGarbage();
}
ManagedCommands.Empty();
}
return PackAndSendMessage<FBPStopAllDevices>(Response);
}
Expand Down
7 changes: 5 additions & 2 deletions Source/ButtplugUE/Private/BPManagedCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ void UBPManagedCommand::UpdateDevice()
}
}

void UBPManagedCommand::StopCommand()
void UBPManagedCommand::StopCommand(bool bBroadcastStop /*= true*/)
{
bActive = false;
GetBP()->StopDevice(Device, FBPInstancedResponseDelegate(), false);
OnCommandStopped.Broadcast(Id);
if(bBroadcastStop)
{
OnCommandStopped.Broadcast(Id);
}
}

FBPDeviceObject UBPManagedCommand::GetDevice() const
Expand Down
2 changes: 1 addition & 1 deletion Source/ButtplugUE/Public/BPManagedCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BUTTPLUGUE_API UBPManagedCommand : public UObject, public FTickableGameObj

static UBPManagedCommand* CreateManagedCommand(UObject* Context, FBPDeviceObject TargetDevice, FInstancedStruct InCommand,
UCurveFloat* InPattern, float InDurationSeconds, FGuid InId, int32 UpdatesPerSecond = 10);
void StopCommand();
void StopCommand(bool bBroadcastStop = true);

FBPDeviceObject GetDevice() const;

Expand Down
7 changes: 7 additions & 0 deletions Source/ButtplugUE/Public/BPTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
#pragma once

#include "CoreMinimal.h"
#include "Misc/EngineVersionComparison.h"

#include "Kismet/BlueprintFunctionLibrary.h"

#if UE_VERSION_OLDER_THAN(5, 5, 0)
#include "InstancedStruct.h"
#else
#include "StructUtils/InstancedStruct.h"
#endif

#include "JsonObjectConverter.h"
#include "Engine/DataTable.h"

Expand Down