OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_win.h" | 5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_win.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "content/common/gamepad_hardware_buffer.h" | 10 #include "content/common/gamepad_hardware_buffer.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 pad_state_[i].raw_input_handle == handle) | 90 pad_state_[i].raw_input_handle == handle) |
91 return true; | 91 return true; |
92 } | 92 } |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
96 void GamepadPlatformDataFetcherWin::EnumerateDevices( | 96 void GamepadPlatformDataFetcherWin::EnumerateDevices( |
97 WebGamepads* pads) { | 97 WebGamepads* pads) { |
98 TRACE_EVENT0("GAMEPAD", "EnumerateDevices"); | 98 TRACE_EVENT0("GAMEPAD", "EnumerateDevices"); |
99 | 99 |
| 100 pads->length = 0; |
100 // Mark all disconnected pads DISCONNECTED. | 101 // Mark all disconnected pads DISCONNECTED. |
101 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 102 for (size_t i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
102 if (!pads->items[i].connected) | 103 if (!pads->items[i].connected) |
103 pad_state_[i].status = DISCONNECTED; | 104 pad_state_[i].status = DISCONNECTED; |
104 } | 105 } |
105 | 106 |
106 for (size_t i = 0; i < XUSER_MAX_COUNT; ++i) { | 107 for (size_t i = 0; i < XUSER_MAX_COUNT; ++i) { |
107 if (HasXInputGamepad(i)) | 108 if (HasXInputGamepad(i)) |
108 continue; | 109 continue; |
109 int pad_index = FirstAvailableGamepadId(); | 110 int pad_index = FirstAvailableGamepadId(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 return false; | 314 return false; |
314 xinput_get_state_ = reinterpret_cast<XInputGetStateFunc>( | 315 xinput_get_state_ = reinterpret_cast<XInputGetStateFunc>( |
315 xinput_dll_.GetFunctionPointer("XInputGetState")); | 316 xinput_dll_.GetFunctionPointer("XInputGetState")); |
316 if (!xinput_get_state_) | 317 if (!xinput_get_state_) |
317 return false; | 318 return false; |
318 xinput_enable_(true); | 319 xinput_enable_(true); |
319 return true; | 320 return true; |
320 } | 321 } |
321 | 322 |
322 } // namespace content | 323 } // namespace content |
OLD | NEW |