OLD | NEW |
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 #ifndef CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 5 #ifndef CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
6 #define CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 6 #define CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // GamepadDataFetcher: | 33 // GamepadDataFetcher: |
34 virtual void GetGamepadData(WebKit::WebGamepads* pads, | 34 virtual void GetGamepadData(WebKit::WebGamepads* pads, |
35 bool devices_changed_hint) OVERRIDE; | 35 bool devices_changed_hint) OVERRIDE; |
36 | 36 |
37 // base::MessagePump:Libevent::Watcher: | 37 // base::MessagePump:Libevent::Watcher: |
38 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 38 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
39 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 39 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
40 | 40 |
41 private: | 41 private: |
42 bool IsGamepad(udev_device* dev, int* index, std::string* path); | |
43 void RefreshDevice(udev_device* dev); | 42 void RefreshDevice(udev_device* dev); |
44 void EnumerateDevices(); | 43 void EnumerateDevices(); |
45 void ReadDeviceData(size_t index); | 44 void ReadDeviceData(size_t index); |
46 | 45 |
47 // libudev-related items, the main context, and the monitoring context to be | 46 // libudev-related items, the main context, and the monitoring context to be |
48 // notified about changes to device states. | 47 // notified about changes to device states. |
49 udev* udev_; | 48 udev* udev_; |
50 udev_monitor* monitor_; | 49 udev_monitor* monitor_; |
51 int monitor_fd_; | 50 int monitor_fd_; |
52 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; | 51 base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_; |
53 | 52 |
54 // File descriptors for the /dev/input/js* devices. -1 if not in use. | 53 // File descriptors for the /dev/input/js* devices. -1 if not in use. |
55 int device_fds_[WebKit::WebGamepads::itemsLengthCap]; | 54 int device_fds_[WebKit::WebGamepads::itemsLengthCap]; |
56 | 55 |
57 // Functions to map from device data to standard layout, if available. May | 56 // Functions to map from device data to standard layout, if available. May |
58 // be null if no mapping is available. | 57 // be null if no mapping is available. |
59 GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap]; | 58 GamepadStandardMappingFunction mappers_[WebKit::WebGamepads::itemsLengthCap]; |
60 | 59 |
61 // Data that's returned to the consumer. | 60 // Data that's returned to the consumer. |
62 WebKit::WebGamepads data_; | 61 WebKit::WebGamepads data_; |
63 | 62 |
64 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); | 63 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); |
65 }; | 64 }; |
66 | 65 |
67 } // namespace content | 66 } // namespace content |
68 | 67 |
69 #endif // CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 68 #endif // CONTENT_BROWSER_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
OLD | NEW |