Vjoy + freepie = The Crew (mouse)

Official forum for open source FreePIE discussion and development.
Post Reply
PCGamer88
One Eyed Hopeful
Posts: 17
Joined: Sun Nov 15, 2015 1:56 pm

Vjoy + freepie = The Crew (mouse)

Post by PCGamer88 »

Hello there,
I try the PC game The crew with vJoy + Freepie to play.
I use the script:

Code: Select all

	# =============================================================================================
	# /////////////////////////////// F1 2014 Mouse Steering Script ///////////////////////////////
	# =============================================================================================
	# This is a modified script, the original script was written by Skagen 
	# url: https://www.lfs.net/forum/post/1862759#post1862759
	# =============================================================================================
	# This script will use 3 axes 
	# 1. Steering (X-Axis)
	# 2. Throttle (Y-Axis)
	# 3. Brake (Z-Axis)
	# =============================================================================================
	# Use vJoy Feeder to set the axes in game
	# =============================================================================================
if starting:    
    system.setThreadTiming(TimingTypes.HighresSystemTimer)
    system.threadExecutionInterval = 5
    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
    # =============================================================================================
    # //////////////////////////////////////// SETTINGS ///////////////////////////////////////////
    # =============================================================================================
    # Mouse settings
    # =============================================================================================
    # Higher SCR = Smoother/Slower Response | Lower SCR = Harder/Quicker Response
    # With the game's built in steering settings, there's no need to change the scr value
    # SCR's effects can be felt better with arcade style racing games
    # =============================================================================================
    global mouse_sensitivity, sensitivity_center_reduction
    mouse_sensitivity = 80
    sensitivity_center_reduction = 0.1
    # =============================================================================================
    # Throttle & Brake Key:
    # =============================================================================================
    global throttle_key, brake_key
    throttle_key = Key.E
    brake_key = Key.W
    # Additional controls: Wheel Up = Reset Steering to Center @ Line 89
    # =============================================================================================
    # Throttle settings
    # =============================================================================================
    # Set throttle behaviour with the increase and decrease time (ms)
    # the actual increase and decrease rates are calculated automatically
    throttle_increase_time = 600
    throttle_decrease_time = 600
    # Init values, do not change
    global throttle, throttle_max, throttle_min, throttle_increase_rate, throttle_decrease_rate
    throttle_max = int32_max
    throttle_min = int32_min
    throttle = throttle_min
    throttle_increase_rate = calculate_rate(throttle_max, throttle_increase_time)
    throttle_decrease_rate = calculate_rate(throttle_max, throttle_decrease_time) * -1
    # =============================================================================================
    # Braking settings
    # =============================================================================================
    # Set brake behaviour with the increase and decrease time (ms)
    # the actual increase and decrease rates are calculated automatically
    braking_increase_time = 200
    braking_decrease_time = 100
    # Init values, do not change
    global braking, braking_max, braking_min, braking_increase_rate, braking_decrease_rate
    braking_max = int32_max
    braking_min = int32_min
    braking = braking_min
    braking_increase_rate = calculate_rate(braking_max, braking_increase_time)
    braking_decrease_rate = calculate_rate(braking_max, braking_decrease_time) * -1  
    # =============================================================================================
    # 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
# =================================================================================================
# LOOP START
# =================================================================================================
# Steering logic
# =================================================================================================
if mouse.wheelUp:
	steering = 0.0
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))
# =================================================================================================
# Throttle logic
# =================================================================================================
if keyboard.getKeyDown(throttle_key):
    throttle = throttle + throttle_increase_rate
else:
    throttle = throttle + throttle_decrease_rate
if throttle > throttle_max:
    throttle = throttle_max
elif throttle < throttle_min:
    throttle = throttle_min
v.y = throttle
# =================================================================================================
# Braking logic
# =================================================================================================
if keyboard.getKeyDown(brake_key):
    braking = braking + braking_increase_rate
else:
    braking = braking + braking_decrease_rate
if braking > braking_max:
    braking = braking_max
elif braking < braking_min:
    braking = braking_min
