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

Side by Side Diff: content/browser/gamepad/data_fetcher_linux.h

Issue 8899017: Add gamepad data fetcher for Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better so load 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 "build/build_config.h"
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/browser/gamepad/data_fetcher.h"
13 #include "content/browser/gamepad/gamepad_standard_mappings_linux.h"
14 #include "content/common/gamepad_hardware_buffer.h"
15
16 #include <libudev.h>
17 #include <string>
18
19 namespace content {
20
21 class LibUdevLateBound;
22
23 class GamepadDataFetcherLinux : public GamepadDataFetcher {
24 public:
25 GamepadDataFetcherLinux();
26 virtual void GetGamepadData(WebKit::WebGamepads* pads,
27 bool devices_changed_hint) OVERRIDE;
28 virtual ~GamepadDataFetcherLinux() OVERRIDE;
29
30 private:
31 // May be null if libudev could not be loaded, in which case all
32 // functionality is disabled.
33 scoped_ptr<LibUdevLateBound> udevlib_;
34
35 void EnumerateDevices();
36 void RefreshDevice(udev_device* dev);
37 bool IsGamepad(udev_device* dev, size_t& index, std::string& path);
38 void CheckForAddRemoveEvents();
39 void ReadDeviceData(size_t index);
40
41 // libudev-related items, the main context, and the monitoring context to be
42 // notified about changes to device states.
43 udev* udev_;
44 udev_monitor* monitor_;
45 int monitor_fd_;
46
47 // File descriptors for the /dev/input/js* devices. -1 if not in use.
48 int device_fds_[WebKit::WebGamepads::itemsLengthCap];
49
50 // Functions to map from device data to standard layout, if available. May
51 // be null if no mapping is available.
52 GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap];
53
54 // Data that's returned to the consumer.
55 WebKit::WebGamepads data_;
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_BROWSER_GAMEPAD_DATA_FETCHER_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698