Difference between revisions of "Command line/en"

From GIMX
Jump to: navigation, search
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 6: Line 6:
 
It's also useful for other stuff like automation.
 
It's also useful for other stuff like automation.
  
==Linux + bluetooth==
+
==Linux + bluetooth + PS3==
  
 
===Set the dongle address===
 
===Set the dongle address===
Line 33: Line 33:
  
 
In a terminal:<br />
 
In a terminal:<br />
  emu ps3_bt_address bt_device_index sixaxis_index
+
  gimx --type Sixaxis --config filename --hci bt_device_index --bdaddr ps3_bt_address
  
* ps3_bt_address
+
* file_name
:This argument is mandatory.
+
:The name of the config file, in the ~/.gimx/config directory (ex : toto.xml).<br />
 +
:This argument is mandatory.<br />
 +
:Use backslashes to escape spaces.
 
* bt_device_index
 
* bt_device_index
 
:The bluetooth device index (ex : 0 for hci0, 1 for hci1, etc).<br />
 
:The bluetooth device index (ex : 0 for hci0, 1 for hci1, etc).<br />
 
:This argument is optional, default device index is 0.
 
:This argument is optional, default device index is 0.
* sixaxis_index
+
* ps3_bt_address
:The sixaxis index (ex : 0 for sixaxis 1, 1 for sixaxis 2, etc).<br />
+
:This argument is mandatory.
:This argument is optional, default sixaxis index is 0.
+
 
 +
==Linux + bluetooth + PS4==
 +
 
 +
===Setup===
 +
 
 +
The setup performs the bluetooth pairing between the PS4 and the dongle, and between the dongle and the DS4.<br />
 +
It has to be run again if the DS4 is reused (i.e. paired again) with the PS4.
  
In another terminal:<br />
+
Download the helper script:
emuclient --config file_name
 
  
* file_name
+
  wget <nowiki>https://raw.github.com/matlo/GIMX-tools/master/PS4/gimx-ps4-helper.sh</nowiki> -O gimx-ps4-helper.sh
:The name of the config file, in the ~/.emuclient/config directory (ex : toto.xml).<br />
+
 
:This argument is mandatory.<br />
+
Make it executable:
:Use backslashes to escape spaces.
+
 
 +
  chmod +x gimx-ps4-helper.sh
 +
 
 +
Run it:
 +
 
 +
  sudo ./gimx-ps4-helper.sh
 +
 
 +
Simply follow the instructions. A successful output should look like this:
 +
 
 +
  $ sudo ./gimx-ps4-setup.sh
 +
  Unplug any Dualshock 4.
 +
  Unplug any teensy.
 +
  Unpug the bluetooth dongle.
 +
  Then press enter.
 +
 
 +
  Plug the bluetooth dongle.
 +
  The bluetooth dongle address is XX:XX:XX:XX:XX:XX.
 +
  The bluetooth hci number is 1.
 +
  Plug the DS4 with a USB cable.
 +
  The DS4 address is YY:YY:YY:YY:YY:YY.
 +
  Unplug the DS4.
 +
  Plug the teensy.
 +
  Unplug the teensy.
 +
  Plug the teensy to the PS4, and wait a few seconds.
 +
  Then plug the teensy back to the PC.
 +
  The PS4 address is ZZ:ZZ:ZZ:ZZ:ZZ:ZZ.
 +
  Everything was successful: setting dongle link keys.
 +
  To run gimx, type:
 +
  gimx -t DS4 -c config.xml -h 1 -b ZZ:ZZ:ZZ:ZZ:ZZ:ZZ
 +
 
 +
===Run GIMX===
 +
 
 +
1. The bluetooth service has to be stopped before starting GIMX (this allows GIMX to get incoming connections):
 +
  sudo service bluetooth stop
 +
You may also have to deactivate the bluetooth service if your system starts it automatically.
 +
 
 +
2. Start GIMX:
 +
  gimx -t DS4 -c <config file> -h <hci number> -b <PS4 bdaddr>
 +
 
 +
<config file> is the name of the config file to use.<br />
 +
<hci number> is the bluetooth hci number, for example 0 if there is only one bluetooth adapter (internal or external). Run 'hciconfig' if you're not sure about this value.<br />
 +
<PS4 bdaddr> is the address of the PS4.<br />
 +
 
 +
3. Start the DS4. It should connect to GIMX, which in turn should connect to the PS4.
  
 
==Linux or Windows + DIY USB adapter or GPP==
 
