41Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
43#if !STEAMVR_SUPPORTED_PLATFORM
46 if ( !KeyboardHandle.IsValid())
51 if (!GEngine->XRSystem.IsValid() || (GEngine->XRSystem->GetSystemName() !=
SteamVRSystemName))
56 vr::IVROverlay* VROverlay = vr::VROverlay();
59 vr::IVRInput* VRInput = vr::VRInput();
66 FTransform PlayerTransform = FTransform::Identity;
79 if (UWorld * CurWorld = GetWorld())
81 const ULocalPlayer* FirstPlayer = GEngine->GetFirstGamePlayer(CurWorld);
82 PC = FirstPlayer ? FirstPlayer->GetPlayerController(CurWorld) :
nullptr;
87 APawn * mpawn = PC->GetPawnOrSpectator();
92 PlayerTransform = mpawn->GetTransform();
96 float WorldToMetersScale = UHeadMountedDisplayFunctionLibrary::GetWorldToMetersScale(GetWorld());
99 FTransform RelTransform = this->GetComponentTransform();
100 RelTransform = RelTransform.GetRelativeTransform(PlayerTransform);
102 FQuat Rot = RelTransform.GetRotation();
103 RelTransform.SetRotation(FQuat(Rot.Y, Rot.Z, -Rot.X, -Rot.W));
105 FVector pos = RelTransform.GetTranslation();
106 RelTransform.SetTranslation(FVector(pos.Y, pos.Z, -pos.X) / WorldToMetersScale);
108 FVector scale = RelTransform.GetScale3D();
109 RelTransform.SetScale3D(FVector(scale.Y, scale.Z, scale.X) / WorldToMetersScale);
111 vr::HmdMatrix34_t NewTransform = UOpenVRExpansionFunctionLibrary::ToHmdMatrix34(RelTransform.ToMatrixNoScale());
112 VROverlay->SetKeyboardTransformAbsolute(vr::ETrackingUniverseOrigin::TrackingUniverseStanding, &NewTransform);
115 vr::VREvent_t VREvent;
117 while (KeyboardHandle.IsValid() && VROverlay->PollNextOverlayEvent(KeyboardHandle.VRKeyboardHandle, &VREvent,
sizeof(VREvent)))
133 switch (VREvent.eventType)
135 case vr::VREvent_KeyboardCharInput:
138 uint32 TextLen = VROverlay->GetKeyboardText((
char*)&OutString, 512);
141 case vr::VREvent_KeyboardClosed:
143 if (KeyboardHandle.IsValid())
145 VROverlay->DestroyOverlay(KeyboardHandle.VRKeyboardHandle);
146 KeyboardHandle.VRKeyboardHandle = vr::k_ulOverlayHandleInvalid;
150 case vr::VREvent_KeyboardDone:
153 uint32 TextLen = VROverlay->GetKeyboardText((
char*)&OutString, 512);
156 if (KeyboardHandle.IsValid())
158 VROverlay->HideKeyboard();
159 VROverlay->DestroyOverlay(KeyboardHandle.VRKeyboardHandle);
160 KeyboardHandle.VRKeyboardHandle = vr::k_ulOverlayHandleInvalid;