Microtube Docs
EN中文
Developers / Unreal / Plugin architecture & API

Unreal plugin architecture & API

How the HexR plugin is built, its Blueprint and C++ API, and how it maps onto the Unity package.

Version

This page describes the HexR plugin 0.2.0 for Unreal Engine 5.8.

What is in the plugin

ModuleWhatIn your Build.cs
HexRCoreThe glove protocol, with no gameplay code: the command encoder, the readings decoder, the haptic scheduler behind the glove effects, and the shared types (EHexRHand, EHexRFinger, EHexRChannels)Yes, with HexR
HexRBleBluetooth LE: Windows’ own Bluetooth (WinRT), Android’s through Java, and simulated gloves for tests and machines without BluetoothRarely
HexRThe gloves and their manager, the tracked hands and touch points, the Pressure Controller, the components, the HexR Pawn, the HexR menu, VR Template grabs, Unreal’s haptics on the gloves and the project settingsYes
HexRPassthroughPassthrough on Quest and PICO through Unreal’s own OpenXR, and the HexR Passthrough Visibility componentTo switch passthrough from C++
HexRRemoteHexR Remote: the network server the HexR Companion app talks to, and the Android capture of the view and its soundFor HexR Remote commands from C++
HexREditorThe Tools → HexR menu, the HexR Tools tab and the project validator. Also two command-line tools, run with UnrealEditor-Cmd -run=: HexRValidate and HexRMakeSamplesNo, editor only
Content/BP_HexRRig, BP_HexRMenu, the example Blueprints and the L_HexRDemo level—

The automation tests are a separate development plugin, HexRTests. The zip leaves them out.

