Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
To start using Steamworks after adding it to your game's project, you need to call the SteamAPI_Init
function
to initialize the API. Optionally, you can call SteamAPI_RestartAppIfNecessary
to relaunch the app
through Steam if necessary. Initializing the Microsoft Game Development Kit (GDK) is a bit more involved, because there isn't a unified app used to launch the game and communicate with the different gaming services like there is on Steam.
To start using the APIs in the GDK, you need to use the following steps.
- Add a MicrosoftGame.config file to your project.
- Initialize the Gaming Runtime service.
- Initialize the Xbox Services API to make calls to Xbox Live for user identity, cloud saves, achievements, and more.
- Sign the user in to Xbox Live. Store the handle and Xbox User ID (XUID) that was returned after a successful sign-in for future use.
Note
On Steam, you have access to the user's Steam ID and all the APIs at load time, because the Steam launcher automatically injects the user's account information when games are launched from their service. The Xbox Live APIs are used by games across multiple launchers, so you don't get this for free. You need to manually sign the user in at launch.
For information about how to do step 1, see MicrosoftGame.config overview.
You can find information about how to do steps 2–4 in Getting started with Xbox Live APIs
(or summarized as follows), making sure to implement the behavior that's described in the Cleaning up XSAPI section of that topic as well. After the Gaming Runtime and Xbox Services API have been initialized, you can sign the user in to Xbox Live. You don't need to create an XTaskQueue
because that's automatically created for you if you leave it blank.
#include <XGameRuntimeInit.h>
#include <XTaskQueue.h>
#include <xsapi-c/services_c.h>
// ...
void InitializeXboxLive()
{
// ...
HRESULT hr = XGameRuntimeInitialize();
if (FAILED(hr))
{
// handle error: couldn't initialize the Gaming Runtime service.
}
XblInitArgs xblArgs = {};
xblArgs.scid = "00000000-0000-0000-0000-000000000000"; // Add your SCID here that you got from the Partner Center web portal.
HRESULT hr = XblInitialize(&xblArgs);
if (FAILED(hr))
{
// handle error: couldn't initialize Xbox Live.
}
// ...
}
Sign the user in to Xbox Live
Use the XUserAddAsync API to sign a user in to Xbox Live. If this is the first time they're signing in to your game, they're given a list of privileges that your game is requesting. They'll need to explicitly authorize these privileges to access their Xbox Live account.
After they're successfully signed in, you can use the XUserHandle
reference that you passed into the XUserAddResult function. It can be
used to obtain information about that Xbox Live user, such as their gamertag, gamer photo, sign-in state, age group, and
privileges.
After the user signs in for the first time, they should be able to successfully sign in silently (that is, with no action required on their part) if they don't need to resolve a UI prompt (such as a new privacy agreement) since they last launched the game. However, you'll still need to make these API calls to gain identity access.
An XblContextHandle will be needed to call Xbox Live APIs. You can use the
XblContextCreateHandle function to get an XblContextHandle by using an XUserHandle
.