My adventure with the logitech sdk and ue4

to recap:

I want to use the g27 features in ue4. I tried to build the code, but i had issues. heres a thread about that:

Anyway, after trying to wrestle with the logitech code, I got frustrated and realized how stupid this approach is. I mean, would I want to change these source files every time I made a game that I wanted to add g27 functionality?? There was also a lot of source, so a lib just made too much sense.

To get it to build, I had to add all the code files from the …\ControllerInput\Src in the logitech sdk folder. I also had to mod the code a bit to make it work, since I’m using visual studio express. (no mention in the readme about this) The changes were minor however. I had to replace the

#include <atlstr.h> in LogiGamingSoftwareManager.h 


#include <windows.h>
#include <Tchar.h>// for the _T macro

The reason is that <atlstr.h> is part of the ATL stuff, and vis studio express doesn’t support mfc or atl.

Then, I had to add #include <Shlwapi.h> for the SHGetValue call LogiGamingSoftwareManager.cpp

Next, I had to change the new lib for xinput for the previous version, since the new version (XINPUT1_4.DLL) only works on windows 8 machines. With that change, I had to comment out

//XInputEnable(TRUE); //(Sets the reporting state of XInput....depending on window focus)

I was then finally able to take the sample code and broke it up into some usable functions (most of the sample was in a giant loop), remove all the windows stuff, and put all this newly “organized” code into the static dll class. There are prob a lot of stuff that’s included that’s not needed, and a few things that should be in there that’s not in there yet, but I will improve everything once i get everything working and I understand more of whats important. I made a small test console app, and I was able to get input from the gas pedal, so the dll and lib seem to work as intended.

Next is getting the dll to build with UE4. So far, I’m having issues trying to get it to build without linker errors. I’m still trying to wrap my head around everything…but I’ll keep you guys updated.

This is fantastic! I tried my hand at doing the same thing but gave up due to my inexperience.

All the best, hope you crack it soon!

I was looking for support of Logitech G27 and found this thread. Maybe here you could find some help about linking problems:

[edit] i cant uplaod the rar file :frowning:

Okay, so i have everything “done” I have that in quotes, because I’m still testing and figuring things out. I derived the functionality from the test program, so, if you have issues, let me know, so i can fix them…or implement your fix. The code that I used can be found here: (itsthe Logitech game software download)

once you have things installed, goto this dir:
C:\Program Files\Logitech\Gaming Software
and extract
The c++ code is in the zip, as well as a few test programs.

So, as I said, I used the test program to figure out how to make this lib. Heres how its used:

  1. Add the 32 and 64 bit versions of the lib to your project directory. I have mine at …\carTest\Source\LogitechSteeringWheel
    When unpacked, there should be 2 folders, one called “Libraries”, and one called “Includes”

  2. To add the .dll and.lib to your c++ project, all you have to do is edit the build.cs file for your game, so it can find the libs you just copy/pasted

For example, if your game is called carTest (like mine is, lol) then you will edit carTest.Build.cs. It should be located at …\carTest\Source\carTest

Edit your carTest.Build.cs file should look something like this

using UnrealBuildTool;

public class carTest : ModuleRules
	public carTest(TargetInfo Target)
		PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });
        PrivateDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

	public void LoadLib(TargetInfo Target)
		string LibraryPath = "C:/myGames/carTest/Source/LogitechSteeringWheel/Libraries/";
        string IncludePath = "C:/myGames/carTest/Source/LogitechSteeringWheel/Includes/";
        if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
            string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64/" : "Win32/";
            LibraryPath += PlatformString;
			PublicAdditionalLibraries.Add(LibraryPath + "LogitechSteeringWheel.lib");

I’m not sure if i need both PublicDependencyModuleNames and PrivateDependencyModuleNames, but it works…I’ll experiment with it later.

Also, i noticed that the libs themselves dont need a file since they are already built. I guess if you were working on the dll/lib in tandem with the game, then build.cs would be needed. (someone please verify) My build.cs for the Logitech stuff is identical to the one i have for my game build.cs

2b) The build.cs file acts like project properties of visual studios. So, you are setting the directories of your libs and includes and what not. However, visual studio itself has no clue about the unreal build process, so when using code from the lib, it will underline all the code it doesn’t recognize. If this annoys you, you can include the include folder in project-> properties → configuration properties → VC++ Directories and fill out the "Include directories field. This should give visual studio a clue on whats going on and stop its complaining.

  1. in your code, use it like this:

