- There's really no need anymore to dynamically load RawInput, considering it has been in Windows since XP.
This commit is contained in:
parent
79ad3e6203
commit
293aa2e6da
6 changed files with 45 additions and 270 deletions
|
|
@ -41,7 +41,6 @@
|
|||
#include "templates.h"
|
||||
#include "gameconfigfile.h"
|
||||
#include "m_argv.h"
|
||||
#include "rawinput.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
|
@ -901,23 +900,17 @@ bool FRawPS2Manager::GetDevice()
|
|||
{
|
||||
RAWINPUTDEVICE rid;
|
||||
|
||||
if (MyRegisterRawInputDevices == NULL ||
|
||||
MyGetRawInputDeviceList == NULL ||
|
||||
MyGetRawInputDeviceInfoA == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rid.usUsagePage = HID_GENERIC_DESKTOP_PAGE;
|
||||
rid.usUsage = HID_GDP_JOYSTICK;
|
||||
rid.dwFlags = RIDEV_INPUTSINK;
|
||||
rid.hwndTarget = Window;
|
||||
if (!MyRegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||
if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rid.dwFlags = RIDEV_REMOVE;
|
||||
rid.hwndTarget = NULL; // Must be NULL for RIDEV_REMOVE.
|
||||
MyRegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||
EnumDevices();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1013,7 +1006,7 @@ FRawPS2Controller *FRawPS2Manager::EnumDevices()
|
|||
RAWINPUTDEVICELIST *devices;
|
||||
UINT i, j;
|
||||
|
||||
if (MyGetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST)) != 0)
|
||||
if (GetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST)) != 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1021,7 +1014,7 @@ FRawPS2Controller *FRawPS2Manager::EnumDevices()
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
if ((numDevices = MyGetRawInputDeviceList(devices, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT)-1)
|
||||
if ((numDevices = GetRawInputDeviceList(devices, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT)-1)
|
||||
{
|
||||
free(devices);
|
||||
return NULL;
|
||||
|
|
@ -1037,7 +1030,7 @@ FRawPS2Controller *FRawPS2Manager::EnumDevices()
|
|||
UINT cbSize;
|
||||
|
||||
cbSize = rdi.cbSize = sizeof(rdi);
|
||||
if ((INT)MyGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &cbSize) >= 0)
|
||||
if ((INT)GetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &cbSize) >= 0)
|
||||
{
|
||||
// All the PS2 adapters report themselves as joysticks.
|
||||
// (By comparison, the 360 controller reports itself as a gamepad.)
|
||||
|
|
@ -1080,41 +1073,41 @@ FRawPS2Controller *FRawPS2Manager::EnumDevices()
|
|||
// <Enumerator>#<Device ID>#<Device Interface Class GUID>
|
||||
// The Device ID has multiple #-seperated parts and uniquely identifies
|
||||
// this device and which USB port it is connected to.
|
||||
char name[256];
|
||||
wchar_t name[256];
|
||||
UINT namelen = countof(name);
|
||||
char *devid, *devidend;
|
||||
wchar_t *devid, *devidend;
|
||||
|
||||
if (MyGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, name, &namelen) == (UINT)-1)
|
||||
if (GetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &namelen) == (UINT)-1)
|
||||
{ // Can't get name. Skip it, since there's stuff in there we need for config.
|
||||
continue;
|
||||
}
|
||||
|
||||
devid = strchr(name, '#');
|
||||
devid = wcschr(name, '#');
|
||||
if (devid == NULL)
|
||||
{ // Should not happen
|
||||
continue;
|
||||
}
|
||||
devidend = strrchr(++devid, '#');
|
||||
devidend = wcsrchr(++devid, '#');
|
||||
if (devidend != NULL)
|
||||
{
|
||||
*devidend = '\0';
|
||||
}
|
||||
|
||||
FAdapterHandle handle = { devices[i].hDevice, type, 0, devid };
|
||||
FAdapterHandle handle = { devices[i].hDevice, type, 0, FString(devid) };
|
||||
|
||||
// Adapters that support more than one controller have a seperate device
|
||||
// entry for each controller. We can examine the name to determine which
|
||||
// controller this device is for.
|
||||
if (Descriptors[type].ControllerNumber >= 0)
|
||||
{
|
||||
char *col = strstr(devid, "&Col");
|
||||
wchar_t *col = wcsstr(devid, L"&Col");
|
||||
if (col != NULL)
|
||||
{
|
||||
// I have no idea if this number is base 16 or base 10. Every
|
||||
// other number in the name is base 16, so I assume this one is
|
||||
// too, but since I don't have anything that goes higher than 02,
|
||||
// I can't be sure.
|
||||
handle.ControllerNumber = strtoul(col + 4, NULL, 16);
|
||||
handle.ControllerNumber = wcstoul(col + 4, NULL, 16);
|
||||
}
|
||||
}
|
||||
adapters.Push(handle);
|
||||
|
|
@ -1267,7 +1260,7 @@ void FRawPS2Manager::DoRegister()
|
|||
{
|
||||
rid.dwFlags = RIDEV_REMOVE;
|
||||
rid.hwndTarget = NULL;
|
||||
if (MyRegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||
if (RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||
{
|
||||
Registered = false;
|
||||
}
|
||||
|
|
@ -1279,7 +1272,7 @@ void FRawPS2Manager::DoRegister()
|
|||
{
|
||||
rid.dwFlags = RIDEV_INPUTSINK;
|
||||
rid.hwndTarget = Window;
|
||||
if (MyRegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||
if (RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||
{
|
||||
Registered = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue