[TUTORIAL] ~ RPi + GIMX + G27 + PS4 + DriveClub = WORKING

Need help? Ask here and someone will help
jhonny
Posts: 10
Joined: Fri Oct 10, 2014 1:54 pm

[TUTORIAL] ~ RPi + GIMX + G27 + PS4 + DriveClub = WORKING

Post by jhonny » Sat Oct 11, 2014 3:28 am

Gents,

Firstly, thank you for this amazing project, its a lot of fun putting this together.

My setup is:
- Raspberry Pi Model B+ (4 usb ports) (because who wants to run a dedicated pc to their steering rig right ?)
running: Linux raspberrypi 3.12.29+ #714 PREEMPT Wed Oct 1 23:11:38 BST 2014 armv6l GNU/Linux
- Teensy 2.0
- Orico bluetooth USB
- G27
- PS4 + DriveClub
- DualShock 4 controller
- GIMX 3.4

So after installing Raspbian (wheezy) and installing all the necessary stack: GIMX, bluez, etc ... I started to configure the inputs using: gimx-configure

Selected:
- DualShock 4 profile
- Assigned steering axis (which has been detected) to x axis
- Then tried to assign the accelerator pedal to R2 and brake to L2.
Problem is the wheel at that point had both pedals on the same axis

So then i installed LTWheelConf and made the wheel go into native mode.
The brake and accelerator pedals are now on separate axis (2 and 3)

So i can map them successfully to L2 and R2 using gimx-configure.

However, when i play the game what happens is:
- If i press the accelerator up to half way the car drives forward.
- Once i press the accelerator past the half way point the acceleration stops (its as if i stop pressing the peal).
- Same thing happens when i press the brake pedal.

Now one other weird bug is that once i press the brake pedal and let it go, and then i press the accelerator pedal and let it go, the car will sit in 1 spot and do doughnuts. So its as if the accelerator and brake are pressed in at the same time ?

jstest shows the values for these axis to be -32767 when foot off pedal.
0 when pressed half way
32767 when pressed all the way

So it seems to me based on the above that gimx is using -32767 (as "pressed down value") and 0 as neutral.

Steering works without issues, although there seems to be a bit of a dead zone in the middle. I wonder if that can be tweaked to be smaller ?

Can anyone help out with tweaking the above ?
Last edited by jhonny on Tue Oct 21, 2014 3:59 pm, edited 3 times in total.

jhonny
Posts: 10
Joined: Fri Oct 10, 2014 1:54 pm

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by jhonny » Sat Oct 11, 2014 12:49 pm

Ok so i managed to get a little further:

In Raspbian x desktop there's a joystick tool.
When i go to configure the joystick i can calibrate the axis.
Now I don't know what the values are supposed to be and they seem to be broken in the tool, but anyway, when i set [x] inverted mode on for Axis 2 and 3 (accel and brake) the car seems to respond correctly, as in it brake and accelerates when i press the correct pedal, HOWEVER ....

It only brakes and accelerates at half the speed.

So when i press the accelerate pedal anything up to half way, nothing happens and then from half way onwards the car starts to speed up, slowly.
Same applies for the brake pedal.

So by default in the joystick config utility (after putting the wheel into native mode with ltwheelconf) i can see:
Axis 1 (clutch)
Axis 3 (brake)
Axis 2 (accel.)
they all have a value of 32,767
as you press then they decline in value all the way to -32,767

So if i go to "Calibration" and set "Invert" on axis 1,2,3 and go back 1 screen i can see now:

Pedals react from -32,767 to 32,767.
I believe the game starts reacting from 0 to 32,767

Any way to fix that either in this joystick config tool or gimx itself ?

It seems the answer would be to have the pedals go from 0 to 65534 ?

The default jscal values are:

jscal -p /dev/input/js0
jscal -s 6,1,0,8191,8191,65542,65542,1,0,127,127,4227201,4227201,1,0,127,127,4227201,4227201,1,0,127,127,4227201,4227201,1,0,0,0,536854528,536854528,1,0,0,0,536854528,536854528 /dev/input/js0

- change them to (inverted):
jscal -p /dev/input/js0
jscal -s 6,1,0,8191,8191,65542,65542,1,0,127,127,-4227201,-4227201,1,0,127,127,-4227201,-4227201,1,0,127,127,-4227201,-4227201,1,0,0,0,536854528,536854528,1,0,0,0,536854528,536854528 /dev/input/js0

User avatar
Matlo
Posts: 4338
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by Matlo » Thu Oct 16, 2014 3:38 pm

jhonny wrote: It only brakes and accelerates at half the speed.
This means you should double the sensitivity.
GIMX creator Donate Shop

jhonny
Posts: 10
Joined: Fri Oct 10, 2014 1:54 pm

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by jhonny » Thu Oct 16, 2014 3:47 pm

Hey Matlo, thank you for your response.

How do i double the sensitivity ? In GIMX gui ?

User avatar
Matlo
Posts: 4338
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by Matlo » Fri Oct 17, 2014 8:28 am

Yes. You probably have a sensitivity of 0.004. Set it to 0.008.
GIMX creator Donate Shop

jhonny
Posts: 10
Joined: Fri Oct 10, 2014 1:54 pm

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by jhonny » Fri Oct 17, 2014 9:18 am

Hey Matlo,

I've double it and it worked like you said, but what i found is that if i use these values and 0.008 sensitivity i get a little dead zone on the pedals:

jscal -s 6,1,0,8191,8191,65542,65542,1,0,127,127,-4227201,-4227201,1,0,200,0,-4227201,0,1,0,160,0,-4227201,0,1,0,0,0,0,0,1,0,0,0,0,0 /dev/input/js1

sensitivity 0.008 for l2 and r2. In jstest the values for the pedals reach from 0 to ~32,000

So I'm just working on tweaking that. Once its done, ill post a full tutorial on how to set this up.
I've already written it up, just tweaking values.

tps
Posts: 29
Joined: Mon Oct 29, 2012 12:36 pm

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by tps » Tue Oct 21, 2014 7:17 am

note that the axis for pedals seem to have 0 set as midway point, meaning that you need to push the pedal halfway to reach the 0 point.
I use the same sensitivity and it works okay for the time being. I need to spend time on tweaking the pedals but so far I have worked on the steering.
anyway, the experience is way better than with the controller: https://drive.google.com/file/d/0B9QsY5 ... ltazQ/view

for an auto-centering wheel I have to reset it before starting GIMX: sudo ltwheelconf --wheel G27 -x
otherwise I use the native mode (more info here http://steamcommunity.com/sharedfiles/f ... =142372419 )

I get some lag when turning the wheel but I'm not sure if/how this can be fixed.
any thoughts?

jhonny
Posts: 10
Joined: Fri Oct 10, 2014 1:54 pm

Re: GIMX + G27 + PS4 + DriveClub = semi working

Post by jhonny » Tue Oct 21, 2014 3:33 pm

Hey tips,

Yes,

These are the magic values you're after:

They tweak the pedals. No more half way throttle
And the steering has no dead zone:

jscal -s 6,1,0,8191,8191,32764,32764,1,0,0,0,0,0,1,0,255,0,-16384,0,1,0,255,0,-16384,0,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js1

jhonny
Posts: 10
Joined: Fri Oct 10, 2014 1:54 pm

Re: GIMX + G27 + PS4 + DriveClub = WORKING :)

Post by jhonny » Tue Oct 21, 2014 3:44 pm

Here's the full tutorial

WHAT DOESN'T WORK:
--------------------------

- force feedback,
- H shifter
- clutch pedal

...maybe soon yeah Matlo ? :)

INGREDIENTS:
-------------------

