Skip to content

Write automated scripts for Xbox or PlayStation console games

License

Notifications You must be signed in to change notification settings

tylearymf/AutomaticGamepad

Repository files navigation

AutomaticGamepad

中文文档

About

  • Write automated scripts for console games
Supported Devices:video_game: Xbox One X Xbox Series X PlayStation 4 PlayStation 5
Test Result▶️

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

// Put the program to sleep for a while
void sleep(double milliseconds)
  • milliseconds:sleep time

setdelay

// The delay after a method is called. For example, call button(), dpad()
void setdelay(double delay)
  • delay:delay time(milliseconds)

button

// Press button
// For example, press LB button, or L1 button
void button(string name, double duration = 200)
  • name:Button Key Name
  • duration:Duration of the press. The default value is 200 ms

dpad

// Press the DPAD button
// For example, press the up button of the DPad
void dpad(string name, double duration = 200)
  • name:DPad Key Name
  • duration:Duration of the press. The default value is 200 ms

trigger

// 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
  • val:Trigger press value, range is [0, 1], full press is 1
  • duration:Duration of the press. The default value is 200 ms

axis

// 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
  • 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

// Push the two axes of the joystick
void axis2(string name1, string name2, double val1, double val2, double duration = 200)
  • name1:Axis Key Name
  • name2: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

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

dpadstate

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

triggerstate

// Press or release the trigger
void triggerstate(string name, double val)
  • name:Trigger Key Name
  • val:Trigger press value, range is [0, 1], full press is 1

axisstate

// Push the single axis of the joystick
void axisstate(string name, double val)
  • 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

// Push the two axes of the joystick
void axis2state(string name1, string name2, double val1, double val2)
  • name1:Axis Key Name
  • name2: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

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                                                                                                        
XboxPlayStation
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

// 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 ViGEm.NET