mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
windisplay: fix handling of invalid devices, replaced 0 with nullptr
Fixes #1559 Closes #1563
This commit is contained in:
parent
1c4a91858b
commit
7277199d6e
@ -660,18 +660,18 @@ initialize_input_devices() {
|
|||||||
_input = device;
|
_input = device;
|
||||||
|
|
||||||
// Get the number of devices.
|
// Get the number of devices.
|
||||||
if (GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
|
if ((int)GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate the array to hold the DeviceList
|
// Allocate the array to hold the DeviceList
|
||||||
pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
|
pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
|
||||||
if (pRawInputDeviceList==0) {
|
if (pRawInputDeviceList == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the Array
|
// Fill the Array
|
||||||
if (GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
|
if ((int)GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,13 +680,13 @@ initialize_input_devices() {
|
|||||||
if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
|
if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
|
||||||
// Fetch information about specified mouse device.
|
// Fetch information about specified mouse device.
|
||||||
UINT nSize;
|
UINT nSize;
|
||||||
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0) {
|
if ((int)GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)nullptr, &nSize) != 0) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
|
char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
|
||||||
if (psName == 0) return;
|
if (psName == nullptr) continue;
|
||||||
if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
|
if ((int)GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's not an RDP mouse, add it to the list of raw mice.
|
// If it's not an RDP mouse, add it to the list of raw mice.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user