diff options
author | Bill Budge <bbudge@chromium.org> | 2015-06-18 16:05:13 -0700 |
---|---|---|
committer | Bill Budge <bbudge@chromium.org> | 2015-06-18 23:06:36 +0000 |
commit | 27eb8ba72f233cdd1f53d24aa97c059de3d19f1b (patch) | |
tree | 2e9b9fd4d726527b8dd80a89408de1a10d6bb8d0 | |
parent | 00409d788cf80111b0b355243fa4033f659e2c57 (diff) | |
download | chromium_src-27eb8ba72f233cdd1f53d24aa97c059de3d19f1b.zip chromium_src-27eb8ba72f233cdd1f53d24aa97c059de3d19f1b.tar.gz chromium_src-27eb8ba72f233cdd1f53d24aa97c059de3d19f1b.tar.bz2 |
Handle gamepad length being incorrectly set to 0 even when gamepad is present
When Windows sends device changed event multiple times even when a single
gamepad is connected, EnumerateDevices incorrectly sets gamepad length to zero.
BUG=485507
TBR=scottmg, raymes
Review URL: https://codereview.chromium.org/1145063004
Cr-Commit-Position: refs/heads/master@{#331822}
(cherry picked from commit bc4f7fa505a2d59a434d8a164043210a960d9be9)
Review URL: https://codereview.chromium.org/1188713009.
Cr-Commit-Position: refs/branch-heads/2357@{#478}
Cr-Branched-From: 59d4494849b405682265ed5d3f5164573b9a939b-refs/heads/master@{#323860}
-rw-r--r-- | content/browser/gamepad/gamepad_platform_data_fetcher_win.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc b/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc index c563cff..aca00960 100644 --- a/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc +++ b/content/browser/gamepad/gamepad_platform_data_fetcher_win.cc @@ -97,7 +97,6 @@ void GamepadPlatformDataFetcherWin::EnumerateDevices( WebGamepads* pads) { TRACE_EVENT0("GAMEPAD", "EnumerateDevices"); - pads->length = 0; // Mark all disconnected pads DISCONNECTED. for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { if (!pads->items[i].connected) @@ -115,7 +114,6 @@ void GamepadPlatformDataFetcherWin::EnumerateDevices( pad_state_[pad_index].status = XINPUT_CONNECTED; pad_state_[pad_index].xinput_index = i; pad_state_[pad_index].mapper = NULL; - pads->length++; } } @@ -151,7 +149,6 @@ void GamepadPlatformDataFetcherWin::EnumerateDevices( else pad.mapping[0] = 0; - pads->length++; } } } @@ -177,6 +174,7 @@ void GamepadPlatformDataFetcherWin::GetGamepadData(WebGamepads* pads, if (devices_changed_hint) EnumerateDevices(pads); + pads->length = 0; for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { // We rely on device_changed and GetCapabilities to tell us that // something's been connected, but we will mark as disconnected if @@ -188,6 +186,9 @@ void GamepadPlatformDataFetcherWin::GetGamepadData(WebGamepads* pads, GetXInputPadData(i, &pads->items[i]); else if (pad_state_[i].status == RAWINPUT_CONNECTED) GetRawInputPadData(i, &pads->items[i]); + + if (pads->items[i].connected) + pads->length++; } } |