When testing an Xbox One title, it is not always efficient to have a human use a physical gamepad to interact with the development console. You can automate unit tests, stress tests, long-haul tests, and user tests by programmatically simulating gamepad input using Xbox Tools Framework (XTF) and the Xbox Test Toolkit on a computer. It is possible to simulate gamepad input for several consoles at once to test online multiplayer scenarios.
To simulate gamepad input, add XtfInput.lib to Configuration Properties->Linker->Input->Additional Dependencies and reference XInput.h (in XDK Path\PC\inlude) in the source files of your test harness or standalone tool. XtfInput.lib is located in XDK Install Path\PC\lib\amd64. XtfInput.h is located in XDK Install Path\PC\Include.
Note Xtf application cannot target 32-bit systems, you must ensure that your build options are targeting a 64-bit system. The following step can be used to set your project to target 64-bit:
- Open the BUILD menu at the top context bar and select Configuration Manager…
- Open the Active solution platform: dropdown (which is most likely set to Win32) and select <New..>
- Open the Type or select the new platform: dropdown and select x64, and copy settings from your preferred configuration (most likely Win32)
- Hit OK to add the new configuration
gamepadReport.Buttons = A;gamepadReport.Buttons = NONE.The following code example demonstrates how to programmatically simulate controller input.
C++
#include "XtfInput.h"
...
IID * riid;
IXtfInputClient * inputClient;
UINT64 controllerID;
GAMEPAD_REPORT gamepadReport = {0,0,0,0,0,0,0};
XtfCreateInputClient((LPCWSTR)"10.124.220.157",(const IID &)riid,(void **)&inputClient);
inputClient->ConnectGamepad(&controllerID);
gamepadReport.Buttons = A;
inputClient->SendGamepadReport(controllerID,gamepadReport);
Sleep(250);
gamepadReport.Buttons = NONE;
inputClient->SendGamepadReport(controllerID,gamepadReport);
...
inputClient->DisconnectGamepad(controllerID);