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

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

Issue 1242023005: Remove legacy StartsWithASCII function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: y Created 5 years, 5 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
OLDNEW
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_linux.h" 5 #include "content/browser/gamepad/gamepad_platform_data_fetcher_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/joystick.h> 8 #include <linux/joystick.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 24 matching lines...) Expand all
35 35
36 bool IsGamepad(udev_device* dev, int* index, std::string* path) { 36 bool IsGamepad(udev_device* dev, int* index, std::string* path) {
37 if (!device::udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK")) 37 if (!device::udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"))
38 return false; 38 return false;
39 39
40 const char* node_path = device::udev_device_get_devnode(dev); 40 const char* node_path = device::udev_device_get_devnode(dev);
41 if (!node_path) 41 if (!node_path)
42 return false; 42 return false;
43 43
44 static const char kJoystickRoot[] = "/dev/input/js"; 44 static const char kJoystickRoot[] = "/dev/input/js";
45 bool is_gamepad = base::StartsWithASCII(node_path, kJoystickRoot, true); 45 bool is_gamepad = base::StartsWith(node_path, kJoystickRoot,
46 base::CompareCase::SENSITIVE);
46 if (!is_gamepad) 47 if (!is_gamepad)
47 return false; 48 return false;
48 49
49 int tmp_idx = -1; 50 int tmp_idx = -1;
50 const int base_len = sizeof(kJoystickRoot) - 1; 51 const int base_len = sizeof(kJoystickRoot) - 1;
51 base::StringPiece str(&node_path[base_len], strlen(node_path) - base_len); 52 base::StringPiece str(&node_path[base_len], strlen(node_path) - base_len);
52 if (!base::StringToInt(str, &tmp_idx)) 53 if (!base::StringToInt(str, &tmp_idx))
53 return false; 54 return false;
54 if (tmp_idx < 0 || 55 if (tmp_idx < 0 ||
55 tmp_idx >= static_cast<int>(blink::WebGamepads::itemsLengthCap)) { 56 tmp_idx >= static_cast<int>(blink::WebGamepads::itemsLengthCap)) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 pad.buttons[item].pressed = event.value; 261 pad.buttons[item].pressed = event.value;
261 pad.buttons[item].value = event.value ? 1.0 : 0.0; 262 pad.buttons[item].value = event.value ? 1.0 : 0.0;
262 if (item >= pad.buttonsLength) 263 if (item >= pad.buttonsLength)
263 pad.buttonsLength = item + 1; 264 pad.buttonsLength = item + 1;
264 } 265 }
265 pad.timestamp = event.time; 266 pad.timestamp = event.time;
266 } 267 }
267 } 268 }
268 269
269 } // namespace content 270 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.cc ('k') | content/browser/media/capture/web_contents_capture_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698