Added Steam Virtual Gamepad support to the GameInput driver
This commit is contained in:
@@ -52,6 +52,7 @@ typedef struct GAMEINPUT_InternalDevice
|
|||||||
SDL_GUID guid; // generated by SDL
|
SDL_GUID guid; // generated by SDL
|
||||||
SDL_JoystickID device_instance; // generated by SDL
|
SDL_JoystickID device_instance; // generated by SDL
|
||||||
const GameInputDeviceInfo *info;
|
const GameInputDeviceInfo *info;
|
||||||
|
int steam_virtual_gamepad_slot;
|
||||||
bool isAdded;
|
bool isAdded;
|
||||||
bool isDeleteRequested;
|
bool isDeleteRequested;
|
||||||
} GAMEINPUT_InternalDevice;
|
} GAMEINPUT_InternalDevice;
|
||||||
@@ -83,6 +84,16 @@ static bool GAMEINPUT_InternalIsGamepad(const GameInputDeviceInfo *info)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int GetSteamVirtualGamepadSlot(const char *device_path)
|
||||||
|
{
|
||||||
|
int slot = -1;
|
||||||
|
|
||||||
|
// The format for the raw input device path is documented here:
|
||||||
|
// https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices
|
||||||
|
(void)SDL_sscanf(device_path, "\\\\.\\pipe\\HID#VID_045E&PID_028E&IG_00#%*X&%*X&%*X#%d#%*u", &slot);
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
|
static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
|
||||||
{
|
{
|
||||||
GAMEINPUT_InternalDevice **devicelist = NULL;
|
GAMEINPUT_InternalDevice **devicelist = NULL;
|
||||||
@@ -162,6 +173,7 @@ static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
|
|||||||
elem->guid = SDL_CreateJoystickGUID(bus, vendor, product, version, manufacturer_string, product_string, 'g', 0);
|
elem->guid = SDL_CreateJoystickGUID(bus, vendor, product, version, manufacturer_string, product_string, 'g', 0);
|
||||||
elem->device_instance = SDL_GetNextObjectID();
|
elem->device_instance = SDL_GetNextObjectID();
|
||||||
elem->info = info;
|
elem->info = info;
|
||||||
|
elem->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(info->pnpPath);
|
||||||
|
|
||||||
g_GameInputList.devices = devicelist;
|
g_GameInputList.devices = devicelist;
|
||||||
g_GameInputList.devices[g_GameInputList.count++] = elem;
|
g_GameInputList.devices[g_GameInputList.count++] = elem;
|
||||||
@@ -349,7 +361,7 @@ static const char *GAMEINPUT_JoystickGetDevicePath(int device_index)
|
|||||||
|
|
||||||
static int GAMEINPUT_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index)
|
static int GAMEINPUT_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index)
|
||||||
{
|
{
|
||||||
return -1;
|
return GAMEINPUT_InternalFindByIndex(device_index)->steam_virtual_gamepad_slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GAMEINPUT_JoystickGetDevicePlayerIndex(int device_index)
|
static int GAMEINPUT_JoystickGetDevicePlayerIndex(int device_index)
|
||||||
|
|||||||
Reference in New Issue
Block a user