Everything a game uses is a UCLASS with Blueprint-callable functions and Blueprint-assignable events, so Blueprint and C++ see the same API. Blueprint shows the names with spaces: ConnectHand is the Connect Hand node. Each function’s comment in Plugins/HexR/Source/*/Public is the node’s tooltip.

Wire compatibility

The plugin sends the glove the same bytes as the Unity package. Its tests compare 555 encoded commands with the Unity package’s output. The Godot addon is checked against the same set.

Connecting the glove

Blueprint and C++ API

The calls most games use.

UHexRSubsystem: where to start

MemberDoes
UHexRSubsystem::Get(WorldContext)The game instance’s HEXR subsystem. In Blueprint, the Get HexRSubsystem node
GetManager()The manager that owns both gloves
GetGlove(Hand), GetLeftGlove(), GetRightGlove()One glove
UHexREngineSubsystem::Get()The same manager outside a game, for editor tools

UHexRManager: both gloves

MemberDoes
ConnectHand(Hand)Connect that hand’s glove. Asks for the Bluetooth permission where needed, then scans or goes straight to the remembered glove. Does nothing if it is connected or connecting
DisconnectHand(Hand)Release the glove, then disconnect it
ToggleHand(Hand)Connect, cancel a connect in progress, or disconnect: what a Connect button does
IsHandConnected(Hand), IsHandConnecting(Hand)Connected now; a connect under way, including a wait between retries
SearchNearbyGloves(), ConnectTo(Hand, Address)List the gloves in range, then connect one of them
ForgetGlove(Hand), GetSavedGloveAddress(Hand)The remembered glove
GetGlove(Hand)One glove
GetTransportKind()Which Bluetooth is in use: Windows, Android or simulated

UHexRGlove: one glove

MemberDoes
Press(Channels, Intensity, Speed)Steady pressure until released
PressHand(Channels, PalmIntensity, FingerIntensity, Speed)The palm and the fingers at different strengths, in one write
Vibrate(Channels, Frequency, Intensity)Vibration until stopped
StopVibration(Channels)Stop the vibration; a steady press keeps pressing
Release(Channels)Pressure and vibration off
Pulse(Channels, Intensity, HoldSeconds, Speed)A press that lets go by itself, after 0.08 s at least
PulseHand(Channels, PalmIntensity, FingerIntensity, HoldSeconds, Speed)A pulse with the palm and the fingers at different strengths
SendPressure(Finger, bOn, Intensity, Speed), SendVibration(Finger, bOn, Frequency, Intensity)One channel, sent as it is
ReleaseAllChannels(), ReleaseChannels(Fingers)Let go of everything, or of some channels
GetChannelState(Finger)What was last sent to a channel
GetBatteryLevel(), GetBatteryState(), GetAirPressureKpa()Readings from the glove
IsConnected(), IsConnecting(), GetStatusText(), GetGloveName()Its state, as the HexR menu shows it
RememberDevice(Id), ForgetDevice(), ConnectToDevice(Id)The glove this platform remembers
bUseCustomDeviceName, CustomDeviceNameConnect to a glove with another name

Channel masks. The effects take an EHexRChannels mask. In Blueprint, tick the channels on the pin. In C++, HexR::ChannelBit(Finger), HexR::ChannelsFingers, HexR::ChannelsPalm and HexR::ChannelsAll make it.

How the effects are sent. Press, Vibrate, Pulse and the rest go through FHexRHapticScheduler, ported from the HEXR Sandbox demo app. It keeps what each channel should be doing and sends only what changed, at most six commands per write. It times each pulse from the write that actually carries it, so a short pulse survives Bluetooth batching. A pulse lasts at least 80 ms, below which it isn’t reliably felt.

UHexRPressureController: one hand’s haptics

MemberDoes
SingleThumbHaptic(Intensity) … SinglePalmHapticPress one channel
RemoveThumbHaptics() … RemovePalmHaptics()Release one channel
CustomSingleHaptics(Finger, bOn, Intensity, Speed, bBypassHandCheck)Press one channel, optionally skipping the hand-near check
CustomSingleVibrations(Finger, bOn, Intensity, Frequency, bBypassHandCheck)Vibrate one channel
TriggerAllHapticsIncrease(Intensity), TriggerCustomHapticsIncrease(Fingers, Intensity, Speed)Press every channel, or the chosen ones
TriggerAllVibrations, TriggerCustomVibrations(Fingers, Intensity, Frequency)Vibrate every channel, or the chosen ones
TriggerPinchPressure(Intensity), RemovePinchPressure()The thumb and index together
TriggerPulseIt(Intensity)One short pulse on every channel
RemoveAllHaptics(), RemoveAllVibrations()Release the whole hand
HandGrabbingCheck(bOn), PokeHoveringCheck(bOn), IsHandNear()Open or close the hand-near check, and read it
GetPressuresKpa(), GetPressuresRaw()The glove’s pressure readings
GetGlove()This hand’s glove

UHexRTouchLibrary: static helpers

MemberDoes
GetTouchPointInfo(Component, Hand, Finger)Whether a component is a touch point, and whose
TriggerFixPressure(TouchPoint, Intensity), RemoveHaptics(TouchPoint)Press or release the channel a touch point belongs to
TriggerVibration(TouchPoint, Frequency, Intensity), RemoveVibration(TouchPoint)Vibrate it, or stop
GetGlove(Hand), GetPressureController(WorldContext, Hand)Find a glove or a Pressure Controller
StrengthToIntensity(Strength)A component strength (10–60) as an intensity (0.1–1)

UHexRTrackedHandComponent: a tracked hand

MemberDoes
IsTracking(), event OnTrackingChangedWhether the headset sees the hand, and when that changes
GetFingerUse()How curled each finger is, from 0 (curled) to 1 (straight)
GetTouchPoint(Finger)One touch point
bShowHand, JointMesh, BoneMesh, HandMaterial, JointRadius, BoneRadiusThe hand it draws
bShowTouchPoints, TipRadius, TipOffsets, PalmSize, PalmOffsetThe touch points, in centimetres

UHexRWorldSubsystem returns the level’s tracked hand and Pressure Controller for each hand.

AHexRPawn and AHexRMenu

MemberDoes
AHexRPawn: Camera, LeftHand, RightHand, LeftPressure, RightPressure, RecenterThe rig’s components
bConnectGlovesOnBeginPlay, bFloorTrackingOrigin, SetShowTouchPoints(bShow)Connect when play starts; track from the floor; show the touch points
AHexRMenu: ToggleMenu(), SetMenuVisible(bVisible), IsMenuVisible(), Summon()Show, hide or bring the menu in front of the wearer
Demos, event OnDemo(Index), bShowRestart, RestartLevel()Your own buttons, and Restart
PanelWidth, bFingerPress, HandleIts size, fingertip pressing, and the header the wearer pinches to move it
bFollowWearer, Distance, Drop, FollowDistance, FollowAngleFollowing the wearer, and where it sits when it does

Zones and effect components

MemberDoes
Every zone: OnTouchBegin(Hand, Finger, TouchPoint), OnTouchEnd, GetTouchingChannels(Hand)A fingertip or the palm came in or left; what touches it now
UHexRGrabbableComponent: GrabTarget, bSimulatePhysicsOnRelease, GetGrabTarget()What moves with the hand; dropping with physics
UHexRFireComponent: Ignite(), Extinguish(), IsLit(), OnIgnited, OnExtinguishedLight it, put it out, and hear about it
UHexRWaterComponent: GetWetChannels(Hand), OnSplashWhich channels are in the water; a hand went in
UHexRHeartbeatComponent: SetRhythm(Rhythm), GetRhythm(), GetBpm(), OnBeatChange the rhythm, read the rate, and hear each beat
UHexRReturnHomeComponent: OnReturnedHomeThe object is back where it started

Passthrough

MemberDoes
UHexRPassthroughLibrary::IsPassthroughAvailable()The headset can show the room now
IsPassthroughOn(), SetPassthroughOn(bOn)Whether the room shows, and switching it
UHexRPassthroughVisibilityComponent: Visibility, IsHidingOwner()Hide in Passthrough or Only in Passthrough; whether it is hiding its actor now

Events

EventWhen
OnGloveConnected(Hand)A glove connected
OnGloveDisconnected(Hand)A glove’s link went down. IsHandConnecting is true if it is reconnecting by itself
OnGloveConnectFailed(Hand)One attempt failed; it may still retry
OnConnectAttemptEnded(Hand)The attempts ended without a connection: it gave up, was cancelled or wasn’t permitted
OnBatteryStateChanged, OnPumpChangedThe battery reading, or the air pump, changed
OnStatusChangedA glove’s status text changed: what the HexR menu shows
OnDeviceFound, OnNearbySearchEndedA scan saw a glove; a nearby search finished

These are on UHexRManager, for both gloves. Each UHexRGlove has the same kind of events for itself alone, such as OnConnected and OnDisconnected.

Coming from Unity

The classes keep the Unity package’s names, with Unreal’s prefixes, and their members are Unity’s in Unreal’s PascalCase: typeOfHaptics becomes TypeOfHaptics. Where Unreal differs, and why:

Unity packageUnreal pluginWhy
HexRManager.InstanceUHexRSubsystem (game instance) → GetManager()Unreal’s singletons are subsystems. The manager lives in UHexREngineSubsystem, so the editor and Play share one connection
HexR Main, HexR → Create HexR RigAHexRPawn / BP_HexRRig, Tools → HexR → Add HexR Rig to LevelA pawn with the hands on it
The HexR menuAHexRMenu / BP_HexRMenuThe same layout, colours and type, drawn in Slate
HaptGloveHandlerUHexRGloveUnreal’s class prefix
PressureTrackerMainUHexRPressureControllerAn actor component on the pawn
HexRTrackedHand, HapticFingerTriggerUHexRTrackedHandComponent, UHexRFingerTouchPointComponent, UHexRPalmTouchPointComponentComponents; UHexRTouchLibrary holds the finger trigger’s calls
FingerUseTrackingFHexRFingerUseCurl is measured by bone ratio by default. The Unity package’s way is the Self Calibrating curl measure
HexRGrabbable, SpecialHaptics, …UHexRGrabbableComponent, UHexRSpecialHapticsComponent, …Box components
The HEXR Sandbox’s fire, fountain and heartUHexRFireComponent, UHexRWaterComponent, UHexRHeartbeatComponentPart of the plugin, not only of a demo
The HEXR Sandbox’s GloveHaptics pumpUHexRGlove Press, Pulse and the rest, through FHexRHapticSchedulerOn the glove itself
Connect / Disconnect(hand)ConnectHand / DisconnectHand(hand)Same behaviour
ConnectLeftBT() / ConnectRightBT()ToggleHand(hand)One call for both hands
HaptGloveHandler.HandTypeEHexRHand
Haptics.FingerEHexRFinger everywhereOne channel order, the glove’s
UnityEvents onBluetoothConnected, onPresseddelegates OnConnected, OnButtonPressedBlueprint-assignable multicast delegates
OnReleased on HexRGrabbable / buttonsOnGrabReleased, OnButtonReleasedUnreal’s components already have an OnReleased
HEXRPressure and the other buildersUHexRGlove::SendPressure, SendVibration, or GetHaptics() with BTSend
HexR editor menu, HexR ToolsTools → HexR, Tools → HexR Tools, Project Settings → Plugins → HexR, console commands
Package Manager git URLThe plugin zip, unzipped into Plugins/Unreal installs project plugins as folders

Console commands

text
HexR.Status          prints Bluetooth's and both gloves' state to the log
HexR.Connect Left    connects the left glove (or cancels a connect, or disconnects)
HexR.Connect Right
HexR.Menu            shows or hides the HexR menu (HexR.Menu Show, HexR.Menu Hide)

HexR Remote

HexR Remote lets a phone on the same Wi-Fi find your app and control it, from the HexR Companion app’s Headsets tab. It is the HexRRemote module. It is off by default, because it opens network ports and can ask to share what the wearer sees.

Turn it on

Tick Enabled in Project Settings → Plugins → HexR Remote, and Enable in Editor for the editor’s Play sessions. Or call Start Remote on UHexRRemoteSubsystem, a game instance subsystem. It also has StopRemote(), IsRemoteRunning(), GetControlPort(), GetPhonesConnected() and GetPhonesWatching().

What a phone may do

Sharing the view

Video Width, Video Height, Video Bitrate Kbps and Video Fps set the video. Share Sound adds the app’s own sound, never the microphone’s. Android guards that capture with the microphone permission, so RECORD_AUDIO is added to the build only while the view and its sound are both shared.

Your own buttons

The Blueprint node Register Remote Command (Id, Label, an event) puts a button on the phone. The event runs on the game thread. Unregister Remote Command removes it. From C++, UHexRRemoteSubsystem::RegisterNativeCommand takes any callable; add HexRRemote to your Build.cs for it.

Ports

PortUsed for
UDP 47800Phones finding the app
TCP 47801Control
TCP 47802, 47803Video and sound

If a TCP port is taken, the next free one is used and announced. It speaks the same RemoteProtocol, version 1, as the Unity package, so the HexR Companion treats Unreal and Unity apps alike.

Not yet tried on a device

The protocol and the server pass their automation tests, but HexR Remote has not yet been tried with the HexR Companion app or on a headset.

Local network only

HexR Remote is not authenticated: anyone on the same Wi-Fi with a HexR Remote client can control the gloves. Bring a dedicated router to events.

How it is tested

The automation tests are in Tools → Session Frontend → Automation; filter for HexR. All 63 pass. They cover:

Beyond the tests, the prebuilt zip opens in a Blueprint-only project with no compiler, and that project packages for Android. On a Meta Quest 3 with real gloves, the gloves connect over Bluetooth and the haptics play. On a PICO 4 the app runs in passthrough; gloves there, and on Windows, have not been tried yet.