==Linux or Windows + DIY USB adapter or GPP==
Line 56: Line 106:
 
In a terminal:<br />
 
In a terminal:<br />
  
GIMX 1.10 and later:
+
   gimx --config file_name --port /dev/ttyUSBX
   emuclient --config file_name --port /dev/ttyUSBX
 
 
  or
 
  or
   emuclient -c file_name -p /dev/ttyUSBX
+
   gimx -c file_name -p /dev/ttyUSBX
 
 
<span style="color:#808080">GIMX 0.51 or older:
 
  emuclient --config file_name --serial --port /dev/ttyUSBX --joystick --precision 16 --refresh 4</span>
 
  
<span style="color:#808080">GIMX later than 0.51:
+
gimx options:
  emuclient --config file_name --port /dev/ttyUSBX --type joystick --refresh 4
 
or
 
  emuclient -c file_name -p /dev/ttyUSBX -t joystick -r 4</span>
 
 
 
emuclient options:
 
 
* --config file_name
 
* --config file_name
:The name of the config file, in the ~/.emuclient/config directory (ex : toto.xml).<br />
+
:The name of the config file, in the ~/.gimx/config directory (ex : toto.xml).<br />
 
:This argument is mandatory.
 
:This argument is mandatory.
 
* --port /dev/ttyUSB0
 
* --port /dev/ttyUSB0
 
:The serial port. Ex: /dev/ttyUSB0 in Linux, COM4 in windows.<br />
 
:The serial port. Ex: /dev/ttyUSB0 in Linux, COM4 in windows.<br />
 
:Only mandatory for the DIY USB adapter.
 
:Only mandatory for the DIY USB adapter.
* --type joystick/GPP/360pad/Sixaxis/PS2pad
 
:The type of USB adapter.
 
:joystick is for the DIY USB adapter with the joystick firmware
 
:Sixaxis is for the DIY USB adapter with the sixaxis firmware
 
:This option is only applicable for GIMX later than 0.51.
 
:Optional since GIMX 1.10.
 
 
* --refresh 4
 
* --refresh 4
 
:The refresh period, in ms.<br />
 
:The refresh period, in ms.<br />
:Recommended values:<br />
+
:Optional. Forcing the refresh period is not recommended.
:joystick/GPP/360pad/Sixaxis: 4 (250Hz)<br />
+
 
:PS2pad: 16 (62.5Hz)
+
==Linux or Windows + Remote GIMX==
:Optional since GIMX 1.10.
+
 
*<span style="color:#808080"> --serial</span>
+
In a terminal:<br />
:<span style="color:#808080">Only mandatory for the DIY USB adapter.</span>
+
 
:<span style="color:#808080">This option is only applicable for GIMX 0.51 and older.</span>
+
  gimx --config file_name --dst IP:port
*<span style="color:#808080"> --joystick / --GPP / --360pad / --PS2pad</span>
+
or
:<span style="color:#808080">The type of USB adapter.</span>
+
  gimx -c file_name -d IP:port
:<span style="color:#808080">--joystick is for the DIY USB adapter</span>
 
:<span style="color:#808080">This option is only applicable for GIMX 0.51 and older.</span>
 
*<span style="color:#808080"> --precision 16</span>
 
:<span style="color:#808080">The axis precision. Joystick: 16, Other adapters: 8.</span>
 
:<span style="color:#808080">This option is only applicable for GIMX 0.51 and older.</span>
 
  
 +
gimx options:
 +
* --config file_name
 +
:The name of the config file, in the ~/.gimx/config directory (ex : toto.xml).<br />
 +
:This argument is mandatory.
 +
* --dst IP:port
 +
:The destination IP+port. Ex: 127.0.0.1:51914.<br />
 +
:The remote GIMX has to be started with the --src argument, with the same IP:port value.
  
==General emuclient options==
+
==General gimx options==
  
 
* --curses
 
* --curses
Line 114: Line 151:
 
:Improve stick precision (counteract rounding issues).
 
:Improve stick precision (counteract rounding issues).
 
* --keygen key
 
* --keygen key
:Generate a key press at emuclient startup.<br />
+
:Generate a key press at gimx startup.<br />
 
:The main use case for this is the automation of macro's execution.<br />
 
:The main use case for this is the automation of macro's execution.<br />
 
:Events that are not generated by macros are ignored.<br />
 
