Manipulate Joystick Data

Talk about anything concerning the source code.
AND_1
Posts: 14
Joined: Wed May 31, 2017 8:20 am

Manipulate Joystick Data

Post by AND_1 »

Hello Guys,

I have a question about the Sourcecode, because it is a huge amount of Source Code in GIMX ;)
I want to manipulate the values of my G27 Wheel. So I need to get the values before they are going to be send over the USB-Adapter.
But I am quite clueless where to start in the Sourcecode. In which C-File the Read and Write Commands have taken place?
Which is the Source of the Events for reading in the Joystick/Wheel? Is it the /dev/input/event* path? So is it possible to implement a function helping me to get the Event-Data for manipulating them before they were send over the USB-Adapter and write them back?

Thanks for any advice. Don't hesitate to be part of this project ;)

Cheers AND_1 :D
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Manipulate Joystick Data

Post by Matlo »

Hi,
Please explain the purpose so that I can give you an appropriate answer.
GIMX creator
AND_1
Posts: 14
Joined: Wed May 31, 2017 8:20 am

Re: Manipulate Joystick Data

Post by AND_1 »

Hi Matlo,

I am using a G27 Wheel (Original Gaming Wheel) which is stucked in a Raspberry Pi3 USB Port. Then I connect my laptop with the Raspberry using your USB-Adapter. GIMX is running on the PI. So I suppose that the Signal of my G27 is going through the Raspberry into my laptop. Because I was able to play Project CARS with it. Now I want to catch the data coming from the G27 wheel and modify them, before they were send to your USB-Adapter and finally to my laptop. So shortly, I want to change the axes position form the wheel, or that the brake is less sensitive and so on.
I need this for a project on my university ;)

I hope that it is clear now. If not you can tell me what you need to know.
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Manipulate Joystick Data

Post by Matlo »

No need to modify the source code, you can just modify the gimx configuration file.
GIMX creator
AND_1
Posts: 14
Joined: Wed May 31, 2017 8:20 am

Re: Manipulate Joystick Data

Post by AND_1 »

Thanks for your fast replies.
But I think there is a missunderstanding. I want to catch the data while GIMX is running and modify them before they were send over the USB-Adapter. So I want to catch the data from the G27, modify them and then send the new data using your USB-Adapter. So that there are my modified data instead of the data from the real G27. So I suppose I need to modify the source of the events for Joysticks am I right? And I am not sure where to find them and how to write them back.

Hopefully you understand what I am trying to do. Sorry if I didn't express myself good enough.

Thank you for your time ;)

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

Re: Manipulate Joystick Data

Post by Matlo »

GIMX does this already.
You are probably using the LogitechG27_G29.xml configuration. On the RPi, open gimx-config, load the configuration, and modify button mappings, or axis sensitivities. Save the configuration, restart GIMX. Done!
GIMX creator
AND_1
Posts: 14
Joined: Wed May 31, 2017 8:20 am

Re: Manipulate Joystick Data

Post by AND_1 »

Hi Matlo,

thanks for replying with that frequency. :) But I want to do something different. I could send you a png-file of my project.
I want to catch the data while GIMX is running and send them with CAN to another device, where these datas will be modified.
So I need the data coming from the G27 wheel, preferably in a format I can understand and read(String, char or int, etc.).
Then I want to implement a code which send this data via Can and receives it afterweards.
After that, GIMX can go on with the modified data and transmit it over the DIY-USB-Cable.
But my question is only focused on the Sourcecode. And at this point I need your help (response). The stuff before was to explain you what I want to do.
In which files are the functions which getting the Data from the input device(wheel) in a readable form and where are these data written to the DIY-USB-Adapter.
I only need the functions where the data are read from the input device and written to the DIY-Adapter.
I think the source of your values might be the Joystick package? (Linux Joystick-Api)?

Hopefully you understand what I want to say :)

Thanks for reply ;)
User avatar
Matlo
Posts: 5768
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Manipulate Joystick Data

Post by Matlo »

Something you may be not aware of is that I/Os (read and write operations) are asynchronous. Once the init is finished and until the process exits, everything is non-blocking. Adding blocking I/Os somewhere will most probably break things and at least impact performances.

Unless you know how to make your I/Os asynchronous, you should consider handling your task externally. Create a simple process that reads inputs from the /dev/input/joystickX device, and sends the controls to GIMX using the network API. In the master branch, the code handling the joystick is located in shared/gasync/src/input/linux/js.c.

More about the network API here: https://gimx.fr/wiki/index.php?title=Network_API
GIMX creator
AND_1
Posts: 14
Joined: Wed May 31, 2017 8:20 am

Re: Manipulate Joystick Data

Post by AND_1 »

Hi Matlo,

Thanks for your answer. So I did a programm to Read Joystick data from /dev/input/js* and print it to console. Now I am wondering how to use the Network API. I don't really understand how it works and what I need to do. The IP:port arguement is what I don't get. Which adresses are meant? Does it send the data internally to the port? Can I send my modified data from my c-File to GIMX repeatedly? I am clueless how to make the instructions send data to GIMX and how to get it together with my c-File.

I am quite confused :?

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

Re: Manipulate Joystick Data

Post by Matlo »

Start GIMX with network input, and send your reports to the same IP:port.
The byte array must contain a header (type + length) and the axis values.

EDIT: make sure not to send your reports too fast!
GIMX creator
Post Reply