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

Side by Side 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: review fixes, mostly -> WatchFileDescriptor 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_
6 #define CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/message_pump_libevent.h"
12 #include "build/build_config.h"
13 #include "content/browser/gamepad/data_fetcher.h"
14 #include "content/browser/gamepad/gamepad_standard_mappings_linux.h"
15 #include "content/common/gamepad_hardware_buffer.h"
16
17 extern "C" {
18 struct udev;
19 struct udev_device;
20 struct udev_monitor;
21 }
22
23 namespace content {
24
25 class GamepadPlatformDataFetcherLinux :
26 public GamepadDataFetcher,
27 public base::MessagePumpLibevent::Watcher {
28 public:
29 GamepadPlatformDataFetcherLinux();
30
31 // GamepadDataFetcher:
32 virtual void GetGamepadData(WebKit::WebGamepads* pads,
33 bool devices_changed_hint) OVERRIDE;
34
35 // base::MessagePump:Libevent::Watcher:
36 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
37 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
38
39 private:
40 virtual ~GamepadPlatformDataFetcherLinux();
Ryan Sleevi 2011/12/19 22:51:58 BUG: Having this method be private means you canno
scottmg 2011/12/19 23:23:53 Done.
41 bool IsGamepad(udev_device* dev, size_t& index, std::string& path);
42 void RefreshDevice(udev_device* dev);
43 void EnumerateDevices();
44 void ReadDeviceData(size_t index);
45
46 // libudev-related items, the main context, and the monitoring context to be
47 // notified about changes to device states.
48 udev* udev_;
49 udev_monitor* monitor_;
50 int monitor_fd_;
51 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_;
52
53 // File descriptors for the /dev/input/js* devices. -1 if not in use.
54 int device_fds_[WebKit::WebGamepads::itemsLengthCap];
55
56 // Functions to map from device data to standard layout, if available. May
57 // be null if no mapping is available.
58 GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap];
59
60 // Data that's returned to the consumer.
61 WebKit::WebGamepads data_;
62 };
63
64 } // namespace content
65
66 #endif // CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698