:Events that are not generated by macros are ignored.<br />
:<span style="color:#808080">For GIMX older than 1.10: the only way to quit is to add KEYDOWN LSHIFT and KEYDOWN ESCAPE at the end of the macro, or use --nograb and press ctrl+c into the terminal.<br /></span>
 
 
:Another use case is the sending of a single command (it requires to use a macro as no key up event is generated).
 
:Another use case is the sending of a single command (it requires to use a macro as no key up event is generated).
 
* --event "control(value)"
 
* --event "control(value)"
:Since GIMX 1.10 it's possible to send controls to the console from the command line, without having to create a configuration and macros to use with the --keygen argument.
+
:It's possible to send controls to the console from the command line, without having to create a configuration and macros to use with the --keygen argument.
 
:Example:
 
:Example:
   emuclient -p /dev/ttyUSB0 --event "lstick x(127)" --event "rstick y(-128)" --event "circle(255)" --event "square(0)"
+
   gimx -p /dev/ttyUSB0 --event "lstick x(127)" --event "rstick y(-128)" --event "circle(255)" --event "square(0)"
 
:This moves the left stick right, the right stick forward, fully presses the circle button, and releases the square button.
 
:This moves the left stick right, the right stick forward, fully presses the circle button, and releases the square button.
 
:The state of all other controls is cleared, i.e. all other buttons and axes are released (in the above command, --event "square(0)" is not necessary).
 
:The state of all other controls is cleared, i.e. all other buttons and axes are released (in the above command, --event "square(0)" is not necessary).
:emuclient should complete in about 10ms.
+
:gimx should complete in about 10ms.
 
:Names and value ranges:
 
:Names and value ranges:
 
:"lstick x", "lstick y", "rstick x", "rstick y": [-128,127]
 
:"lstick x", "lstick y", "rstick x", "rstick y": [-128,127]
Line 131: Line 167:
 
:"select", "start", "PS", "l3", "r3": {0, 255} (only two values as these buttons are not pressure-sensitive)
 
:"select", "start", "PS", "l3", "r3": {0, 255} (only two values as these buttons are not pressure-sensitive)
 
:"up", "right", "down", "left", "triangle", "circle", "cross", "square", "l1", "r1", "l2", "r2": [0,255]
 
:"up", "right", "down", "left", "triangle", "circle", "cross", "square", "l1", "r1", "l2", "r2": [0,255]
 +
* --src IP:port
 +
:Specifies a source IP+port to listen on. Ex: 127.0.0.1:51914.
 +
:This argument has to be placed before the --bdaddr and --port arguments.

Revision as of 10:26, 3 September 2014

Other languages:

Motivation

GIMX can be run from a Linux terminal without having to run a windowing system.
This improves performances, especially on small targets like the Raspberry Pi or thin clients.
It's also useful for other stuff like automation.

Linux + bluetooth + PS3

Set the dongle address

It is highly recommended to use a CSR Bluecore4-rom dongle. Check the compatibility list.

Plug a Sixaxis previously paired with the target PS3.

Type in a terminal:

sixaddr

Result:

Current Bluetooth master: ps3_bt_address
Current Bluetooth Device Address: sixaxis_bt_address

Get the current dongle address:

bdaddr -i hciN

where N is the dongle index (type "hciconfig -a" to see all dongles).

Write it down so as to be able to restore it later.

Set the dongle address:

bdaddr -r -i hciN sixaxis_bt_address

Check the result:

bdaddr -i hciN

Run GIMX

In a terminal:

gimx --type Sixaxis --config filename --hci bt_device_index --bdaddr ps3_bt_address
  • file_name
The name of the config file, in the ~/.gimx/config directory (ex : toto.xml).
This argument is mandatory.
Use backslashes to escape spaces.
  • bt_device_index
The bluetooth device index (ex : 0 for hci0, 1 for hci1, etc).
This argument is optional, default device index is 0.
  • ps3_bt_address
This argument is mandatory.

Linux + bluetooth + PS4

Setup

The setup performs the bluetooth pairing between the PS4 and the dongle, and between the dongle and the DS4.
It has to be run again if the DS4 is reused (i.e. paired again) with the PS4.

Download the helper script:

 wget https://raw.github.com/matlo/GIMX-tools/master/PS4/gimx-ps4-helper.sh -O gimx-ps4-helper.sh

Make it executable:

 chmod +x gimx-ps4-helper.sh

