Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat the keyboard and pads differently #1214

Merged
merged 1 commit into from Apr 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions Windows/DinputDevice.cpp
Expand Up @@ -150,8 +150,6 @@ int DinputDevice::UpdateState(InputState &input_state)
}
}

if (js.lX != 0.0f || js.lY != 0.0f)
return UPDATESTATE_SKIP_NEXT;
return 0;
return UPDATESTATE_SKIP_PAD;
}

1 change: 1 addition & 0 deletions Windows/DinputDevice.h
Expand Up @@ -27,6 +27,7 @@ class DinputDevice :
DinputDevice();
~DinputDevice();
virtual int UpdateState(InputState &input_state);
virtual bool IsPad() { return true; }
private:
LPDIRECTINPUT8 pDI;
LPDIRECTINPUTDEVICE8 pJoystick;
Expand Down
3 changes: 2 additions & 1 deletion Windows/InputDevice.h
Expand Up @@ -10,8 +10,9 @@ struct InputState;
class InputDevice
{
public:
enum { UPDATESTATE_SKIP_NEXT = 0x1234};
enum { UPDATESTATE_SKIP_PAD = 0x1234};
virtual int UpdateState(InputState &input_state) = 0;
virtual bool IsPad() = 0;
};

std::list<std::shared_ptr<InputDevice>> getInputDevices();
1 change: 1 addition & 0 deletions Windows/KeyboardDevice.h
Expand Up @@ -4,4 +4,5 @@
class KeyboardDevice : public InputDevice {
public:
virtual int UpdateState(InputState &input_state);
virtual bool IsPad() { return false; }
};
10 changes: 8 additions & 2 deletions Windows/WindowsHost.cpp
Expand Up @@ -130,9 +130,15 @@ void WindowsHost::SetDebugMode(bool mode)

void WindowsHost::PollControllers(InputState &input_state)
{
bool doPad = true;
for (auto iter = this->input.begin(); iter != this->input.end(); iter++)
if ((*iter)->UpdateState(input_state) == InputDevice::UPDATESTATE_SKIP_NEXT)
break;
{
auto device = *iter;
if (!doPad && device->IsPad())
continue;
if (device->UpdateState(input_state) == InputDevice::UPDATESTATE_SKIP_PAD)
doPad = false;
}
}

void WindowsHost::BootDone()
Expand Down
4 changes: 1 addition & 3 deletions Windows/XinputDevice.cpp
Expand Up @@ -55,9 +55,7 @@ int XinputDevice::UpdateState(InputState &input_state) {

// If there's an XInput pad, skip following pads. This prevents DInput and XInput
// from colliding.
if (left.x != 0.0f || left.y != 0.0f)
return UPDATESTATE_SKIP_NEXT;
return 0;
return UPDATESTATE_SKIP_PAD;
} else {
// wait check_delay frames before polling the controller again
this->gamepad_idx = -1;
Expand Down
1 change: 1 addition & 0 deletions Windows/XinputDevice.h
Expand Up @@ -8,6 +8,7 @@ class XinputDevice :
public:
XinputDevice();
virtual int UpdateState(InputState &input_state);
virtual bool IsPad() { return true; }
private:
void ApplyDiff(XINPUT_STATE &state, InputState &input_state);
int gamepad_idx;
Expand Down