5#include "CoreMinimal.h"
10#include "Engine/Engine.h"
12#include "IXRTrackingSystem.h"
13#include "IHeadMountedDisplay.h"
15#include "SteamVRKeyboardComponent.generated.h"
25UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent))
38 virtual
void TickComponent(
float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
39 virtual
void OnUnregister() override;
42#if STEAMVR_SUPPORTED_PLATFORM
46 UPROPERTY(BlueprintAssignable, Category =
"VRExpansionFunctions|SteamVR")
47 FVRKeyboardStringCallbackSignature OnKeyboardDone;
49 UPROPERTY(BlueprintAssignable, Category = "VRExpansionFunctions|SteamVR")
50 FVRKeyboardNullCallbackSignature OnKeyboardClosed;
52 UPROPERTY(BlueprintAssignable, Category = "VRExpansionFunctions|SteamVR")
53 FVRKeyboardStringCallbackSignature OnKeyboardCharInput;
57 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf = "true", ExpandEnumAsExecs = "Result"))
58 void OpenVRKeyboard(
bool bIsForPassword,
bool bIsMultiline,
bool bUseMinimalMode,
bool bIsRightHand, int32 MaxCharacters, FString Description, FString StartingString,
EBPOVRResultSwitch & Result)
60#if !STEAMVR_SUPPORTED_PLATFORM
76 if (!GEngine->XRSystem.IsValid() || (GEngine->XRSystem->GetSystemName() !=
SteamVRSystemName))
82 vr::IVROverlay* VROverlay = vr::VROverlay();
90 vr::EVROverlayError OverlayError;
91 OverlayError = VROverlay->CreateOverlay(
"KeyboardOverlay",
"Keyboard Overlay", &KeyboardHandle.
VRKeyboardHandle);
93 if (OverlayError != vr::EVROverlayError::VROverlayError_None || !KeyboardHandle.
IsValid())
100 vr::EGamepadTextInputMode Inputmode = bIsForPassword ? vr::EGamepadTextInputMode::k_EGamepadTextInputModePassword : vr::EGamepadTextInputMode::k_EGamepadTextInputModeNormal;
101 vr::EGamepadTextInputLineMode LineInputMode = bIsMultiline ? vr::EGamepadTextInputLineMode::k_EGamepadTextInputLineModeMultipleLines : vr::EGamepadTextInputLineMode::k_EGamepadTextInputLineModeSingleLine;
102 uint32 HandInteracting = bIsRightHand ? 0 : 1;
105 OverlayError = VROverlay->ShowKeyboardForOverlay(KeyboardHandle.
VRKeyboardHandle, Inputmode, LineInputMode, TCHAR_TO_ANSI(*Description), MaxCharacters, TCHAR_TO_ANSI(*StartingString), bUseMinimalMode, HandInteracting);
107 OverlayError = VROverlay->ShowKeyboardForOverlay(KeyboardHandle.
VRKeyboardHandle, Inputmode, LineInputMode, TCHAR_TO_ANSI(*Description), MaxCharacters, TCHAR_TO_ANSI(*StartingString), bUseMinimalMode, HandInteracting);
109 if (OverlayError != vr::EVROverlayError::VROverlayError_None)
133 this->SetComponentTickEnabled(
true);
140 UFUNCTION(BlueprintCallable, Category =
"VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf =
"true", ExpandEnumAsExecs =
"Result"))
143#if !STEAMVR_SUPPORTED_PLATFORM
147 if ( !KeyboardHandle.
IsValid())
153 if (!GEngine->XRSystem.IsValid() || (GEngine->XRSystem->GetSystemName() !=
SteamVRSystemName))
159 vr::IVROverlay* VROverlay = vr::VROverlay();
167 VROverlay->HideKeyboard();
170 vr::EVROverlayError OverlayError;
173 this->SetComponentTickEnabled(
false);
180 UFUNCTION(BlueprintCallable, Category =
"VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf =
"true", ExpandEnumAsExecs =
"Result"))
181 void ReOpenVRKeyboardForUser(
bool bIsForPassword,
bool bIsMultiline,
bool bUseMinimalMode,
bool bIsRightHand, int32 MaxCharacters, FString Description, FString StartingString,
EBPOVRResultSwitch & Result)
183#if !STEAMVR_SUPPORTED_PLATFORM
187 if ( !KeyboardHandle.
IsValid())
193 if (!GEngine->XRSystem.IsValid() || (GEngine->XRSystem->GetSystemName() !=
SteamVRSystemName))
199 vr::IVROverlay* VROverlay = vr::VROverlay();
207 vr::EVROverlayError OverlayError;
209 VROverlay->HideKeyboard();
211 vr::EGamepadTextInputMode Inputmode = bIsForPassword ? vr::EGamepadTextInputMode::k_EGamepadTextInputModePassword : vr::EGamepadTextInputMode::k_EGamepadTextInputModeNormal;
212 vr::EGamepadTextInputLineMode LineInputMode = bIsMultiline ? vr::EGamepadTextInputLineMode::k_EGamepadTextInputLineModeMultipleLines : vr::EGamepadTextInputLineMode::k_EGamepadTextInputLineModeSingleLine;
213 uint32 HandInteracting = bIsRightHand ? 0 : 1;
216 OverlayError = VROverlay->ShowKeyboardForOverlay(KeyboardHandle.
VRKeyboardHandle, Inputmode, LineInputMode, TCHAR_TO_ANSI(*Description), MaxCharacters, TCHAR_TO_ANSI(*StartingString), bUseMinimalMode, HandInteracting);
218 OverlayError = VROverlay->ShowKeyboardForOverlay(KeyboardHandle.
VRKeyboardHandle, Inputmode, LineInputMode, TCHAR_TO_ANSI(*Description), MaxCharacters, TCHAR_TO_ANSI(*StartingString), bUseMinimalMode, HandInteracting);
220 if (OverlayError != vr::EVROverlayError::VROverlayError_None)
234 UFUNCTION(BlueprintCallable, Category =
"VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf =
"true", ExpandEnumAsExecs =
"Result"))
237#if !STEAMVR_SUPPORTED_PLATFORM
241 if ( !KeyboardHandle.
IsValid())
247 if (!GEngine->XRSystem.IsValid() || (GEngine->XRSystem->GetSystemName() !=
SteamVRSystemName))
253 vr::IVROverlay* VROverlay = vr::VROverlay();
262 uint32 TextLen = VROverlay->GetKeyboardText((
char*)&OutString, 512);
264 Text = FString(ANSI_TO_TCHAR(OutString));
static FName SteamVRSystemName(TEXT("SteamVR"))
EBPOVRResultSwitch
UENUM()
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FVRKeyboardNullCallbackSignature)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FVRKeyboardStringCallbackSignature, FString, Text)
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent))
FVRKeyboardStringCallbackSignature OnKeyboardCharInput
UPROPERTY(BlueprintAssignable, Category = "VRExpansionFunctions|SteamVR")
void CloseVRKeyboard(EBPOVRResultSwitch &Result)
UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf = "true",...
void ReOpenVRKeyboardForUser(bool bIsForPassword, bool bIsMultiline, bool bUseMinimalMode, bool bIsRightHand, int32 MaxCharacters, FString Description, FString StartingString, EBPOVRResultSwitch &Result)
UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf = "true",...
void GetVRKeyboardText(FString &Text, EBPOVRResultSwitch &Result)
UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf = "true",...
FVRKeyboardNullCallbackSignature OnKeyboardClosed
UPROPERTY(BlueprintAssignable, Category = "VRExpansionFunctions|SteamVR")
FVRKeyboardStringCallbackSignature OnKeyboardDone
UPROPERTY(BlueprintAssignable, Category = "VRExpansionFunctions|SteamVR")
void OpenVRKeyboard(bool bIsForPassword, bool bIsMultiline, bool bUseMinimalMode, bool bIsRightHand, int32 MaxCharacters, FString Description, FString StartingString, EBPOVRResultSwitch &Result)
UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|SteamVR", meta = (bIgnoreSelf = "true",...
uint64_t VRKeyboardHandle