mirror of https://github.com/PCSX2/pcsx2.git
LilyPad: More minor fixes to failure detection in raw input initialization code. Gabest already fixed the big one.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1013 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
a2a1d58b4b
commit
1d2ae02c97
|
@ -105,12 +105,14 @@ struct Stick {
|
||||||
int vert;
|
int vert;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sum of states of all controls for a pad (Not including toggles).
|
||||||
struct ButtonSum {
|
struct ButtonSum {
|
||||||
int buttons[12];
|
int buttons[12];
|
||||||
Stick sticks[3];
|
Stick sticks[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Freeze data, for a single pad.
|
// Freeze data, for a single pad. Basically has all pad state that
|
||||||
|
// a PS2 can set.
|
||||||
struct PadFreezeData {
|
struct PadFreezeData {
|
||||||
// Digital / Analog / DS2 Native
|
// Digital / Analog / DS2 Native
|
||||||
u8 mode;
|
u8 mode;
|
||||||
|
@ -129,9 +131,14 @@ struct PadFreezeData {
|
||||||
|
|
||||||
class Pad : public PadFreezeData {
|
class Pad : public PadFreezeData {
|
||||||
public:
|
public:
|
||||||
ButtonSum sum, lockedSum;
|
// Current pad state.
|
||||||
|
ButtonSum sum;
|
||||||
|
// State of locked buttons. Already included by sum, used
|
||||||
|
// as initial value of sum.
|
||||||
|
ButtonSum lockedSum;
|
||||||
|
|
||||||
int lockedState;
|
// Flags for which controls (buttons or axes) are locked, if any.
|
||||||
|
DWORD lockedState;
|
||||||
|
|
||||||
// Last vibration value. Only used so as not to call vibration
|
// Last vibration value. Only used so as not to call vibration
|
||||||
// functions when old and new values are both 0.
|
// functions when old and new values are both 0.
|
||||||
|
|
|
@ -249,21 +249,31 @@ int InitializeRawInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumRawInputDevices() {
|
void EnumRawInputDevices() {
|
||||||
UINT count = 0;
|
int count = 0;
|
||||||
if (InitializeRawInput() && pGetRawInputDeviceList(0, &count, sizeof(RAWINPUTDEVICELIST)) != (UINT)-1) {
|
if (InitializeRawInput() && pGetRawInputDeviceList(0, (unsigned int*)&count, sizeof(RAWINPUTDEVICELIST)) && count > 0) {
|
||||||
wchar_t *instanceID = (wchar_t *) malloc(41000*sizeof(wchar_t));
|
wchar_t *instanceID = (wchar_t *) malloc(41000*sizeof(wchar_t));
|
||||||
wchar_t *keyName = instanceID + 11000;
|
wchar_t *keyName = instanceID + 11000;
|
||||||
wchar_t *displayName = keyName + 10000;
|
wchar_t *displayName = keyName + 10000;
|
||||||
wchar_t *productID = displayName + 10000;
|
wchar_t *productID = displayName + 10000;
|
||||||
|
|
||||||
|
RAWINPUTDEVICELIST *list = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * count);
|
||||||
int keyboardCount = 1;
|
int keyboardCount = 1;
|
||||||
int mouseCount = 1;
|
int mouseCount = 1;
|
||||||
if (count) {
|
count = pGetRawInputDeviceList(list, (unsigned int*)&count, sizeof(RAWINPUTDEVICELIST));
|
||||||
RAWINPUTDEVICELIST *list = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * count);
|
|
||||||
if (list && pGetRawInputDeviceList(list, &count, sizeof(RAWINPUTDEVICELIST))) {
|
// Not necessary, but reminder that count is -1 on failure.
|
||||||
for (UINT i=0; i<count; i++) {
|
if (count > 0) {
|
||||||
UINT nameLen = 10000;
|
for (int i=0; i<count; i++) {
|
||||||
if ((int)pGetRawInputDeviceInfo(list[i].hDevice, RIDI_DEVICENAME, instanceID, &nameLen) > 0 &&
|
if (list[i].dwType != RIM_TYPEKEYBOARD && list[i].dwType != RIM_TYPEMOUSE) continue;
|
||||||
nameLen >= 3) {
|
|
||||||
|
UINT bufferLen = 10000;
|
||||||
|
int nameLen = pGetRawInputDeviceInfo(list[i].hDevice, RIDI_DEVICENAME, instanceID, &bufferLen);
|
||||||
|
if (nameLen >= 4) {
|
||||||
|
// nameLen includes terminating null.
|
||||||
|
nameLen--;
|
||||||
|
|
||||||
|
// Strip out GUID parts of instanceID to make it a generic product id,
|
||||||
|
// and reformat it to point to registry entry containing device description.
|
||||||
wcscpy(productID, instanceID);
|
wcscpy(productID, instanceID);
|
||||||
wchar_t *temp = 0;
|
wchar_t *temp = 0;
|
||||||
for (int j=0; j<3; j++) {
|
for (int j=0; j<3; j++) {
|
||||||
|
@ -275,6 +285,7 @@ void EnumRawInputDevices() {
|
||||||
}
|
}
|
||||||
if (j==1) temp = s;
|
if (j==1) temp = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
wsprintfW(keyName, L"SYSTEM\\CurrentControlSet\\Enum%s", productID+3);
|
wsprintfW(keyName, L"SYSTEM\\CurrentControlSet\\Enum%s", productID+3);
|
||||||
if (temp) *temp = 0;
|
if (temp) *temp = 0;
|
||||||
displayName[0] = 0;
|
displayName[0] = 0;
|
||||||
|
@ -304,9 +315,8 @@ void EnumRawInputDevices() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
free(list);
|
free(list);
|
||||||
}
|
|
||||||
}
|
|
||||||
free(instanceID);
|
free(instanceID);
|
||||||
dm->AddDevice(new RawInputKeyboard(0, L"Simulated Keyboard"));
|
dm->AddDevice(new RawInputKeyboard(0, L"Simulated Keyboard"));
|
||||||
dm->AddDevice(new RawInputMouse(0, L"Simulated Mouse"));
|
dm->AddDevice(new RawInputMouse(0, L"Simulated Mouse"));
|
||||||
|
|
Loading…
Reference in New Issue