Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: content/browser/gamepad/raw_input_data_fetcher_win.cc

Issue 1950883002: Fix button 1 being stuck down on certain Logitech gamepads on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/raw_input_data_fetcher_win.h" 5 #include "content/browser/gamepad/raw_input_data_fetcher_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 16 matching lines...) Expand all
27 27
28 // From the HID Usage Tables specification. 28 // From the HID Usage Tables specification.
29 USHORT DeviceUsages[] = { 29 USHORT DeviceUsages[] = {
30 0x04, // Joysticks 30 0x04, // Joysticks
31 0x05, // Gamepads 31 0x05, // Gamepads
32 0x08, // Multi Axis 32 0x08, // Multi Axis
33 }; 33 };
34 34
35 const uint32_t kAxisMinimumUsageNumber = 0x30; 35 const uint32_t kAxisMinimumUsageNumber = 0x30;
36 const uint32_t kGameControlsUsagePage = 0x05; 36 const uint32_t kGameControlsUsagePage = 0x05;
37 const uint32_t kButtonUsagePage = 0x09;
37 38
38 } // namespace 39 } // namespace
39 40
40 RawGamepadInfo::RawGamepadInfo() { 41 RawGamepadInfo::RawGamepadInfo() {
41 } 42 }
42 43
43 RawGamepadInfo::~RawGamepadInfo() { 44 RawGamepadInfo::~RawGamepadInfo() {
44 } 45 }
45 46
46 RawInputDataFetcher::RawInputDataFetcher() 47 RawInputDataFetcher::RawInputDataFetcher()
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Query button information. 290 // Query button information.
290 USHORT count = caps.NumberInputButtonCaps; 291 USHORT count = caps.NumberInputButtonCaps;
291 if (count > 0) { 292 if (count > 0) {
292 std::unique_ptr<HIDP_BUTTON_CAPS[]> button_caps( 293 std::unique_ptr<HIDP_BUTTON_CAPS[]> button_caps(
293 new HIDP_BUTTON_CAPS[count]); 294 new HIDP_BUTTON_CAPS[count]);
294 status = hidp_get_button_caps_( 295 status = hidp_get_button_caps_(
295 HidP_Input, button_caps.get(), &count, gamepad_info->preparsed_data); 296 HidP_Input, button_caps.get(), &count, gamepad_info->preparsed_data);
296 DCHECK_EQ(HIDP_STATUS_SUCCESS, status); 297 DCHECK_EQ(HIDP_STATUS_SUCCESS, status);
297 298
298 for (uint32_t i = 0; i < count; ++i) { 299 for (uint32_t i = 0; i < count; ++i) {
299 if (button_caps[i].Range.UsageMin <= WebGamepad::buttonsLengthCap) { 300 if (button_caps[i].Range.UsageMin <= WebGamepad::buttonsLengthCap &&
301 button_caps[i].UsagePage == kButtonUsagePage) {
300 uint32_t max_index = 302 uint32_t max_index =
301 std::min(WebGamepad::buttonsLengthCap, 303 std::min(WebGamepad::buttonsLengthCap,
302 static_cast<size_t>(button_caps[i].Range.UsageMax)); 304 static_cast<size_t>(button_caps[i].Range.UsageMax));
303 gamepad_info->buttons_length = std::max( 305 gamepad_info->buttons_length = std::max(
304 gamepad_info->buttons_length, max_index); 306 gamepad_info->buttons_length, max_index);
305 } 307 }
306 } 308 }
307 } 309 }
308 310
309 // Query axis information. 311 // Query axis information.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 usages.get(), 390 usages.get(),
389 &buttons_length, 391 &buttons_length,
390 gamepad_info->preparsed_data, 392 gamepad_info->preparsed_data,
391 reinterpret_cast<PCHAR>(input->data.hid.bRawData), 393 reinterpret_cast<PCHAR>(input->data.hid.bRawData),
392 input->data.hid.dwSizeHid); 394 input->data.hid.dwSizeHid);
393 395
394 if (status == HIDP_STATUS_SUCCESS) { 396 if (status == HIDP_STATUS_SUCCESS) {
395 // Set each reported button to true. 397 // Set each reported button to true.
396 for (uint32_t j = 0; j < buttons_length; j++) { 398 for (uint32_t j = 0; j < buttons_length; j++) {
397 int32_t button_index = usages[j].Usage - 1; 399 int32_t button_index = usages[j].Usage - 1;
398 if (button_index >= 0 && 400 if (usages[j].UsagePage == kButtonUsagePage &&
401 button_index >= 0 &&
399 button_index < 402 button_index <
400 static_cast<int>(blink::WebGamepad::buttonsLengthCap)) { 403 static_cast<int>(blink::WebGamepad::buttonsLengthCap)) {
401 gamepad_info->buttons[button_index] = true; 404 gamepad_info->buttons[button_index] = true;
402 } 405 }
403 } 406 }
404 } 407 }
405 } 408 }
406 409
407 // Query axis state. 410 // Query axis state.
408 ULONG axis_value = 0; 411 ULONG axis_value = 0;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 return false; 523 return false;
521 hidd_get_product_string_ = reinterpret_cast<HidDGetStringFunc>( 524 hidd_get_product_string_ = reinterpret_cast<HidDGetStringFunc>(
522 hid_dll_.GetFunctionPointer("HidD_GetProductString")); 525 hid_dll_.GetFunctionPointer("HidD_GetProductString"));
523 if (!hidd_get_product_string_) 526 if (!hidd_get_product_string_)
524 return false; 527 return false;
525 528
526 return true; 529 return true;
527 } 530 }
528 531
529 } // namespace content 532 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698