Run it:

 sudo ./gimx-ps4-helper.sh

Simply follow the instructions. A successful output should look like this:

 $ sudo ./gimx-ps4-setup.sh
 Unplug any Dualshock 4.
 Unplug any teensy.
 Unpug the bluetooth dongle.
 Then press enter.
 
 Plug the bluetooth dongle.
 The bluetooth dongle address is XX:XX:XX:XX:XX:XX.
 The bluetooth hci number is 1.
 Plug the DS4 with a USB cable.
 The DS4 address is YY:YY:YY:YY:YY:YY.
 Unplug the DS4.
 Plug the teensy.
 Unplug the teensy.
 Plug the teensy to the PS4, and wait a few seconds.
 Then plug the teensy back to the PC.
 The PS4 address is ZZ:ZZ:ZZ:ZZ:ZZ:ZZ.
 Everything was successful: setting dongle link keys.
 To run gimx, type:
 gimx -t DS4 -c config.xml -h 1 -b ZZ:ZZ:ZZ:ZZ:ZZ:ZZ

Run GIMX

1. The bluetooth service has to be stopped before starting GIMX (this allows GIMX to get incoming connections):

 sudo service bluetooth stop

You may also have to deactivate the bluetooth service if your system starts it automatically.

2. Start GIMX:

 gimx -t DS4 -c <config file> -h <hci number> -b <PS4 bdaddr>

<config file> is the name of the config file to use.
<hci number> is the bluetooth hci number, for example 0 if there is only one bluetooth adapter (internal or external). Run 'hciconfig' if you're not sure about this value.
<PS4 bdaddr> is the address of the PS4.

3. Start the DS4. It should connect to GIMX, which in turn should connect to the PS4.

Linux or Windows + DIY USB adapter or GPP

In a terminal:

 gimx --config file_name --port /dev/ttyUSBX
or
 gimx -c file_name -p /dev/ttyUSBX

gimx options:

  • --config file_name
The name of the config file, in the ~/.gimx/config directory (ex : toto.xml).
This argument is mandatory.
  • --port /dev/ttyUSB0
The serial port. Ex: /dev/ttyUSB0 in Linux, COM4 in windows.
Only mandatory for the DIY USB adapter.
  • --refresh 4
The refresh period, in ms.
Optional. Forcing the refresh period is not recommended.

Linux or Windows + Remote GIMX

In a terminal:

 gimx --config file_name --dst IP:port
or
 gimx -c file_name -d IP:port

gimx options:

  • --config file_name
The name of the config file, in the ~/.gimx/config directory (ex : toto.xml).
This argument is mandatory.
  • --dst IP:port
The destination IP+port. Ex: 127.0.0.1:51914.
The remote GIMX has to be started with the --src argument, with the same IP:port value.

General gimx options

  • --curses
curses terminal display.
Mouse calibration is available through this interface.
  • --status
Display controls in the terminal.
  • --nograb
Do not grab the mouse cursor.
  • --force-updates
Send button+axis status even if there is no change (for compatibility with games like DNF).
  • --subpos
Improve stick precision (counteract rounding issues).
  • --keygen key
Generate a key press at gimx startup.
The main use case for this is the automation of macro's execution.
Events that are not generated by macros are ignored.
Another use case is the sending of a single command (it requires to use a macro as no key up event is generated).
  • --event "control(value)"
It's possible to send controls to the console from the command line, without having to create a configuration and macros to use with the --keygen argument.
Example:
 gimx -p /dev/ttyUSB0 --event "lstick x(127)" --event "rstick y(-128)" --event "circle(255)" --event "square(0)"
This moves the left stick right, the right stick forward, fully presses the circle button, and releases the square button.
The state of all other controls is cleared, i.e. all other buttons and axes are released (in the above command, --event "square(0)" is not necessary).
gimx should complete in about 10ms.
Names and value ranges:
"lstick x", "lstick y", "rstick x", "rstick y": [-128,127]
"acc x", "acc y", "acc z", "gyro": [-512,511]
"select", "start", "PS", "l3", "r3": {0, 255} (only two values as these buttons are not pressure-sensitive)
"up", "right", "down", "left", "triangle", "circle", "cross", "square", "l1", "r1", "l2", "r2": [0,255]
  • --src IP:port
Specifies a source IP+port to listen on. Ex: 127.0.0.1:51914.
This argument has to be placed before the --bdaddr and --port arguments.