Index: device/gamepad/gamepad_platform_data_fetcher_linux.cc |
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc b/device/gamepad/gamepad_platform_data_fetcher_linux.cc |
similarity index 76% |
rename from content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc |
rename to device/gamepad/gamepad_platform_data_fetcher_linux.cc |
index 87ec3714b66ea44df8be0ee549f53ce6247c043d..4781a8f7fac8b800709fc2922e2e45628691ee98 100644 |
--- a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc |
+++ b/device/gamepad/gamepad_platform_data_fetcher_linux.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/gamepad/gamepad_platform_data_fetcher_linux.h" |
+#include "device/gamepad/gamepad_platform_data_fetcher_linux.h" |
#include <fcntl.h> |
#include <linux/joystick.h> |
@@ -43,8 +43,8 @@ bool IsGamepad(udev_device* dev, int* index, std::string* path) { |
return false; |
static const char kJoystickRoot[] = "/dev/input/js"; |
- bool is_gamepad = base::StartsWith(node_path, kJoystickRoot, |
- base::CompareCase::SENSITIVE); |
+ bool is_gamepad = |
+ base::StartsWith(node_path, kJoystickRoot, base::CompareCase::SENSITIVE); |
if (!is_gamepad) |
return false; |
@@ -64,7 +64,7 @@ bool IsGamepad(udev_device* dev, int* index, std::string* path) { |
} // namespace |
-namespace content { |
+namespace device { |
using blink::WebGamepad; |
using blink::WebGamepads; |
@@ -77,10 +77,9 @@ GamepadPlatformDataFetcherLinux::GamepadPlatformDataFetcherLinux() { |
pad_state_[i].button_mask = 0; |
} |
- std::vector<device::UdevLinux::UdevMonitorFilter> filters; |
- filters.push_back( |
- device::UdevLinux::UdevMonitorFilter(kInputSubsystem, NULL)); |
- udev_.reset(new device::UdevLinux( |
+ std::vector<UdevLinux::UdevMonitorFilter> filters; |
+ filters.push_back(UdevLinux::UdevMonitorFilter(kInputSubsystem, NULL)); |
+ udev_.reset(new UdevLinux( |
filters, base::Bind(&GamepadPlatformDataFetcherLinux::RefreshDevice, |
base::Unretained(this)))); |
@@ -112,7 +111,7 @@ void GamepadPlatformDataFetcherLinux::GetGamepadData(WebGamepads* pads, bool) { |
void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
int index; |
std::string node_path; |
- if (IsGamepad(dev, &index, &node_path)) { |
+ if (IsGamepad(dev, &index, &node_path)) { |
int& device_fd = device_fd_[index]; |
WebGamepad& pad = pad_state_[index].data; |
GamepadStandardMappingFunction& mapper = pad_state_[index].mapper; |
@@ -123,8 +122,8 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
// joystick device. In order to get the information about the physical |
// hardware, get the parent device that is also in the "input" subsystem. |
// This function should just walk up the tree one level. |
- dev = device::udev_device_get_parent_with_subsystem_devtype( |
- dev, kInputSubsystem, NULL); |
+ dev = udev_device_get_parent_with_subsystem_devtype(dev, kInputSubsystem, |
+ NULL); |
if (!dev) { |
// Unable to get device information, don't use this device. |
device_fd = -1; |
@@ -139,36 +138,32 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
return; |
} |
- const char* vendor_id = |
- device::udev_device_get_sysattr_value(dev, "id/vendor"); |
- const char* product_id = |
- device::udev_device_get_sysattr_value(dev, "id/product"); |
+ const char* vendor_id = udev_device_get_sysattr_value(dev, "id/vendor"); |
+ const char* product_id = udev_device_get_sysattr_value(dev, "id/product"); |
mapper = GetGamepadStandardMappingFunction(vendor_id, product_id); |
// Driver returns utf-8 strings here, so combine in utf-8 first and |
// convert to WebUChar later once we've picked an id string. |
- const char* name = device::udev_device_get_sysattr_value(dev, "name"); |
+ const char* name = udev_device_get_sysattr_value(dev, "name"); |
std::string name_string(name); |
// In many cases the information the input subsystem contains isn't |
// as good as the information that the device bus has, walk up further |
// to the subsystem/device type "usb"/"usb_device" and if this device |
// has the same vendor/product id, prefer the description from that. |
- struct udev_device* usb_dev = |
- device::udev_device_get_parent_with_subsystem_devtype( |
- dev, kUsbSubsystem, kUsbDeviceType); |
+ struct udev_device* usb_dev = udev_device_get_parent_with_subsystem_devtype( |
+ dev, kUsbSubsystem, kUsbDeviceType); |
if (usb_dev) { |
const char* usb_vendor_id = |
- device::udev_device_get_sysattr_value(usb_dev, "idVendor"); |
+ udev_device_get_sysattr_value(usb_dev, "idVendor"); |
const char* usb_product_id = |
- device::udev_device_get_sysattr_value(usb_dev, "idProduct"); |
+ udev_device_get_sysattr_value(usb_dev, "idProduct"); |
if (strcmp(vendor_id, usb_vendor_id) == 0 && |
strcmp(product_id, usb_product_id) == 0) { |
const char* manufacturer = |
- device::udev_device_get_sysattr_value(usb_dev, "manufacturer"); |
- const char* product = |
- device::udev_device_get_sysattr_value(usb_dev, "product"); |
+ udev_device_get_sysattr_value(usb_dev, "manufacturer"); |
+ const char* product = udev_device_get_sysattr_value(usb_dev, "product"); |
// Replace the previous name string with one containing the better |
// information, again driver returns utf-8 strings here so combine |
@@ -182,8 +177,7 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
std::string id = |
name_string + base::StringPrintf(" (%sVendor: %s Product: %s)", |
mapper ? "STANDARD GAMEPAD " : "", |
- vendor_id, |
- product_id); |
+ vendor_id, product_id); |
base::TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id); |
base::string16 tmp16 = base::UTF8ToUTF16(id); |
memset(pad.id, 0, sizeof(pad.id)); |
@@ -191,8 +185,8 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
if (mapper) { |
std::string mapping = "standard"; |
- base::TruncateUTF8ToByteSize( |
- mapping, WebGamepad::mappingLengthCap - 1, &mapping); |
+ base::TruncateUTF8ToByteSize(mapping, WebGamepad::mappingLengthCap - 1, |
+ &mapping); |
tmp16 = base::UTF8ToUTF16(mapping); |
memset(pad.mapping, 0, sizeof(pad.mapping)); |
tmp16.copy(pad.mapping, arraysize(pad.mapping) - 1); |
@@ -208,27 +202,25 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) { |
} |
void GamepadPlatformDataFetcherLinux::EnumerateDevices() { |
- device::ScopedUdevEnumeratePtr enumerate( |
- device::udev_enumerate_new(udev_->udev_handle())); |
+ ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev_->udev_handle())); |
if (!enumerate) |
return; |
- int ret = device::udev_enumerate_add_match_subsystem(enumerate.get(), |
- kInputSubsystem); |
+ int ret = |
+ udev_enumerate_add_match_subsystem(enumerate.get(), kInputSubsystem); |
if (ret != 0) |
return; |
- ret = device::udev_enumerate_scan_devices(enumerate.get()); |
+ ret = udev_enumerate_scan_devices(enumerate.get()); |
if (ret != 0) |
return; |
- udev_list_entry* devices = |
- device::udev_enumerate_get_list_entry(enumerate.get()); |
+ udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate.get()); |
for (udev_list_entry* dev_list_entry = devices; dev_list_entry != NULL; |
- dev_list_entry = device::udev_list_entry_get_next(dev_list_entry)) { |
+ dev_list_entry = udev_list_entry_get_next(dev_list_entry)) { |
// Get the filename of the /sys entry for the device and create a |
// udev_device object (dev) representing it |
- const char* path = device::udev_list_entry_get_name(dev_list_entry); |
- device::ScopedUdevDevicePtr dev( |
- device::udev_device_new_from_syspath(udev_->udev_handle(), path)); |
+ const char* path = udev_list_entry_get_name(dev_list_entry); |
+ ScopedUdevDevicePtr dev( |
+ udev_device_new_from_syspath(udev_->udev_handle(), path)); |
if (!dev) |
continue; |
RefreshDevice(dev.get()); |
@@ -271,4 +263,4 @@ void GamepadPlatformDataFetcherLinux::ReadDeviceData(size_t index) { |
} |
} |
-} // namespace content |
+} // namespace device |