Difference between revisions of "Network API"

From GIMX
Jump to: navigation, search
(Get controller type)
 

(28 intermediate revisions by the same user not shown)

Line 2: Line 2:
 
See the "--src IP:port" argument on the [[Command_line#General_gimx_options|Command line page]] to learn how to start such a GIMX instance.
 
See the "--src IP:port" argument on the [[Command_line#General_gimx_options|Command line page]] to learn how to start such a GIMX instance.
  
=Get controller type=
+
=Protocol starting from version 7.1=
  
It's possible to send a packet to get the controller type from the remote GIMX.
+
One problem with the earlier protocol was that backward compatibility was broken each time a new axis was added to the controller map.<br />
 +
The new protocol allows to send any number of axis values.
 +
 
 +
==Get controller type==
 +
 
 +
Use this request for getting the controller type of the remote GIMX instance.
  
 
{| class="wikitable" style="text-align: center;"
 
{| class="wikitable" style="text-align: center;"
Line 10: Line 15:
 
| byte || value
 
| byte || value
 
|-
 
|-
| 0 || 0x11
+
|
 +
|-
 +
| 0 || 0x00
 
|-
 
|-
 
| 1 || 0x00
 
| 1 || 0x00
Line 19: Line 26:
 
| byte || value
 
| byte || value
 
|-
 
|-
| 0 || 0x11
+
|
 +
|-
 +
| 0 || 0x00
 
|-
 
|-
 
| 1 || 0x01
 
| 1 || 0x01
 
|-
 
|-
| 2 || type
+
| 2 || value
 
|}
 
|}
  
Line 29: Line 38:
 
|value || type
 
|value || type
 
|-
 
|-
| 0 || JOYSTICK
+
|
 
|-
 
|-
| 1 || 360 PAD
+
| 0x00 || JOYSTICK
 
|-
 
|-
| 2 || SIXAXIS
+
| 0x01 || 360 PAD
 
|-
 
|-
| 5 || DS4
+
| 0x02 || SIXAXIS
 
|-
 
|-
| 7 || T300RS PS4
+
| 0x05 || DS4
 
|-
 
|-
| 8 || G27 PS3
+
| 0x06 || Xbox One PAD
 +
|-
 +
| 0x07 || T300RS PS4
 +
|-
 +
| 0x08 || G27 PS3
 +
|-
 +
| 0x09 || G29 PS4
 +
|-
 +
| 0x0A || DF PS2 (Driving Force)
 +
|-
 +
| 0x0B || DFP PS2 (Driving Force Pro)
 +
|-
 +
| 0x0C || GTF PS2 (GT Force)
 
|}
 
|}
  
=Send report=
+
==Send report==
 
 
All axes are signed integers.
 
  
 +
Use this request to update the axes of the remote GIMX instance.<br >
 
The [[Controller_Maps|Controller Maps]] page describes the axes and the value ranges corresponding to each controller type.
 
The [[Controller_Maps|Controller Maps]] page describes the axes and the value ranges corresponding to each controller type.
  
 
{| class="wikitable" style="text-align: center;"
 
{| class="wikitable" style="text-align: center;"
 
|+Report
 
|+Report
| byte 0 || 0xff
+
| byte || value
 
|-
 
|-
| byte 1 || 0x7c = 124
+
|
 
|-
 
|-
| byte 2-5 || axis 0
+
| 0 || 0x01
 
|-
 
|-
| byte 6-9 || axis 1
+
| 1 || number of axes to follow
 
|-
 
|-
| byte 10-13 || axis 2
+
| 2 ||
 +
{| class="wikitable" style="text-align: center;"
 +
|bit 7
 +
|bit 6
 +
|bit 5
 +
|bit 4
 +
|bit 3
 +
|bit 2
 +
|bit 1
 +
|bit 0
 
|-
 
|-
| byte 14-17 || axis 3
+
|0 for rel_axis<br />
 +
1 for abs_axis
 +
|colspan="7"|axis index<br />X for abs_axis_X or rel_axis_X
 +
|}
 
|-
 
|-
| byte 18-21 || axis 4
+
| 3-6 || axis value (network byte order, see below)
 
|-
 
|-
| byte 22-25 || axis 5
+
| ... || repeat 2 and 3-6 for each axis to update
 
|-
 
|-
| byte 26-29 || axis 6
+
|}
 +
 
 +
To compute the axis value, take the int value stored as two's complement, and store it using the network byte order, which is big endian.<br />
 +
Examples:
 +
* -32767 = 0xffff8001 => value = 0xff, 0xff, 0x80, 0x01
 +
* -127  = 0xffffff81 => value = 0xff, 0xff, 0xff, 0x81
 +
* -1    = 0xffffffff => value = 0xff, 0xff, 0xff, 0xff
 +
*  0    = 0x00000000 => value = 0x00, 0x00, 0x00, 0x00
 +
*  1    = 0x00000001 => value = 0x00, 0x00, 0x00, 0x01
 +
*  127  = 0x0000007f => value = 0x00, 0x00, 0x00, 0x7f
 +
*  32767 = 0x00007fff => value = 0x00, 0x00, 0x7f, 0xff
 +
 
 +
=Python source code example=
 +
 
 +
A python source code example is available here: https://github.com/matlo/gimx-network-client
 +
 
 +
=Protocol for versions up to 6.11=
 +
 
 +
<div class="mw-collapsible mw-collapsed">
 +
 
 +
==Get controller type==
 +
 
 +
It's possible to send a packet to get the controller type from the remote GIMX.
 +
 
 +
{| class="wikitable" style="text-align: center;"
 +
|+Request
 +
| byte || value
 
|-
 
|-
| byte 30-33 || axis 7
+
|
 
|-
 
|-
| byte 34-37 || axis 8
+
| 0 || 0x11
 
|-
 
|-
| byte 38-41 || axis 9
+
| 1 || 0x00
 +
|}
 +
 
 +
{| class="wikitable" style="text-align: center;"
 +
|+Answer
 +
| byte || value
 
|-
 
|-
| byte 42-45 || axis 10
+
|
 
|-
 
|-
| byte 46-49 || axis 11
+
| 0 || 0x11
 
|-
 
|-
| byte 50-53 || axis 12
+
| 1 || 0x01
 
|-
 
|-
| byte 54-57 || axis 13
+
| 2 || value
 +
|}
 +
 
 +
{| class="wikitable" style="text-align: center;"
 +
|value || type
 
|-
 
|-
| byte 58-61 || axis 14
+
|
 
|-
 
|-
| byte 62-65 || axis 15
+
| 0x00 || JOYSTICK
 
|-
 
|-
| byte 66-69 || axis 16
+
| 0x01 || 360 PAD
 
|-
 
|-
| byte 70-73 || axis 17
+
| 0x02 || SIXAXIS
 
|-
 
|-
| byte 74-77 || axis 18
+
| 0x05 || DS4
 
|-
 
|-
| byte 78-81 || axis 19
+
| 0x07 || T300RS PS4
 
|-
 
|-
| byte 82-85 || axis 20
+
| 0x08 || G27 PS3
 
|-
 
|-
| byte 86-89 || axis 21
+
| 0x09 || G29 PS4
 +
|}
 +
 
 +
==Send report==
 +
 
 +
All axes are signed integers.
 +
 
 +
The [[Controller_Maps|Controller Maps]] page describes the axes and the value ranges corresponding to each controller type.
 +
 
 +
{| class="wikitable" style="text-align: center;"
 +
|+Report
 +
| byte || value
 
|-
 
|-
| byte 90-93 || axis 22
+
|
 
|-
 
|-
| byte 94-97 || axis 23
+
| 0 || 0xff
 
|-
 
|-
| byte 98-101 || axis 24
+
| 1 || 0x9C = 156
 
|-
 
|-
| byte 102-105 || axis 25
+
| 2-5 || axis 0
 
|-
 
|-
| byte 106-109 || axis 26
+
| 6-9 || axis 1
 
|-
 
|-
| byte 110-113 || axis 27
+
| ... ||  
 
|-
 
|-
| byte 114-117 || axis 28
+
| 158-161 || axis 39 (changed in GIMX 6.10)
|-
 
| byte 118-121 || axis 29
 
|-
 
| byte 122-125 || axis 30
 
 
|}
 
|}
 +
 +
</div>

Latest revision as of 20:49, 28 August 2019

This page describes how to talk to a GIMX instance that is listening for UDP packets on a specific port.
See the "--src IP:port" argument on the Command line page to learn how to start such a GIMX instance.

Protocol starting from version 7.1

One problem with the earlier protocol was that backward compatibility was broken each time a new axis was added to the controller map.
The new protocol allows to send any number of axis values.

Get controller type

Use this request for getting the controller type of the remote GIMX instance.

Request
byte value
0 0x00
1 0x00
Answer
byte value
0 0x00
1 0x01
2 value
value type
0x00 JOYSTICK
0x01 360 PAD
0x02 SIXAXIS
0x05 DS4
0x06 Xbox One PAD
0x07 T300RS PS4
0x08 G27 PS3
0x09 G29 PS4
0x0A DF PS2 (Driving Force)
0x0B DFP PS2 (Driving Force Pro)
0x0C GTF PS2 (GT Force)

Send report

Use this request to update the axes of the remote GIMX instance.
The Controller Maps page describes the axes and the value ranges corresponding to each controller type.

Report
byte value
0 0x01
1 number of axes to follow
2
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
0 for rel_axis

1 for abs_axis

axis index
X for abs_axis_X or rel_axis_X
3-6 axis value (network byte order, see below)
... repeat 2 and 3-6 for each axis to update

To compute the axis value, take the int value stored as two's complement, and store it using the network byte order, which is big endian.
Examples:

  • -32767 = 0xffff8001 => value = 0xff, 0xff, 0x80, 0x01
  • -127 = 0xffffff81 => value = 0xff, 0xff, 0xff, 0x81
  • -1 = 0xffffffff => value = 0xff, 0xff, 0xff, 0xff
  • 0 = 0x00000000 => value = 0x00, 0x00, 0x00, 0x00
  • 1 = 0x00000001 => value = 0x00, 0x00, 0x00, 0x01
  • 127 = 0x0000007f => value = 0x00, 0x00, 0x00, 0x7f
  • 32767 = 0x00007fff => value = 0x00, 0x00, 0x7f, 0xff

Python source code example

A python source code example is available here: https://github.com/matlo/gimx-network-client

Protocol for versions up to 6.11

Get controller type

It's possible to send a packet to get the controller type from the remote GIMX.

Request
byte value
0 0x11
1 0x00
Answer
byte value
0 0x11
1 0x01
2 value
value type
0x00 JOYSTICK
0x01 360 PAD
0x02 SIXAXIS
0x05 DS4
0x07 T300RS PS4
0x08 G27 PS3
0x09 G29 PS4

Send report

All axes are signed integers.

The Controller Maps page describes the axes and the value ranges corresponding to each controller type.

Report
byte value
0 0xff
1 0x9C = 156
2-5 axis 0
6-9 axis 1
...
158-161 axis 39 (changed in GIMX 6.10)