Get gamepad name/ID from RawInput

Hi,

I’m using the RawInput plugin so I can support DS gamepads. I’ve got this set up and I’m receiving input from my controllers.

However, I need to get the ID/name for the controller so I can save the config setup for later use. Any ideas on how to do this? I’ve combed through the code and can’t see how to do it.

In 4.26 there is a new WinDualShock plugin. I’d look into that and see if it works better than RawInput.

I think one problem with DS4 is it has slightly different directinput mappings (I think around the touchpad?) depending on whether it is connected wirelessly or through USB, but has the same id. I’m not sure if they have addressed this in the WinDualShock plugin.

Nevermind, I looked into it a bit, it is new in 4.26 but it looks like it may be some proprietary devkit thing:



// Use reflection to allow type not to exist if console code is not present
System.Type LibScePadType = System.Type.GetType("LibScePad");
bool bHasSupport = false;
if (LibScePadType != null)


I’m looking for a solution to this, as well.

As far as I can tell, FInputDeviceScopeis supposed to provide that information, but I can’t tell how I’m supposed to go about getting that information for a specific controller. After looking through the code for awhile, I assumed I could use FInputDeviceScope::GetCurrent() to somehow get the information I need, but it seems to always return a nullptr.

I ended up including my old SDL2 code in the end. SLD2 will give you all the details for the attached gamepad/joystick devices.
Will have a look if 4.26 works any better.

When using SDL2, do you use the includes that come with the engine? Or do you package a separate DLL with the game? I’ve heard a couple people mention they solved this with SDL2, but they never really expanded on the process they went through to solve it.

I use my own copy of SDL. In my prjoect I add the SDL headers, lib and dll files (I build these from a separate SDL .sln). Then in my project build.cs file I add the following:

// SDL2
PrivateIncludePaths.Add(“BeatHazard2/SDL2/include”);
PublicAdditionalLibraries.Add("$(ModuleDir)/SDL2/lib/SDL2.lib"); // lib
RuntimeDependencies.Add("$(TargetOutputDir)/SDL2.dll", Path.Combine(ModuleDirectory, “SDL2/lib/SDL2.dll”));

This adds the header path, includes the lib and copies the .dll file to the build location.

Let me know if you need any more info to get that working.

Thank you very much! I ended up making it into a plugin for use in other projects as well.

Still can’t figure out for the life of me how to include SDL2 into my project files, any code snippets of the .h & .cpp files would be a huge help!