EEC We Go Faster
Twitter
Facebook
EEC Friends


Top posters
Kalinin (10289)
 
PATR10T (9021)
 
ilu2404 (3974)
 
JorritVD (3044)
 
alexmezza (2428)
 
bmwcrash (2420)
 
Totenkopf (2281)
 
dbr93 (2234)
 
Nectaria (2058)
 
Maxellero (1595)
 


Mouse/gamepad driving tutorial

Go down

Mouse/gamepad driving tutorial

Post  biboul on 9/8/2016, 13:49

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.]

[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...

______________________________________________________________________________________________________________________
Alex Biboul

biboul

Posts : 33
Join date : 2016-06-22
Age : 38
Location : France

Back to top Go down

Re: Mouse/gamepad driving tutorial

Post  Kalinin on 9/8/2016, 14:21

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

______________________________________________________________________________________________________________________
Will Mazeo
The only way to God is called Jesus, not religion, just Jesus.
avatar
Kalinin
EEC Team

Posts : 10289
Join date : 2012-05-16
Age : 30
Location : Brazil

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum