New topics
Most active topics
Most Viewed Topics
Mouse/gamepad driving tutorial
Page 1 of 1
Mouse/gamepad driving tutorial
This is simply the best cheap method to have a good feeling of driving; Games will not put you automaticly stupid help or filters , you can have a free steering ( unlike gamepad/keyboard that autocenter and give cheated car control) and you have analogic input for gaz/brake/clutch.
[You must be registered and logged in to see this link.]
Vjoy will create a virtual controller with all the axis and stuff you have in standard joysticks. And Freepie will feed him with the info of your inputs. So as you move the mouse, freepie will understand where you are on a -16000; +16000 axis and send it to Vjoy which is sending inputs to the game.
Freepie is a Python code program, so we have to set a code to make this whole thing work. The file is attached . So the best is to make a shortcut of freepie that will automaticly load this script.
Windows shortcut : "c:\Program Files (x86)\FreePIE\FreePIE.exe" iracing.py /r"
You can find plenty of tutorial on the web if you type : Vjoy + freepie so i will not detail much, but if you are getting mad setting this, just PM me or leave a comment, we will see together. This is easy for programmer, but can be impossible for some non-geek
As it's freeware, so it's not necesseraly easy as Plug'n'Play
Once this is corrected set your mouse should move the joystick you got in windows panel. If all is ok , we can now launch the game and configure controls in game.
If your are in trouble with binding your controler, you can use programs as UJR, to remap them as you want, there is also gaming driver that are better than official ones.
So follow normally the wizard config, and all should work. Basically you are playing with a gamepad, but your mouse is your wheel.
Configuration tips
You can edit the code as you want, and change the binding of anything. For configuration, i recommand to you to put Steering reduction fonction to 1, and be sure you dont have acceleration in windows. The more linear is always the best.
So in game when you have to set your wheel at neutral point, put your mouse at center and dont move it anymore, ALT+TAB to Freepie and use maj+F5 to stop the script , now you can back to the game and click ok with your mouse without killing your calibration.
Since i'm using leftclick for shifting, everytime you will leftclick , the game will understand you are binding the leftclick ....so you cant confirm any action , so when you are doing configuration , you cant put a # ( lane 91) in front of the corresponding lane. This way the script will ignore this particulary lane (all green text is ignored by the script) and will not bind everything on Leftclick . Remove the # back to set the leftclick or play.
But you can edit the code and bind all you want as you want.
and Here is the code:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 5
def set_button(button, key):
if keyboard.getKeyDown(key):
v.setButton(button, True)
else:
v.setButton(button, False)
def calculate_rate(max, time):
if time > 0:
return max / (time / system.threadExecutionInterval)
else:
return max
int32_max = (2 ** 14) - 1
int32_min = (( 2** 14) * -1) + 1
v = vJoy[0]
v.x, v.y, v.z, v.rx, v.ry, v.rz, v.slider, v.dial = (int32_min,) * 8
# =============================================================================================
# Axis inversion settings (multiplier): normal = 1; inverted = -1
# =============================================================================================
global throttle_inversion, braking_inversion, clutch_inversion
throttle_inversion = 1
braking_inversion = 1
clutch_inversion = 1
handbrake_inversion = 1
# =============================================================================================
# Mouse settings
# =============================================================================================
global mouse_sensitivity, sensitivity_center_reduction
mouse_sensitivity = 10
sensitivity_center_reduction = 2
# =============================================================================================
# Steering settings
# =============================================================================================
global steering, steering_max, steering_min, steering_center_reduction
# Init values, do not change
steering = 0.0
steering_max = float(int32_max)
steering_min = float(int32_min)
steering_center_reduction = 1.0
# =============================================================================================
# Clutch settings
# =============================================================================================
# In milliseconds
clutch_increase_time = 0
clutch_decrease_time = 70
global Clutch, clutch_max, clutch_min
# Init values, do not change
clutch_max = int32_max * clutch_inversion
clutch_min = int32_min * clutch_inversion
Clutch = clutch_min
global clutch_increase_rate, clutch_decrease_rate
# Set clutch behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
clutch_increase_rate = calculate_rate(clutch_max, clutch_increase_time)
clutch_decrease_rate = calculate_rate(clutch_max, clutch_decrease_time) * -1
# =============================================================================================
# handbrake settings
# =============================================================================================
# In milliseconds
handbrake_increase_time = 20
handbrake_decrease_time = 50
global handbrake, handbrake_max, handbrake_min
# Init values, do not change
handbrake_max = int32_max * handbrake_inversion
handbrake_min = int32_min * handbrake_inversion
handbrake = handbrake_min
global handbrake_increase_rate, handbrake_decrease_rate
# Set clutch behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
handbrake_increase_rate = calculate_rate(handbrake_max, handbrake_increase_time)
handbrake_decrease_rate = calculate_rate(handbrake_max, handbrake_decrease_time) * -1
# assign button
vJoy[0].setButton(1,int(mouse.leftButton))
vJoy[0].setButton(2,int(mouse.rightButton))
vJoy[0].setButton(3,int(mouse.middleButton))
vJoy[0].setButton(4,int(keyboard.getKeyDown(Key.E)))
vJoy[0].setButton(5,int(keyboard.getKeyDown(Key.R)))
vJoy[0].setButton(6,int(keyboard.getKeyDown(Key.T)))
vJoy[0].setButton(7,int(keyboard.getKeyDown(Key.Y)))
# =================================================================================================
# LOOP START
# =================================================================================================
# =================================================================================================
# Steering logic
# =================================================================================================
if steering > 0:
steering_center_reduction = sensitivity_center_reduction ** (1 - (steering / steering_max))
elif steering < 0:
steering_center_reduction = sensitivity_center_reduction ** (1 - (steering / steering_min))
steering = steering + ((float(mouse.deltaX) * mouse_sensitivity) / steering_center_reduction)
if steering > steering_max:
steering = steering_max
elif steering < steering_min:
steering = steering_min
v.x = int(round(steering))
# =================================================================================================
# Clutch logic
# =================================================================================================
if Clutch > clutch_max * clutch_inversion:
Clutch = clutch_max * clutch_inversion
elif Clutch < clutch_min * clutch_inversion:
Clutch = clutch_min * clutch_inversion
v.rz = Clutch
# =================================================================================================
# handbrake logic
# =================================================================================================
if handbrake > handbrake_max * handbrake_inversion:
handbrake = clutch_max * handbrake_inversion
elif handbrake < handbrake_min * handbrake_inversion:
handbrake = handbrake_min * handbrake_inversion
v.rx = handbrake
if mouse.middleButton:
handbrake = handbrake + handbrake_increase_rate
else:
handbrake = handbrake + handbrake_decrease_rate
# =================================================================================================
# PIE diagnostics logic
# =================================================================================================
diagnostics.watch(v.x)
diagnostics.watch(v.rz)
diagnostics.watch(v.rx)
diagnostics.watch(steering_center_reduction)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Copy this in freepie, it will be easier to read with colors, lane numbers, etc...
[You must be registered and logged in to see this link.]
Vjoy will create a virtual controller with all the axis and stuff you have in standard joysticks. And Freepie will feed him with the info of your inputs. So as you move the mouse, freepie will understand where you are on a -16000; +16000 axis and send it to Vjoy which is sending inputs to the game.
Freepie is a Python code program, so we have to set a code to make this whole thing work. The file is attached . So the best is to make a shortcut of freepie that will automaticly load this script.
Windows shortcut : "c:\Program Files (x86)\FreePIE\FreePIE.exe" iracing.py /r"
You can find plenty of tutorial on the web if you type : Vjoy + freepie so i will not detail much, but if you are getting mad setting this, just PM me or leave a comment, we will see together. This is easy for programmer, but can be impossible for some non-geek
As it's freeware, so it's not necesseraly easy as Plug'n'Play
Once this is corrected set your mouse should move the joystick you got in windows panel. If all is ok , we can now launch the game and configure controls in game.
If your are in trouble with binding your controler, you can use programs as UJR, to remap them as you want, there is also gaming driver that are better than official ones.
So follow normally the wizard config, and all should work. Basically you are playing with a gamepad, but your mouse is your wheel.
Configuration tips
You can edit the code as you want, and change the binding of anything. For configuration, i recommand to you to put Steering reduction fonction to 1, and be sure you dont have acceleration in windows. The more linear is always the best.
So in game when you have to set your wheel at neutral point, put your mouse at center and dont move it anymore, ALT+TAB to Freepie and use maj+F5 to stop the script , now you can back to the game and click ok with your mouse without killing your calibration.
Since i'm using leftclick for shifting, everytime you will leftclick , the game will understand you are binding the leftclick ....so you cant confirm any action , so when you are doing configuration , you cant put a # ( lane 91) in front of the corresponding lane. This way the script will ignore this particulary lane (all green text is ignored by the script) and will not bind everything on Leftclick . Remove the # back to set the leftclick or play.
But you can edit the code and bind all you want as you want.
and Here is the code:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 5
def set_button(button, key):
if keyboard.getKeyDown(key):
v.setButton(button, True)
else:
v.setButton(button, False)
def calculate_rate(max, time):
if time > 0:
return max / (time / system.threadExecutionInterval)
else:
return max
int32_max = (2 ** 14) - 1
int32_min = (( 2** 14) * -1) + 1
v = vJoy[0]
v.x, v.y, v.z, v.rx, v.ry, v.rz, v.slider, v.dial = (int32_min,) * 8
# =============================================================================================
# Axis inversion settings (multiplier): normal = 1; inverted = -1
# =============================================================================================
global throttle_inversion, braking_inversion, clutch_inversion
throttle_inversion = 1
braking_inversion = 1
clutch_inversion = 1
handbrake_inversion = 1
# =============================================================================================
# Mouse settings
# =============================================================================================
global mouse_sensitivity, sensitivity_center_reduction
mouse_sensitivity = 10
sensitivity_center_reduction = 2
# =============================================================================================
# Steering settings
# =============================================================================================
global steering, steering_max, steering_min, steering_center_reduction
# Init values, do not change
steering = 0.0
steering_max = float(int32_max)
steering_min = float(int32_min)
steering_center_reduction = 1.0
# =============================================================================================
# Clutch settings
# =============================================================================================
# In milliseconds
clutch_increase_time = 0
clutch_decrease_time = 70
global Clutch, clutch_max, clutch_min
# Init values, do not change
clutch_max = int32_max * clutch_inversion
clutch_min = int32_min * clutch_inversion
Clutch = clutch_min
global clutch_increase_rate, clutch_decrease_rate
# Set clutch behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
clutch_increase_rate = calculate_rate(clutch_max, clutch_increase_time)
clutch_decrease_rate = calculate_rate(clutch_max, clutch_decrease_time) * -1
# =============================================================================================
# handbrake settings
# =============================================================================================
# In milliseconds
handbrake_increase_time = 20
handbrake_decrease_time = 50
global handbrake, handbrake_max, handbrake_min
# Init values, do not change
handbrake_max = int32_max * handbrake_inversion
handbrake_min = int32_min * handbrake_inversion
handbrake = handbrake_min
global handbrake_increase_rate, handbrake_decrease_rate
# Set clutch behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
handbrake_increase_rate = calculate_rate(handbrake_max, handbrake_increase_time)
handbrake_decrease_rate = calculate_rate(handbrake_max, handbrake_decrease_time) * -1
# assign button
vJoy[0].setButton(1,int(mouse.leftButton))
vJoy[0].setButton(2,int(mouse.rightButton))
vJoy[0].setButton(3,int(mouse.middleButton))
vJoy[0].setButton(4,int(keyboard.getKeyDown(Key.E)))
vJoy[0].setButton(5,int(keyboard.getKeyDown(Key.R)))
vJoy[0].setButton(6,int(keyboard.getKeyDown(Key.T)))
vJoy[0].setButton(7,int(keyboard.getKeyDown(Key.Y)))
# =================================================================================================
# LOOP START
# =================================================================================================
# =================================================================================================
# Steering logic
# =================================================================================================
if steering > 0:
steering_center_reduction = sensitivity_center_reduction ** (1 - (steering / steering_max))
elif steering < 0:
steering_center_reduction = sensitivity_center_reduction ** (1 - (steering / steering_min))
steering = steering + ((float(mouse.deltaX) * mouse_sensitivity) / steering_center_reduction)
if steering > steering_max:
steering = steering_max
elif steering < steering_min:
steering = steering_min
v.x = int(round(steering))
# =================================================================================================
# Clutch logic
# =================================================================================================
if Clutch > clutch_max * clutch_inversion:
Clutch = clutch_max * clutch_inversion
elif Clutch < clutch_min * clutch_inversion:
Clutch = clutch_min * clutch_inversion
v.rz = Clutch
# =================================================================================================
# handbrake logic
# =================================================================================================
if handbrake > handbrake_max * handbrake_inversion:
handbrake = clutch_max * handbrake_inversion
elif handbrake < handbrake_min * handbrake_inversion:
handbrake = handbrake_min * handbrake_inversion
v.rx = handbrake
if mouse.middleButton:
handbrake = handbrake + handbrake_increase_rate
else:
handbrake = handbrake + handbrake_decrease_rate
# =================================================================================================
# PIE diagnostics logic
# =================================================================================================
diagnostics.watch(v.x)
diagnostics.watch(v.rz)
diagnostics.watch(v.rx)
diagnostics.watch(steering_center_reduction)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Copy this in freepie, it will be easier to read with colors, lane numbers, etc...
Guest- Guest
Re: Mouse/gamepad driving tutorial
These alternative drivng tools can be very usefull. Before getitng my DFGT I drove with my android phone, it was much better than on keyboard
Guest- Guest
Similar topics
» [Tutorial] GTR2 AIW Creation Tutorial by ilu2404
» ILMC 2011/WEC 2012-2016 SATURAZ MOD v2.0
» Low FPS driving, but fine in replays
» Top Gear - Top 50 driving games
» No wheels in cockpitview when driving singleseaters
» ILMC 2011/WEC 2012-2016 SATURAZ MOD v2.0
» Low FPS driving, but fine in replays
» Top Gear - Top 50 driving games
» No wheels in cockpitview when driving singleseaters
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
24/10/2024, 21:16 by Chronskic
» BMW M4 GT4 G82 beta versions
19/10/2024, 23:17 by vitstalker
» GTWC Mod for gtr2 and motec display
11/10/2024, 12:40 by Stoner
» [DATA] Real weather data for GTR2 original tracks and more 1979 - 2023
4/10/2024, 22:08 by shovas
» [MOD] Real Weather for Crew Chief GTR2 Enhancements Plugin
4/10/2024, 22:01 by shovas
» RELEASE: THE STADIUM for GTR2 and POWER & GLORY
3/10/2024, 12:56 by Jim Clark
» Hello From italy !!!!
28/9/2024, 18:46 by Onofrio
» Argo JM16
24/9/2024, 18:39 by Vonbakker
» NASCAR 2005 (2004) Mod Question
22/9/2024, 08:20 by Jonny6833