v.z = braking
# =================================================================================================
# vJoy BUTTONS 
# F1 2014 allows keyboard controls mixed with other input devices, so we don't need to set any more
# =================================================================================================
v.setButton(0,int(mouse.leftButton))
v.setButton(1,int(mouse.rightButton))
v.setButton(2,int(mouse.middleButton))
# =================================================================================================
# PIE diagnostics logic
# =================================================================================================
diagnostics.watch(v.x)
diagnostics.watch(v.y)
diagnostics.watch(v.z)
diagnostics.watch(steering_center_reduction)
Unfortunately, the car will not respond to my mouse movement :(
The game Grid 2 works perfectly.
But if I'm running The Crew with vJoy Feeder (demo) and the X axis pretending manually, the car responds. But why not go with freepie? Is there another script with which it works?
Looking forward to help. greeting PCGamer88
Relaxation
One Eyed Hopeful
Posts: 11
Joined: Sat Oct 10, 2015 12:53 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by Relaxation »

vJoy outputs DirectInput, which Grid 2 had support for, however many titles these days only support XInput.. what you could do is grab x360ce and set it up in The Crews folder (where its executable is) and it'll translate the DirectInput to XInput for that game.
PCGamer88
One Eyed Hopeful
Posts: 17
Joined: Sun Nov 15, 2015 1:56 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by PCGamer88 »

But if I vJoy Feeder use and adjusting the X axis manually, it works perfectly (without FreePie and x360ce). Why?
Relaxation
One Eyed Hopeful
Posts: 11
Joined: Sat Oct 10, 2015 12:53 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by Relaxation »

Are you running each by themselves? only one feeder(freepie, vjoy feeder demo) can control vJoys output
PCGamer88
One Eyed Hopeful
Posts: 17
Joined: Sun Nov 15, 2015 1:56 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by PCGamer88 »

so when I run the vjoy feeder demo itself, it works perfectly. When I run but only freepie works not :(
or what do you mean?

So it must be freepie or the script or?
Relaxation
One Eyed Hopeful
Posts: 11
Joined: Sat Oct 10, 2015 12:53 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by Relaxation »

What I'm trying to say is if you have the vJoy Feeder demo open then freepie can't send commands to the virtual controller since it's being occupied, was it closed in your testing?

I'm grabbing the demo, I'll test it later tonight

If people are using G27 wheels in their The Crew reviews that are DirectInput devices.. I wonder what the hang up is then.
PCGamer88
One Eyed Hopeful
Posts: 17
Joined: Sun Nov 15, 2015 1:56 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by PCGamer88 »

yes I closed the demo before I opened freebie. Freebie also sends commands (seen in Windows game controller settings).
I'm going to test x360ce. 32 or 64 bit (my OS is 64bit)?
Relaxation
One Eyed Hopeful
Posts: 11
Joined: Sat Oct 10, 2015 12:53 pm

Re: Vjoy + freepie = The Crew (mouse)

Post by Relaxation »

OK, it is possible to have [a 3rd party] freepie send X axis information to The Crew (Trial), while in game you have to goto Options and the very last entry is to allow advanced mouse control. BUT in my limited testing, even if you had enabled that in a previous session, the game freezes up outside you driving.. like at the main menu and game launching.. and I also had trouble playing until I unticked and reticked the option* and saved settings then ran the script. So even if I had went to options at the main menu, ticked advanced controls, ran the script and then selected play game I could drive just fine, even with the FreePIE->xoutput plugin, but going back to the main menu crashed to desktop.

*2nd session went to start the script but the game wasn't responding until I stopped script, reticked and applied, then started the script and could drive.. finally.

The F1 2014 mouse script** is what I used to test with [as well as a xoutput script I made that uses keypresses instead of mouse], left to right do a nice drift with no over steering while you still had the option to press left/right arrow keys to get the full effect. I didn't have to rename the dll or use any other hook methods.

**I would suggest you set everything but x, so y z rx ry rz, to zero.. remove the accel/decel parts since they don't function for this particular game and unzero'd sticks will mess with the menus in game in my limited experience.


OLD POST; ignore for the most part.. you can still blame Ubisoft for lack luster support.
Actually there may be other hook methods or renaming the xinput.dll to try with x360ce that some people got working with their [ubisoft] games.

Sorry, Ubisoft doesn't even want to load the game with any script running beforehand, even freezes when I start it after its running. Tried FreePIE->vJoy, FreePIE->vJoy->x360ce and FreePIE with the XOutput plugin and It didn't like any combination.

It's likely a game guard-ish feature. Blame Ubisoft.
Post Reply

Return to “FreePIE”