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

Unified Diff: content/browser/gamepad/platform_data_fetcher_linux.h

Issue 8899017: Add gamepad data fetcher for Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use system.gyp for udev dep Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/gamepad/platform_data_fetcher_linux.h
diff --git a/content/browser/gamepad/platform_data_fetcher_linux.h b/content/browser/gamepad/platform_data_fetcher_linux.h
new file mode 100644
index 0000000000000000000000000000000000000000..1912a531697019f09d33fa84228e1fbe93381ced
--- /dev/null
+++ b/content/browser/gamepad/platform_data_fetcher_linux.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_
+#define CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_
+
+#include "build/build_config.h"
+
+#include "base/compiler_specific.h"
+#include "content/browser/gamepad/data_fetcher.h"
+#include "content/browser/gamepad/gamepad_standard_mappings_linux.h"
+#include "content/common/gamepad_hardware_buffer.h"
+
+#include <string>
Ryan Sleevi 2011/12/17 04:31:14 random drive-by style nit: #include <string> befor
scottmg 2011/12/19 19:41:45 Done.
+extern "C" {
+struct udev;
+struct udev_device;
+struct udev_monitor;
+}
+
+namespace content {
+
+class GamepadPlatformDataFetcherLinux : public GamepadDataFetcher {
+ public:
+ GamepadPlatformDataFetcherLinux();
+ virtual void GetGamepadData(WebKit::WebGamepads* pads,
Ryan Sleevi 2011/12/17 04:31:14 style nit: Declare DTORs before methods http://go
scottmg 2011/12/19 19:41:45 Done.
+ bool devices_changed_hint) OVERRIDE;
+ virtual ~GamepadPlatformDataFetcherLinux() OVERRIDE;
+
+ private:
+ void EnumerateDevices();
+ void RefreshDevice(udev_device* dev);
+ bool IsGamepad(udev_device* dev, size_t& index, std::string& path);
+ void CheckForAddRemoveEvents();
+ void ReadDeviceData(size_t index);
+
+ // libudev-related items, the main context, and the monitoring context to be
+ // notified about changes to device states.
+ udev* udev_;
+ udev_monitor* monitor_;
+ int monitor_fd_;
+
+ // File descriptors for the /dev/input/js* devices. -1 if not in use.
+ int device_fds_[WebKit::WebGamepads::itemsLengthCap];
+
+ // Functions to map from device data to standard layout, if available. May
+ // be null if no mapping is available.
+ GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap];
+
+ // Data that's returned to the consumer.
+ WebKit::WebGamepads data_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_

Powered by Google App Engine
This is Rietveld 408576698