35 FVROnWindowCloseRequested BPOnWindowCloseRequested;
39 bool bIgnoreWindowCloseCommands;
47 bool bAlsoChangeGamepPadInput;
51 TArray<FName> GamepadInputCategories;
53 bool IsValidGamePadKey(const FKey & InputKey)
55 if (!bAlsoChangeGamepPadInput)
58 FName KeyCategory = InputKey.GetMenuCategory();
60 return GamepadInputCategories.Contains(KeyCategory);
64 bool EventWindowClosing()
66 if (BPOnWindowCloseRequested.IsBound())
68 BPOnWindowCloseRequested.Broadcast();
71 if (bIgnoreWindowCloseCommands)
79 virtual void PostInitProperties()
override
81 Super::PostInitProperties();
83 if (GamepadInputCategories.Num() < 1)
85 GamepadInputCategories.Add(
FName(TEXT(
"Gamepad")));
86 GamepadInputCategories.Add(
FName(TEXT(
"PS4")));
87 GamepadInputCategories.Add(
FName(TEXT(
"XBox One")));
88 GamepadInputCategories.Add(
FName(TEXT(
"Touch")));
89 GamepadInputCategories.Add(
FName(TEXT(
"Gesture")));
96 virtual bool InputKey(
const FInputKeyEventArgs& EventArgs)
override
100 return Super::InputKey(EventArgs);
102 const int32 NumLocalPlayers = World->GetGameInstance()->GetNumLocalPlayers();
105 if (NumLocalPlayers < 2)
106 return Super::InputKey(EventArgs);
109 FInputKeyEventArgs NewStruct = EventArgs;
114 NewStruct.ControllerId++;
115 return Super::InputKey(NewStruct);
119 bool bRetVal =
false;
120 for (int32 i = 0; i < NumLocalPlayers; i++)
122 NewStruct.ControllerId = i;
123 bRetVal = Super::InputKey(NewStruct) || bRetVal;
130 virtual bool InputAxis(FViewport* tViewport, int32 ControllerId, FKey Key,
float Delta,
float DeltaTime, int32 NumSamples = 1,
bool bGamepad =
false)
override
133 const int32 NumLocalPlayers = World->GetGameInstance()->GetNumLocalPlayers();
136 if (((!Key.IsMouseButton() && !bGamepad) || (bGamepad && !IsValidGamePadKey(Key))) || NumLocalPlayers < 2 || GameInputMethod ==
EVRGameInputMethod::GameInput_Default || IgnoreInput())
137 return Super::InputAxis(tViewport, ControllerId, Key, Delta, DeltaTime, NumSamples, bGamepad);
143 return Super::InputAxis(tViewport, ControllerId, Key, Delta, DeltaTime, NumSamples, bGamepad);
147 bool bRetVal =
false;
148 for (int32 i = 0; i < NumLocalPlayers; i++)
150 bRetVal = Super::InputAxis(tViewport, i, Key, Delta, DeltaTime, NumSamples, bGamepad) || bRetVal;
159UVRGameViewportClient::UVRGameViewportClient(
const FObjectInitializer& ObjectInitializer)
160 : Super(ObjectInitializer)
virtual bool InputAxis(FViewport *tViewport, int32 ControllerId, FKey Key, float Delta, float DeltaTime, int32 NumSamples=1, bool bGamepad=false) override