Unreal gamepad input without EnhancedInput
Hello! I am getting Noesis set up for our project in Unreal, and I am having some trouble with setting up gamepad input. I know the recommended method is to use EnhancedInput, but after some investigation, I would prefer to avoid that. This is for various reasons, but mainly because we have built our own input system on top of Unreal's legacy system, which makes it complex to shift the whole project to EnhancedInput. In addition, I don't want to break existing menus that use UMG/CommonUI while we transition to Noesis menus.
Therefore, I'm looking for a workaround to get gamepad input working with Noesis menus without EnhancedInput. So far, the most successful method I've found was following this post in order to handle inputs via UNoesisInstance::NativeOnKeyDown. This is working great for navigating menus with the dpad, but I'm not sure how I could leverage this to navigate with the left/right sticks as well, as I don't see these defined anywhere in InputEnums.h. Is there a way I could access stick inputs through NativeOnKeyDown (or maybe NativeOnAnalogValueChanged)?
Alternatively, I could use the EnhancedInput mapping context, if I could find a way to disable all legacy input actions and only enable enhanced actions at runtime. I haven't been able to find a clear spot to do this in the engine, but any leads would help! I'd appreciate any advice or insight you have to offer. Thanks!
Therefore, I'm looking for a workaround to get gamepad input working with Noesis menus without EnhancedInput. So far, the most successful method I've found was following this post in order to handle inputs via UNoesisInstance::NativeOnKeyDown. This is working great for navigating menus with the dpad, but I'm not sure how I could leverage this to navigate with the left/right sticks as well, as I don't see these defined anywhere in InputEnums.h. Is there a way I could access stick inputs through NativeOnKeyDown (or maybe NativeOnAnalogValueChanged)?
Alternatively, I could use the EnhancedInput mapping context, if I could find a way to disable all legacy input actions and only enable enhanced actions at runtime. I haven't been able to find a clear spot to do this in the engine, but any leads would help! I'd appreciate any advice or insight you have to offer. Thanks!
Re: Unreal gamepad input without EnhancedInput
Hi georgie,
Perhaps what we used to have is enough to get you through this transitional period. We just had a hardcoded mapping between Unreal FKeys and our Key_Gamepad. We removed this from InitKeyMap in NoesisInstance.cpp
We also handled scrolling using the right analog stick through NativeOnAnalogValueChanged like this:
You could do something similar to this.
If you are planning on avoiding enhanced input long term we can discuss alternatives that would allow you to customize the mappings.
Perhaps what we used to have is enough to get you through this transitional period. We just had a hardcoded mapping between Unreal FKeys and our Key_Gamepad. We removed this from InitKeyMap in NoesisInstance.cpp
Code: Select all
KeyMap.Add(EKeys::Gamepad_DPad_Up, Noesis::Key_GamepadUp);
KeyMap.Add(EKeys::Gamepad_LeftStick_Up, Noesis::Key_GamepadUp);
KeyMap.Add(EKeys::Gamepad_DPad_Down, Noesis::Key_GamepadDown);
KeyMap.Add(EKeys::Gamepad_LeftStick_Down, Noesis::Key_GamepadDown);
KeyMap.Add(EKeys::Gamepad_DPad_Left, Noesis::Key_GamepadLeft);
KeyMap.Add(EKeys::Gamepad_LeftStick_Left, Noesis::Key_GamepadLeft);
KeyMap.Add(EKeys::Gamepad_DPad_Right, Noesis::Key_GamepadRight);
KeyMap.Add(EKeys::Gamepad_LeftStick_Right, Noesis::Key_GamepadRight);
KeyMap.Add(EKeys::Virtual_Accept, Noesis::Key_GamepadAccept);
KeyMap.Add(EKeys::Virtual_Back, Noesis::Key_GamepadCancel);
KeyMap.Add(EKeys::Gamepad_LeftShoulder, Noesis::Key_GamepadPageLeft);
KeyMap.Add(EKeys::Gamepad_RightShoulder, Noesis::Key_GamepadPageRight);
KeyMap.Add(EKeys::Gamepad_LeftTrigger, Noesis::Key_GamepadPageUp);
KeyMap.Add(EKeys::Gamepad_RightTrigger, Noesis::Key_GamepadPageDown);
KeyMap.Add(EKeys::Gamepad_Special_Left, Noesis::Key_GamepadView);
KeyMap.Add(EKeys::Gamepad_Special_Right, Noesis::Key_GamepadMenu);
Code: Select all
FReply UNoesisInstance::NativeOnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& InAnalogEvent)
{
SCOPE_CYCLE_COUNTER(STAT_NoesisInstance_OnAnalogValueChanged);
if (XamlView)
{
if (FMath::Abs(InAnalogEvent.GetAnalogValue()) > 0.25f)
{
if (InAnalogEvent.GetKey() == EKeys::Gamepad_RightX)
{
XamlView->HScroll(InAnalogEvent.GetAnalogValue());
}
else if (InAnalogEvent.GetKey() == EKeys::Gamepad_RightY)
{
XamlView->Scroll(InAnalogEvent.GetAnalogValue());
}
}
}
return Super::NativeOnAnalogValueChanged(MyGeometry, InAnalogEvent);
}
If you are planning on avoiding enhanced input long term we can discuss alternatives that would allow you to customize the mappings.
Re: Unreal gamepad input without EnhancedInput
Thanks, this is working great to get us started! I do think we will avoid enhanced input long term, so it would be great to discuss alternatives.
Who is online
Users browsing this forum: No registered users and 2 guests