I’m writing some C++ code that uses udev library available on Ubuntu 16.04. If I was writing standalone executable I can link my code by ether specifying
-ludev option to GCC or using following line in CMakeLists.txt:
How do I do this in Unreal build system? The problem is that I can’t use
PublicAdditionalLibraries in Build.cs because the file name for Linux libraries like udev could be
libudev.1.so or something like that which is system dependent wich why GCC option
Background info: The reason I’m using udev is to get joystick vendor ID which seems to be the only viable way in Linux. The reason I’m getting in to this at all is because Unreal doesn’t support DirectInput based joysticks like flight RCs :(.
You should be able to use PublicAdditionalLibraries.Add(“udev”) as this will pass -ludev to the linker in the UBT toolchain. This is how Core.Build.cs links in dlopen for example.
Also as a note to your reasoning for using udev directly; UE4 uses SDL for the input backend (which uses udev and evdev internally) and therefore it should be able to be updated to support your joystick without needing to use udev in the engine code. There are essentially two ways you can do this:
- Map the joystick to an xinput (XBox) style controller using the SDL GameController mappings.
- One way is mapping the joystick can be done is through the functions https://wiki.libsdl.org/SDL_GameControllerMapping
- Another way is passing in the mappings as an environment variable SDL_GAMECONTROLLERCONFIG.
- Finally you can also find a community crowd source database of input mappings here GitHub - gabomdq/SDL_GameControllerDB: A community sourced database of game controller mappings to be used with SDL2 Game Controller functionality and then (as directed in the readme) use SDL_GameControllerAddMappingsFromFile.
- Add in your own SDL_Joystick code into LinuxApplication.cpp and use this code path if SDL_IsGameController returns false.