win: Fix X360 button problems by skipping DInput if there's a 360 pad available.

This commit is contained in:
Henrik Rydgard 2013-04-01 20:15:16 +02:00
parent e95b43a12d
commit 09d1f3c1fa
5 changed files with 9 additions and 4 deletions

View File

@ -94,7 +94,7 @@ int DinputDevice::UpdateState(InputState &input_state)
}
if(FAILED(pJoystick->GetDeviceState(sizeof(DIJOYSTATE2), &js)))
return -1;
return -1;
switch (js.rgdwPOV[0])
{

View File

@ -8,8 +8,8 @@
#define PUSH_BACK(Cls) do { list.push_back(std::shared_ptr<InputDevice>(new Cls())); } while (0)
std::list<std::shared_ptr<InputDevice>> getInputDevices() {
std::list<std::shared_ptr<InputDevice>> list;
PUSH_BACK(KeyboardDevice);
PUSH_BACK(XinputDevice);
PUSH_BACK(DinputDevice);
PUSH_BACK(KeyboardDevice);
return list;
}

View File

@ -10,6 +10,7 @@ struct InputState;
class InputDevice
{
public:
enum { UPDATESTATE_SKIP_NEXT = 0x1234};
virtual int UpdateState(InputState &input_state) = 0;
};

View File

@ -132,7 +132,8 @@ void WindowsHost::SetDebugMode(bool mode)
void WindowsHost::PollControllers(InputState &input_state)
{
for (auto iter = this->input.begin(); iter != this->input.end(); iter++)
(*iter)->UpdateState(input_state);
if ((*iter)->UpdateState(input_state) == InputDevice::UPDATESTATE_SKIP_NEXT)
break;
}
void WindowsHost::BootDone()

View File

@ -52,7 +52,10 @@ int XinputDevice::UpdateState(InputState &input_state) {
this->prevState = state;
this->check_delay = 0;
return 0;
// If there's an XInput pad, skip following pads. This prevents DInput and XInput
// from colliding.
return UPDATESTATE_SKIP_NEXT;
} else {
// wait check_delay frames before polling the controller again
this->gamepad_idx = -1;