#include "carTest.h"
#include "carTestPawn.h"
#include "carTestWheelFront.h"
#include "carTestWheelRear.h"

//add the header file
#include "LogitechSteeringWheel.h"

AcarTestPawn::AcarTestPawn(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)

//init the steering wheel in the constructor or some early running method	

//change the properties of the wheel with this call. I'm not sure if it works right at the moment...still testing and figuring out what does what
//I'm not sure what these mean, besides the wheelRange (i named degreeOfTurn for the params)
//SteeringWheel::setWheelProperties(bool enableForce, int overallGain, int springGain,int damperGain, bool combinePedals, int degreeOfTurn )

//other constructor code

//add a tick method if theres not one already, this is to poll the wheel every frame, and use its inputs
void AcarTestPawn::TickActor(float DeltaSeconds, ELevelTick TickType, FActorTickFunction& ThisTickFunction)

	//add the values of brake and gas pedal to get overall result
	MoveForward(SteeringWheel::getThrottleValue() - SteeringWheel::getBrakeValue());
//without the negative value, the car would turn the wrong way, lol
//since ue4 has its own garbage collector and dont use destructors, make sure that we call BeginDestroy() to clean up the wheel
void AcarTestPawn::BeginDestroy()

  1. make sure you take the proper dll and place it next the game exe in …\carTest\Binaries\Win64 (or whereever your game exe llives…I dont know how to make this automatic yet. :frowning:

And with that, you should have control of your g27 and a slew of other steering wheels and control pads. For some joysticks, I had to guess how to implement them since I dont have them to see how they give values.

In the future, I’ll make the code blueprint friendly. However, for now, I’m more concerned on making sure everything works as intended.

Congrats and thanks for sharing it!

Can you upload the .rar to a file sharing website? I’m excited to check this out!

I’ll put it on my ugly website. Hold on while I make a new html page for it.

Hey Kablam, thanks for the awesome tutorial. I have my G27 working…pretty much.
I am no real coder…so C++ isn’t easy for me. But I noticed some differences in the code you posted and what I put in my code to get it to work. Firstly, the Tick method that was already in the code only had Tick(float Delta) and leaving it at that worked. The extra stuff would not compile. Next, the code will not compile when I put the BeginDestroy in there. Other than that, everything else worked as-is. So, while it works in the editor, I can’t recompile without a crash and I can’t replay without a crash: When I start the editor and PIE, everything works fine. I can stop the play and do stuff, but when I press play again, UE4 just crashes. Any ideas?
Also, I’m not sure how to manage the inputs from the G27…sensitivity and stuff. Is that all hard coded too? And what about the button inputs?
Anyway, thanks for the awesome help! You are pure genius:)

I’m not sure whats going on in the code, but I hope to get some free time soon to check it out. Now that I think about it, when using a g27 for the unity game engine, I had issues when destroying the g27 object. What you are experiencing is probably the same thing and it could be driver related. Not that the driver is bad, but as in me and the guy who made the unity plugin aren’t shutting things down properly the way the g27/windows expects. (BTW, the official unity plugin for the g27 crashes at start up, so maybe the driver is just not good?)

Anyway, Thanks for your hard work.:cool: As I said, I’ll try to carve out some time to look at it, but that wont be until next week.

quick question…because I may have updated the wrong code: for the second set of code tweaks, which file did you edit? I edited the Pawn.cpp. I mean, it’s working (ish)…but if I edited the wrong file, maybe that’s causing the crash?
By the way, thanks for your patience and guidance. I’m really not a coder and am very unfamiliar with C++…just kinda muddling through:)

I only had a chance to actually try it recently, and bar the crash when it’s trying to destroy the object - it worked great.

Would be great to eventually see support for other functions, such as controlling the force feedback and whatnot.

I tried to implement the library working with Win10 and UE4.8.

Sadly the Editor crashes at startup with an Stackoverflow in user32.dll or ntdll.dll due to a callback error.
This happens as soon as I use the Steeringwheel::initSteeringWheel() Function.

Does anyone has the same issues or is there a workaround?

After attempting this in 4.11.2 the project compiles fine, but the editor won’t launch and complains about the game-module not being set up properly. Yet to find what is specifically causing it to complain.