- Raspberry Pi - Model B+ (512mb ram and 4 usb ports)
- 4Gb microsd card
- Teensy 2.0
- Orico USB adapter BTA-403
- USB powered hub (I'm using noontec USB 3.0)


Make sure you start out with nothing but your Raspberry Pi and USB HUB with keyboard and mouse connected.
Other devices will be connected at the appropriate time.

CONNECTIVITY:
------------------

Image


PREPARE THE TEENSY:
==============

download:
- teensy.dmg (from teensy website)
- EMUPS4PAIRING.7z (from: http://gimx.fr/download/EMUPS4PAIRING.7z)
- my config.xml file (from: https://dl.dropboxusercontent.com/u/88290593/config.xml)

Extract EMUPS4PAIRING.7z file (for teensy 2.0 you only need the file: atmega32u4.hex that is extracted from the 7z archive)

Install teensy.dmg.
Run the Teensy app.
Click File -> Open Hex file
Find the atmega32u4.hex file and click Open
Next click the AUTO green button
Plug in the teensy and press the button on the teensy to activate it.
The Teensy app will now program the board. Once its done, unplug it from your pc and its ready to use.


PREPARE THE RASPBERRY PI:
==================


download:
2014-09-09-wheezy-raspbian.img from:
http://downloads.raspberrypi.org/raspbian_latest

use dd to transfer the image onto a microsd card. from linux/mac os it will be:

Code: Select all

dd if=/Users/root/Downloads/2014-09-09-wheezy-raspbian.img of=/dev/rdisk1 bs=1024
plug the microsd card into the raspberry pi and let it boot.

It should boot to the "Raspberry Pi Software configuration Tool"

Select:
1) Expand filesystem.
You should get a confirmation on the screen that the "Root partition has been resized".

Back in the main menu now select:
2) Change user password.
Set a password for the user: PI
e.g. Passw0rd

Tab to "Finish" and press Enter.
When you get to "Would you like to reboot now?" select: Yes

Once the raspberry pi reboots, login as user: pi
with password: Passw0rd

then complete the following tasks:

A) set root password
----------------------------

Code: Select all

sudo vi /etc/passwd
change line
root:x:0:0:root:/root:/bin/bash
to

Code: Select all

root::0:0:root:/root:/bin/bash

Code: Select all

sudo shutdown -r 0
once the Pi reboots, login as root with no password.

then type:
passwd - to set a new password: Passw0rd for user root

B) set US keyboard
--------------------------

dpkg-reconfigure keyboard-configuration
Select: Generic 104-key PC (or your keyboard if it is in the list)
then Other
then English US
English US again
The default for the keyboard layout
No compose key
At the "by default the combination Control+Alt+Backspace does nothing ..." screen select Yes

NOTE: For the following you will need your pi to be connected to the home network and for it to have access to the internet.
The Pi will pick up a DHCP address from your home network automatically.

C) update the raspberry pi firmware
-----------------------------------------------

from the prompt run:

Code: Select all

rpi-update
D) install GIMX
---------------------

from the prompt run:

Code: Select all

apt-get install gdebi
wget http://gimx.fr/download/gimx-raspbian.html -O gimx.deb
gdebi gimx.deb
E) Disable triggerhappy service
------------------------------------------

from the prompt run:

Code: Select all

service triggerhappy stop
update-rc.d triggerhappy disable
F) Install bluetooth package
-------------------------------------

Code: Select all

apt-get install bluez
service bluetooth stop
G) Install LTWheelConf
-------------------------------

Code: Select all

apt-get install libusb-1.0-0-dev git jstest-gtk joystick
cd /
git clone https://github.com/thk/LTWheelConf.git
cd LTWheelConf
make
cp ltwheelconf /usr/local/bin/
H) update all software
-----------------------------

Code: Select all

apt-get update
apt-get upgrade
apt-get install
I) restart the raspberry pi
---------------------------------

Code: Select all

shutdown -r 0

SETTING UP AND RUNNING THE WHEEL
==================================

1) connect and configure the G27
---------------------------------------------

connect the G27 wheel to the Pi
run:

Code: Select all

ltwheelconf --list
your wheel should appear as detected
run the following to put the G27 into "native" mode:

Code: Select all

ltwheelconf -n -w G27
2) copy the config.xml file you downloaded from dropbox
----------------------------------

Code: Select all

