Logitech G25 pedals with ED - a guide

I thought I'd share this, as I've got it working nicely.

I have a Logitech G25 wheel, and as the pedals are permanently fixed under my desk, I thought I'd try and use them for ED. My intention was to have the right pedal increase the ship's throttle, and the left pedal decrease it. I also realised I could use the brake to intuitively zero the throttle, whichever direction you were flying.

For my first attempt, I simply mapped the pedals' axis to the throttle. This worked, but it meant I had to hold the accelerator down to cruise which made my foot hurt.
The second attempt involved mapping 'increase throttle' and 'decrease throttle' buttons to the pedals. This came closer, but as I was mapping them to button controls, I lost the analogue input - it would do nothing until the pedal was half-pressed, then give it everything it had. Still not ideal.

After a bit of research, I found some software called vJoy. This will set up a 'virtual joystick' -it emulates a joystick to the system, allowing any number of axes or buttons to be configured. You then send commands to the virtual joystick to move the axes - for this, I used FreePIE. FreePIE allows you to create Python scripts which will take input from any connected device, process it according to your script, and then feed it to the virtual joystick.

After some experimentation, I've written a script which will allow the accelerator to increase the throttle, the clutch to decrease it (and if you hold it long enough, engage reverse throttle), and the brake to move your speed to zero, whether you are moving forwards or backwards. All this while retaining the analogue input -you can just tickle the pedals to give a small change in throttle setting, but if you push it to the floor, you go from min to max in about a second.

I've found it very, very useful in combat and also whilst docking, as it leaves your hands free for other tasks/controls.

vJoy: http://vjoystick.sourceforge.net/site/
FreePIE: http://andersmalmgren.github.io/FreePIE/

Getting the game to recognise the axis can be tricky, as when you press a pedal to map the axis in the control options the game tends to map the pedals real input instead of the virtual joysticks input - to solve this, in the script I have a few lines (disabled by default, explained in the script) which allow you to use End and Delete to 'rock' the vJoy's axis back and forth so it can be initially detected by the game. Once you have the game controls set up, you can open the script and remove/comment these lines if you use End/Delete for other controls.

Code:
# for use with Logitech G25 pedals

def update():
	global yPos
	global multiplier
	global joyNumber

if starting:
	yPos = 0
	multiplier = 0.02 # increase or decrease this to alter the rate of change
	vJoy[0].y = -vJoy[0].axisMax
	joyNumber = 2 # set this to the device number of your pedals. If you don't know it, just try zero, then 1, 2, 3 etc

	
dAcc = (-joystick[joyNumber].y + 1000) * multiplier
dBrake = (joystick[joyNumber].sliders[0] * 4) * multiplier
dClutch = (-joystick[joyNumber].sliders[1] + 1000) * multiplier


if (dBrake < 0):
	dBrake = 0

yPos = yPos + dAcc
yPos = yPos - dClutch

if (yPos < 0):
	if (dBrake > -yPos):
		dBrake = -yPos
	yPos  = yPos + dBrake

if (yPos > 0):
	if (dBrake > yPos):
		dBrake = yPos
	yPos = yPos - dBrake



if (yPos > vJoy[0].axisMax):
	yPos = vJoy[0].axisMax
if (yPos < -vJoy[0].axisMax):
	yPos = -vJoy[0].axisMax
		
# // uncomment these lines to make Delete and End 'wiggle' the input (for in-game detection of the axis)		
#if (keyboard.getPressed(Key.End)):
#	yPos = 0
#if (keyboard.getPressed(Key.Delete)):
#	yPos = 10000
	
vJoy[0].y = yPos
 
Back
Top Bottom