[Guide] Use any joystick as H-shifter (ETS2 / STDS)

Handleidingen over verschillende onderwerpen
Plaats reactie
Gebruikersavatar
Noodleguitar
Lid
Lid
Berichten: 82
Lid geworden op: di 25 sep 2012, 23:18
Locatie: Groningen

[Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door Noodleguitar »

Topic: How to make a joystick behave as an H-shifter
Author: Noodleguitar
Difficulty: Hard
Requirements: A plain-text editor (I recommend Notepad++)
Game: Euro Truck Simulator 2 or Scania Truck Driving Simulator (version 1.2.0 or higher)
Copyright info: Don't distribute without permission. Message me if you want this guide featured somewhere.

Introduction
I wrote this guide in English so it will be available to everyone rather than just the Dutch. And from my understanding, the majority of the Dutch can read English well enough to understand everything.

The guide is meant for those who don't have a Logitech G27 or an other wheel with an included H-shifter. In my mind, shifting with a sequential gearbox (with an up and down button) is far from ideal because you can't skip gears when upshifting for example. And of course, an H-shifter is much more realistic. This guide will teach you how to use any joystick as H-shifter along with your normal controls (a steering wheel + pedals, a gamepad, a keyboard etc.).

The guide allows for the use of both joystick spring-configurations. Meaning you can have your joystick's spring active (default) or you can remove the spring to avoid the joystick automatically snapping back to its center. How to do this is not in the scope of this guide and the difficulty of it depends on the make of your joystick.

Because the controller setup for both ETS2 and STDS is very similar the whole guide will work for either game. Any difference is noted in purple.

Lay-out information
Parts in blue refer to text that you might need to change. Parts in red mean that these items can have a different name on your system. Parts between "-------" headers should only be read if you meet the condition it states right above them.

The Guide
1. Enable all controllers
Make sure each controller you are going to use to play the game is installed and calibrated properly, including the joystick.

2. Temporarily bind some things to the H-shifter joystick
Go into the game and into the controller options screen. Now, enable all the controllers that will be used. The game shows a maximum of 3 controllers activated at one time. If you want to use more than three this is possible but make sure your joystick is one of the 3 set to active in the game.
Still in this options screen, temporarily bind "Steering Axis" to the joystick x-axis (move it sideways). Then, bind the "Acceleration Axis" to the joystick y-axis (move it upwards).
Now, if you have an analog button/pedal available that you want to use for the clutch, you can go ahead and set it up. If you want to use a normal button (yes, you can :D), don't do anything in-game with the clutch, it will come to light later.

The reason for these temporary binds is that it gives you access to the names of the buttons and axes you just bound, along with the name of the joystick device itself. These names will be used in the controls file.

3. Find your controls.sii file
First, exit the game. You don't want to edit any files while the game is running. When the game is running and you have a file open that's being read by the game you will probably need to refresh it after exiting the game (Notepad++ will notify you of this).
The file we need to modify to make the joystick work is called "controls.sii" and can be found at:

Code: Selecteer alles

\Users\[your name]\Documents\Euro Truck Simulator 2\profile\[profile ID]\
The path for Scania Truck Driving Simulator is:

Code: Selecteer alles

\Users\[your name]\Documents\SCANIA Truck Driving Simulator\profile\[profile ID]\
If you have multiple game profiles and you don't know which one is which ID, don't worry, we'll get to that soon.
Open controls.sii with your text editor. You should see a long document with lines starting with
config_lines[26]:
for example.

If you didn't know which profile ID you needed, go into the game and re-bind the handbrake to something odd (like "n"). Now when you open controls.sii (close the game first) in one of the profile ID maps, find the line that corresponds to the handbrake button. If it looks like this:
config_lines[137]: "mix parkingbrake `keyboard.n?0`"
then you have the right profile ID.

4. Find the names of the joystick and its axes
Now that we have the right controls.sii file, we can analyse and modify it.

Towards the top of the page you will see lines in the following form:
config_lines[2]: "device joy `di8.'{19645DB0-83DB-11E1-8001-444553540000}|{C21D046D-0000-0000-0000-504944564944}'`"
There will be multiple lines similar to this.
The "joy" behind "device" is a name that the game assigned to a particular controller. The abra-cadabra part in the end is the official name of the device but we don't have to deal with this name (luckily).

Now, below the two "device"-lines there should be a steering and throttle "input"-line:
config_lines[5]: "input j_steer `joy2.x`"
config_lines[6]: "input j_throttle `joy2.y`"

If you have payed attention you will notice that these lines contain "joy2" and thus that they refer to the controller named "joy2". The part behind the dot corresponds to an axis of the controller. These lines simply say that the steering is done with the x-axis and the acceleration is done with the y-axis of the joystick. Since we assigned the steering and acceleration to our H-shifter joystick we now know the name of the joystick that the game uses.

You now need to note or memorize the name of the joystick and the two axes (the name is "joy2" and the axes are "x" and "y" in this case). These will be used later.

4.1 If you use more than 3 controllers:
--------------------------------------------------------
In this case we need to change a few things to make the game the game accept 4 controllers. Remember me saying when setting up the controllers in game that one of them needed to be the H-shifter joystick? The purpose of that is to find the joystick's name.
Look at the two lines for steering and throttle described above and note the name of the joystick (using as example "joy3" here). Now, above these lines, find the "device" line with the name "joy3" in it. Copy this whole line and paste it below the other "device"-lines. Name the device "joy4". Then your new line should look like this:
config_lines[192]: "device joy4 `di8.'{216BC880-07D0-11E2-8001-444553540000}|{A02F12BD-0000-0000-0000-504944564944}'`"
Because this line is new it needs a number as well in the square brackets next to "config_lines" (192 here). To find out what number to use, scroll all the way to see which number is used on the last line and add 1 to it (191 as last line + 1 = 192).

Now we have two identical lines so we need to change the first one to not be an active controller (the line you copied earlier). To do that, remove the part between ` and ` to have it result in this line:
config_lines[4]: "device joy3 ``"

Note: your joystick name is now "joy4". The name of the axes did not change.

You can (probably) not bind anything to your joystick in the game because it is not listed among the controllers. You can however bind things in controls.sii.
We will now bind a button for "Shifter Toggle: 1". This toggles the range of the shifter from gear 1-6 and 7-12. Our H-shifter joystick will have the usual 6 positions referring to 6 individual gears.
Find the following line:
config_lines[167]: "mix gearsel1tgl ``"
Between ` and ` you can specifiy a key or button to bind to the action. The syntax is:
`[controller name].[button]?0`
So, if you want to bind the shifter toggle to button 1 on your joystick, you'll do:
config_lines[167]: "mix gearsel1tgl `joy4.b1?0`"
or, if you want to bind it to key g:
config_lines[167]: "mix gearsel1tgl `keyboard.g?0`"

At any point from now on you can go back into the game to return your active controllers to those you were using before. If you go into the options screen now there should be only two controllers active as we just moved the joystick controller to a new device entry. The joystick is not listed in-game now but that is okay.
--------------------------------------------------------

5. Return your steering and throttle bindings to what you used before this guide

Go back into the controller options screen and bind your steering and throttle back to that what you were using before.

5.1 If you are not using more than 3 controllers:
--------------------------------------------------------
You will want to bind a button or key for "Shifter Toggle: 1". This toggles the range of the shifter from gear 1-6 and 7-12. Our H-shifter joystick will have the usual 6 positions referring to 6 individual gears. Any button on the joystick is not a bad choice for this.
--------------------------------------------------------

5.2 Bind the clutch if you want to use a button and therefore didn't bind it in the game:
--------------------------------------------------------
Exit the game again and go back to your controls.sii (don't forget to refresh it first).
The clutch is necessary to use the gearbox with an H-shifter. I myself use the spacebar for this as I don't have an analog button available for this (using gamepad + joystick).
Find the line with "dclutch" in it. This action activates the clutch.
config_lines[128]: "mix dclutch ``"
Now bind a button which you want to use for the clutch. The syntax is:
`[controller name].[button]?0`
So, if you want to bind the clutch to the spacebar, do this:
config_lines[128]: "mix dclutch `keyboard.space?0`"
Then modify the line below it (called "clutch") to this:
config_lines[129]: "mix clutch `dclutch`"
--------------------------------------------------------

6. Specifiy positions of the joystick that correspond to the gears
Exit the game, refresh controls.sii and find the "mix"-lines where the gears are assigned. They look like this:
config_lines[171]: "mix gear1 ``"
The numbering here is a bit deceiving. gear1 is the reverse gear, and gear2 till gear7 are gears 1-6. gear8 till gear16 won't be used.

The gears are split into two groups. 1-6 and 7-12 (reverse will be dealt with in a moment). The layout is standard, meaning 1st is top-left, 2nd is bottom-left, 4th is bottom-middle, 5th is top right etc. This pattern stays the same for gears 7-12 which are available when "Shifter Toggle: 1" is pressed once. Press it again to go back to 1-6.

6.1 If you use a joystick that centers itself when you release it:
--------------------------------------------------------
The mechanics of the joystick code are set up in such a way that when you pick a gear with the joystick it will stay in that gear -- even when you release it -- and changes gear when an other gear is selected. This makes it friendly to joysticks that center themselves automatically. The only inability is that you can't switch straight from reverse to 6th gear, but I don't see any situation where this would be a bad thing.

Replace the lines gear1 till gear7 with the following:

config_lines[171]: "mix gear1 `(gear1 & !gear2 & !gear3 & !gear4 & !gear5 & !gear6 & !gear7 & !gearsel1tgl & !joy2.b2?0) | (joy2.b3?0 & gte(normalize(joy2.x,0),0.6) & gte(normalize(joy2.y,0),0.5))`"
config_lines[172]: "mix gear2 `(gear2 & !gear1 & !gear3 & !gear4 & !gear5 & !gear6 & !gear7 & !gearsel1tgl & !joy2.b2?0) | (gte(normalize(abs(joy2.x),0),0.6) & gte(normalize(abs(joy2.y),0),0.5) & !sign(joy2.x) & !sign(joy2.y))`"
config_lines[173]: "mix gear3 `(gear3 & !gear1 & !gear2 & !gear4 & !gear5 & !gear6 & !gear7 & !gearsel1tgl & !joy2.b2?0) | (gte(normalize(abs(joy2.x),0),0.6) & gte(normalize(joy2.y,0),0.5) & !sign(joy2.x))`"
config_lines[174]: "mix gear4 `(gear4 & !gear1 & !gear2 & !gear3 & !gear5 & !gear6 & !gear7 & !gearsel1tgl & !joy2.b2?0) | (gte(0.1,normalize(abs(joy2.x),0)) & gte(normalize(abs(joy2.y),0),0.9) & !sign(joy2.y))`"
config_lines[175]: "mix gear5 `(gear5 & !gear1 & !gear2 & !gear3 & !gear4 & !gear6 & !gear7 & !gearsel1tgl & !joy2.b2?0) | (gte(0.1,normalize(abs(joy2.x),0)) & gte(normalize(joy2.y,0),0.9))`"
config_lines[176]: "mix gear6 `(gear6 & !gear1 & !gear2 & !gear3 & !gear4 & !gear5 & !gear7 & !gearsel1tgl & !joy2.b2?0) | (gte(normalize(joy2.x,0),0.6) & gte(normalize(abs(joy2.y),0),0.5) & !sign(joy2.y))`"
config_lines[177]: "mix gear7 `(gear7 & !gear1 & !gear2 & !gear3 & !gear4 & !gear5 & !gear6 & !gearsel1tgl & !joy2.b2?0) | (!gear1 & gte(normalize(joy2.x,0),0.6) & gte(normalize(joy2.y,0),0.5))`"


Explanation of the code if interested:
A gear will activate when the conditions on the line are true and it will de-activate when they are false.
Using this, the first half of each line (the bracketed part before |) tells the game to re-engage the gear if this gear is currently selected (to avoid it snapping to neutral). If an other gear is active it will not re-engage, these checks were necessary because of the order the game evaluates the conditions. Checked also is whether the shifter toggle (gearsel1tgl) was pressed and if the neutral button was pressed. These will both set the gearbox to neutral.
The second half of each line specifies which position the joystick must be in to return true. For example for 1st gear it checks if the x-direction is more or equal than 60% of the way to the left from the middle and if the y-direction is more or equal to 50% of the way to the top from the middle. These values (0.6 and 0.5 respectively) can be tweaked to fine-tune the gear selection on the joystick.
For more information on the specifics, see the official site or this post.


The first red part on each line ("joy2.b2") corresponds to the button that puts the truck in neutral. Change the name of the joystick to the one you noted earlier in section 4. "b2" equates to button 2 on my joystick. Pick anything you like for this, keyboard keys work too, for example:
...& !gear7 & !gearsel1tgl & !keyboard.k?0) |... (part of each line)
will let you put it in neutral with "k". Remember to repeat this for all 7 lines.

Now, let's make the truck go backwards so you can hit walls/vehicles/people again!
Because all 6 gears (6 positions on the joystick) are normal gears, I chose to put the gearbox in reverse when the position is in 6th gear (lower right) and a button is held down. You can see that on the line with gear1 (reverse) this button is "joy2.b3" (displayed in red). Go ahead and change this button to your liking. For example if you want to hold "u" to reverse:
...| (keyboard.u?0 & gte(normalize(joy2.x,0),0.6) &... (part of line)
To be clear, you put the truck in reverse by engaging the clutch, then --while holding the reverse button-- move the joystick to position 6. You can let go of the reverse button when it is in gear.

Everywhere it says "joy2.x" or "joy2.y" you must change these names to your joystick name and axis names (from section 4). For example, if your joystick is named "joy4" and your axes are named "rx" and "ry", the line for gear3 will be:
config_lines[173]: "mix gear3 `(gear3 & !gear1 & !gear2 & !gear4 & !gear5 & !gear6 & !gear7 & !gearsel1tgl & !joy4.b2?0) | (gte(normalize(abs(joy4.rx),0),0.6) & gte(normalize(joy4.ry,0),0.5) & !sign(joy4.rx))`"

I chose to put the gearbox in neutral when pressing the button that switches between high and low range because of preference. If you do not want this, remove the blue parts.
--------------------------------------------------------

6.2 If you use a joystick that doesn't center itself when you release it (the spring removed)
--------------------------------------------------------
This setting will keep the truck in gear as long as the joystick stays in the correct position. When it is moved to the middle, neutral will be set.

Replace the lines gear1 till gear7 with the following:

config_lines[171]: "mix gear1 `(gear1 & !gear2 & !gear3 & !gear4 & !gear5 & !gear6 & !gear7) | (joy2.b3?0 & gte(normalize(joy2.x,0),0.6) & gte(normalize(joy2.y,0),0.5))`"
config_lines[172]: "mix gear2 `(gte(normalize(abs(joy2.x),0),0.6) & gte(normalize(abs(joy2.y),0),0.5) & !sign(joy2.x) & !sign(joy2.y))`"
config_lines[173]: "mix gear3 `(gte(normalize(abs(joy2.x),0),0.6) & gte(normalize(joy2.y,0),0.5) & !sign(joy2.x))`"
config_lines[174]: "mix gear4 `(gte(0.1,normalize(abs(joy2.x),0)) & gte(normalize(abs(joy2.y),0),0.9) & !sign(joy2.y))`"
config_lines[175]: "mix gear5 `(gte(0.1,normalize(abs(joy2.x),0)) & gte(normalize(joy2.y,0),0.9))`"
config_lines[176]: "mix gear6 `(gte(normalize(joy2.x,0),0.6) & gte(normalize(abs(joy2.y),0),0.5) & !sign(joy2.y))`"
config_lines[177]: "mix gear7 `(!gear1 & gte(normalize(joy2.x,0),0.6) & gte(normalize(joy2.y,0),0.5))`"


Now, let's make the truck go backwards so you can hit walls/vehicles/people again!
Because all 6 gears (6 positions on the joystick) are normal gears, I chose to put the gearbox in reverse when the position is in 6th gear (lower right) and a button is held down. You can see that on the line with gear1 (reverse) this button is "joy2.b3" (displayed in red). Go ahead and change this button to your liking. For example if you want to hold "u" to reverse:
(keyboard.u?0 & gte(normalize(joy2.x,0),0.6) &... (part of line)
To be clear, you put the truck in reverse by engaging the clutch, then --while holding the reverse button-- move the joystick to position 6. You can let go of the reverse button when it is in gear.

Everywhere it says "joy2.x" or "joy2.y" you must change these names to your joystick name and axis names (from section 4). For example, if your joystick is named "joy4" and your axes are named "rx" and "ry", the line for gear3 will be:
config_lines[173]: "mix gear3 `(gte(normalize(abs(joy4.rx),0),0.6) & gte(normalize(joy4.ry,0),0.5) & !sign(joy4.rx))`"
--------------------------------------------------------

There you have it. If you followed everything closely you should have a working H-shifter now!
A check worth doing is to go in the controller options and see if the gear selection all read "Complex". If they don't, something went wrong saving the file or you're editing the wrong profile. Also check your bindings to see if your steering and acceleration/braking still work.
Note: if you bound the clutch to a button (using the text editor) then you will not see the clutch set in the game options but it will still work. Likewise for buttons that have been set for a fourth controller using the text editor.

(Likely) Asked Questions
Q: How do I find out what (for example) my joystick's left button is called?
A: It's quite simple. Go into the controller options (make sure the device that belongs to this button is set to active in game) and temporarily bind it to something like "Horn". Then go into controls.sii and find your corresponding binding with the name of the button displayed. "Horn" is called the same in controls.sii, so the line you're searching for can look like this:
config_lines[134]: "mix horn `joy3.b8?0`"
Now, the part in red is: [controller name].[button name]

Q: What does this "?0" mean behind every button?
A: This is a default value the game uses in case something goes wrong. It means that when the button can't be found, it will make the value 0 instead. So, if you accidentally bind a button called "yojstick.b2?0" or "kweyboord.q?0" it will use the value 0 everywhere the button is used. You can change the default value, but I like to assume nothing should go wrong :) (and keeping it at 0 can't hurt).

Thanks for reading! I hope you'll enjoy the realistic shifting :)

If you have questions, feel free to post them here or message me, either in English or Dutch.
Laatst gewijzigd door Noodleguitar op ma 19 nov 2012, 23:55, 4 keer totaal gewijzigd.
Trucking career: Hard Truck 2 --- Hard Truck: 18 Wheels of Steel --- 18 WoS: Across America --- 18 WoS: American Long Haul --- Euro Truck Simulator --- Euro Truck Simulator 2
Gebruikersavatar
ETS Rijder
Ere-Lid
Ere-Lid
Berichten: 3218
Lid geworden op: ma 15 jun 2009, 08:26
Locatie: Thuis
Contacteer:

Re: [Guide] Use any joystick as H-shifter (STDS)

Bericht door ETS Rijder »

Thanks for this discription/manual!
Afbeelding Afbeelding
Heb je een vraag? Schroom niet om (ons) te vragen.
Gebruikersavatar
Noodleguitar
Lid
Lid
Berichten: 82
Lid geworden op: di 25 sep 2012, 23:18
Locatie: Groningen

Re: [Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door Noodleguitar »

De guide is ge-update voor ETS 2. Was niet veel werk want dit is bijna hetzelfde als in STDS :P
Trucking career: Hard Truck 2 --- Hard Truck: 18 Wheels of Steel --- 18 WoS: Across America --- 18 WoS: American Long Haul --- Euro Truck Simulator --- Euro Truck Simulator 2
Gebruikersavatar
ETS Rijder
Ere-Lid
Ere-Lid
Berichten: 3218
Lid geworden op: ma 15 jun 2009, 08:26
Locatie: Thuis
Contacteer:

Re: [Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door ETS Rijder »

Bedankt hiervoor!
Afbeelding Afbeelding
Heb je een vraag? Schroom niet om (ons) te vragen.
sieder
Lid
Lid
Berichten: 231
Lid geworden op: vr 02 okt 2009, 18:28
Locatie: Makkum (friesland)

Re: [Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door sieder »

bedankt goeie manual
toothpaste
Lid
Lid
Berichten: 48
Lid geworden op: wo 15 jul 2009, 20:07

Re: [Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door toothpaste »

nice

effe wennen als je automaat gewend ben maar wel gaaf
Never share a foxhole with anyone braver than yourself.
ADDER
Lid
Lid
Berichten: 1
Lid geworden op: zo 18 nov 2012, 11:07

Re: [Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door ADDER »

Sorry i have a question .
in 5.2 Bind the clutch if you want to use a button and therefore didn't bind it in the game: i have a problem .
how to move on?. I set the clutch on the space, but when i move the engine is shutdown.
Gebruikersavatar
Noodleguitar
Lid
Lid
Berichten: 82
Lid geworden op: di 25 sep 2012, 23:18
Locatie: Groningen

Re: [Guide] Use any joystick as H-shifter (ETS2 / STDS)

Bericht door Noodleguitar »

So you set "keyboard.space?0" in the controls.sii file?
Then in game, you should put the truck in 1st gear and press down on the throttle so that you get enough RPM before you release the clutch, otherwise it might stall like you experience.

I haven't tested using a digital clutch in ETS2, but it did work in Scania TDS. If you still can't get the truck moving (with trailer) then I'll test it in ETS2.
Trucking career: Hard Truck 2 --- Hard Truck: 18 Wheels of Steel --- 18 WoS: Across America --- 18 WoS: American Long Haul --- Euro Truck Simulator --- Euro Truck Simulator 2
Plaats reactie

Terug naar “Algemeen”