An open API service indexing awesome lists of open source software.

https://github.com/tylearymf/automaticgamepad

Write automated scripts for Xbox or PlayStation console games
https://github.com/tylearymf/automaticgamepad

automatic elden-ring eldenring gamepad playstation ps5 xbox

Last synced: 3 months ago
JSON representation

Write automated scripts for Xbox or PlayStation console games

Awesome Lists containing this project

README

          

# AutomaticGamepad

[中文文档](https://github.com/tylearymf/AutomaticGamepad/blob/main/README_CN.md)

# About

* Write automated scripts for console games

| Supported Devices:video_game: | Xbox One X | Xbox Series X | PlayStation 4 | PlayStation 5 |
| ------------------------------ | :----------------: | :----------------: | :-----------: | :----------------: |
| **Test Result**:arrow_forward: | :white_check_mark: | :white_check_mark: | :question: | :white_check_mark: |

## Prerequisites

1. You need a PC, an Xbox (or PS5, PS4)
2. The idea is to stream an Xbox (or PS5) on a PC over a local area network, and then use the software to send virtual gamepad signals to a streaming window on the PC

# Usage

1. Install the virtual gamepad driver **ViGEmBusSetup.msi** in the Drivers directory
2. Run Xbox.exe (or PS Remote Play.exe) to stream your Xbox (or PS5).
3. Configure **config.ini** and set the **GamepadType** parameter
1. Xbox:GamepadType=0
2. PlayStation:GamepadType=1
4. Run AutomaticGamepad.exe
5. Select the script you want to run, confirm that the window binding is successful, set the number of times to run, and finally click Start

Xbox Virtual Controller

Playstation Virtual Controller

---

# Script functions

1. The scripting language is JavaScript
2. The script file suffix is .ag
3. Place the script file in the same directory as the current program, and click Refresh in the program to view it

## sleep

```c#
// Put the program to sleep for a while
void sleep(double milliseconds)
```

* milliseconds:sleep time

## setdelay

```c#
// The delay after a method is called. For example, call button(), dpad()
void setdelay(double delay)
```

* delay:delay time(milliseconds)

## button

```c#
// Press button
// For example, press LB button, or L1 button
void button(string name, double duration = 200)
```

* name:[Button Key Name](#button_key_name)
* duration:Duration of the press. The default value is 200 ms

## dpad

```c#
// Press the DPAD button
// For example, press the up button of the DPad
void dpad(string name, double duration = 200)
```

* name:[DPad Key Name](#dpad_key_name)
* duration:Duration of the press. The default value is 200 ms

## trigger

```c#
// Press the trigger
// For example, press LT or RT, L1 or R1
void trigger(string name, double val, double duration = 200)
```

* name:[Trigger Key Name](#trigger_key_name)
* val:Trigger press value, range is [0, 1], full press is 1
* duration:Duration of the press. The default value is 200 ms

## axis

```c#
// Push the single axis of the joystick
// For example, push the X-axis or Y-axis of the left joystick, or push the X-axis or Y-axis of the right joystick
void axis(string name, double val, double duration = 200)
```

* name:[Axis Key Name](#axis_key_name)
* val:The joystick push value, the range is [-1, 1], the lower left is -1, and the upper right is 1
* duration:Duration of the press. The default value is 200 ms

## axis2

```c#
// Push the two axes of the joystick
void axis2(string name1, string name2, double val1, double val2, double duration = 200)
```

* name1:[Axis Key Name](#axis_key_name)
* name2:[Axis Key Name](#axis_key_name)
* val1:The joystick push value, the range is [-1, 1], the lower left is -1, and the upper right is 1
* val2:The joystick push value, the range is [-1, 1], the lower left is -1, and the upper right is 1
* duration:Duration of the press. The default value is 200 ms

## buttonstate

```c#
// Press or release the button
void buttonstate(string name, bool state)
```

* name:[Button Key Name](#button_key_name)
* state::press is true, release is false

## dpadstate

```c#
// Press or release the dpad button
void dpadstate(string name, bool state)
```

* name:[DPad Key Name](#dpad_key_name)
* state::press is true, release is false

## triggerstate

```c#
// Press or release the trigger
void triggerstate(string name, double val)
```

* name:[Trigger Key Name](#trigger_key_name)
* val:Trigger press value, range is [0, 1], full press is 1

## axisstate

```c#
// Push the single axis of the joystick
void axisstate(string name, double val)
```

* name:[Axis Key Name](#axis_key_name)
* val:The joystick push value, the range is [-1, 1], the lower left is -1, and the upper right is 1

## axis2state

```c#
// Push the two axes of the joystick
void axis2state(string name1, string name2, double val1, double val2)
```

* name1:[Axis Key Name](#axis_key_name)
* name2:[Axis Key Name](#axis_key_name)
* val1:The joystick push value, the range is [-1, 1], the lower left is -1, and the upper right is 1
* val2:The joystick push value, the range is [-1, 1], the lower left is -1, and the upper right is 1

# Custom key name

* Xbox:[XboxGamepad.cs](https://github.com/tylearymf/AutomaticGamepad/blob/main/Xbox/XboxGamepad.cs)
* PlayStation:[PlaystationGamepad.cs](https://github.com/tylearymf/AutomaticGamepad/blob/main/PlayStation/PlaystationGamepad.cs)

# Button Key Name


Xbox
PlayStation


A Button
"a"
△ Button
”b1“


B Button
"b"
○ Button
"b2"


X Button
"x"
X Button
"b3"


Y Button
"y"
□ Button
"b4"


Left Bumper
"lb"
L1 Button
"l1"


Right Bumper
"rb"
R1 Button
"r1"


Left Stick Button
"lsb"
Left Stick Button
"l3"


Right Stick Button
"rsb"
Right Stick Button
"r3"


Menu Button
"menu"
Share Button
"share"


View Button
"view"
Option Button
"option"


XBOX Button
"home"
PS Button
"home"




Touchpad Button
"touchpad"

# DPad Key Name


Xbox & PlayStation


Up key
"up"


Down key
"down"


Left Key
"left"


Right Key
"right"

# Trigger Key Name

   
        Xbox
        PlayStation
   
   
        Left Trigger
        "lt"
        L2 Key
        "l2"
   
   
        Right Trigger
        "rt"
        R2 Key
        "r2"
   

# Axis Key Name

   
        Xbox & PlayStation
   
   
X-axis of left joystick
        "lsx"
   
   
        Y-axis of left joystick
        "lsy"
   
   
        X-axis of right joystick
        "rsx"
   
   
        Y-axis of left joystick
        "rsy"
   

# Example

```javascript
// For example (XBOX)
// 1. Go to the ’Palace Approach Ledge Road‘ Site of Grace
// 2. Please two-hand your equipped 'Sacred Sword Relic' weapon
// 3. Finally, please follow the ‘Usage’ steps

// Go to the Site of Grace
button("view")
button("y")
button("a")
button("a")

// Wait for the map to finish loading
sleep(5500)

// Move to the front left
axis2("lsx", "lsy", -0.31, 1, 5200)

// Cast weapons skill
trigger("lt", 1)

// wait for the monsters to die
sleep(5000)

```

example.gif

# Reference

> [ViGEmBus](https://github.com/ViGEm/ViGEmBus)
> [ViGEm.NET](https://github.com/tylearymf/ViGEm.NET)