mkdir /root/.gimx
mkdir /root/.gimx/config
copy the config.xml file to /root/.gimx/config/


3) get the gimx-ps4-helper script
-------------------------------------------

Code: Select all

cd /LTWheelConf
wget https://raw.github.com/matlo/GIMX-tools/master/PS4/gimx-ps4-helper.sh -O gimx-ps4-helper.sh
chmod +x gimx-ps4-helper.sh
4) setting G27 parameters
-----------------------------------

Code: Select all

jscal -p /dev/input/js0
(the default parameters will be):

Code: Select all

jscal -s 6,1,0,8191,8191,65544,65544,1,0,127,127,4227330,4227330,1,0,127,127,4227330,4227330,1,0,127,127,4227330,4227330,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js1
you can also use LTWheelConf to set the "return to center" force and resistance.

You need to put the G27 in native mode:

Code: Select all

./ltwheelconf -n -w G27
Optionally if you want to tinker around with wheel resistance use either:

Code: Select all

./ltwheelconf -n -r 180 -w G27 -s 0 -a 255
(for no resistance up to 180 degrees) <- no centering but easiest to control
or

Code: Select all

./ltwheelconf -n -r 180 -w G27 -s 7 -a 255
(for max resistance up to and past 180 degrees) <- best centering but hardest to turn

NOTE: The wheel must be in native mode before you run the below jscal command.

The parameters are optimal at:

Code: Select all

jscal -s 6,1,0,8191,8191,32764,32764,1,0,0,0,0,0,1,0,255,0,-16384,0,1,0,255,0,-16384,0,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js1

5) Duping your controller
---------------------------------

Turn on your PS4 with the controller that you want to dupe as the steering wheel.
Login to your profile
Press and hold the PS button on the DS4 / Adujust devices / Turn off device / Dualshock 4
The controller will now be off.

on your raspberry pi run:

Code: Select all

cd /LTWheelConf
./gimx-ps4-helper.sh
Unplug the bluetooth dongle, then press enter.
Press enter (your bluetooth dongle should not be plugged in at this stage)
Then....
Plug the bluetooth dongle.
Then this will appear on your screen:
The bluetooth dongle address is 00:AA:BB:CC:DD:EE.
The bluetooth hci number is 0.
Plug the DS4 with a USB cable.
Plug the DS4 you just turned off with a USB cable to the rPi.
The DS4 address is AA:BB:CC:DD:EE:FF.
Unplug the DS4.
Plug the teensy.
Plug the teensy into the rPi, after a few seconds:
Unplug the teensy.
Plug the teensy to the PS4, and wait a few seconds.
Then plug the teensy back to the PC
When it says plug the teensy back to the PC you plug it back into the rPi.

The PS4 address is AA:BB:CC:DD:EE:FF.
Everything was successful: setting dongle link keys.
To run gimx, type:

Code: Select all

gimx -t DS4 -c config.xml -h 0 -b AA:BB:CC:DD:EE:FF

Now run the command:

Code: Select all

service bluetooth stop
gimx -t DS4 -c config.xml -h 0 -b AA:BB:CC:DD:EE:FF

Code: Select all

option -t with value `DS4'
option -c with value `config.xml'
option -h with value `0'
option -b with value `B0:05:94:1A:E4:0E'
Unknown Management opcode 4 (index 0)
using default refresh period: 10.00ms
now press the PS button on the DS4 controller that is off.

A light blue light (not usual dark blue) will flash for a while and once its solid, your G27 is now your primary controller.

Enjoy

User avatar
Matlo
Posts: 4338
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: [TUTORIAL] ~ RPi + GIMX + G27 + PS4 + DriveClub = WORKIN

Post by Matlo » Tue Oct 21, 2014 4:15 pm

Excellent :)
jhonny wrote:WHAT DOESN'T WORK:
--------------------------
- force feedback,
- H shifter
- clutch pedal

...maybe soon yeah Matlo ? :)
Sadly it's not possible with a DS4 emulation. Emulating a licenced PS4 wheel would probably allow to have all these features.
GIMX creator Donate Shop

Locked