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_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
7 | 7 |
8 #include <stddef.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/compiler_specific.h" | |
13 #include "base/macros.h" | 8 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
15 #include "content/browser/gamepad/gamepad_data_fetcher.h" | 10 #include "content/browser/gamepad/gamepad_data_fetcher.h" |
16 | 11 |
17 extern "C" { | 12 extern "C" { |
18 struct udev_device; | 13 struct udev_device; |
19 } | 14 } |
20 | 15 |
21 namespace content { | 16 namespace content { |
22 | 17 |
23 class UdevLinux; | 18 class UdevLinux; |
24 | 19 |
25 class GamepadPlatformDataFetcherLinux : public GamepadDataFetcher { | 20 class GamepadPlatformDataFetcherLinux : public GamepadDataFetcher { |
26 public: | 21 public: |
27 GamepadPlatformDataFetcherLinux(); | 22 GamepadPlatformDataFetcherLinux(); |
28 ~GamepadPlatformDataFetcherLinux() override; | 23 ~GamepadPlatformDataFetcherLinux() override; |
29 | 24 |
30 // GamepadDataFetcher implementation. | 25 // GamepadDataFetcher implementation. |
31 void GetGamepadData(blink::WebGamepads* pads, | 26 void GetGamepadData(bool devices_changed_hint) override; |
32 bool devices_changed_hint) override; | |
33 | 27 |
34 private: | 28 private: |
| 29 void OnAddedToProvider() override; |
| 30 |
35 void RefreshDevice(udev_device* dev); | 31 void RefreshDevice(udev_device* dev); |
36 void EnumerateDevices(); | 32 void EnumerateDevices(); |
37 void ReadDeviceData(size_t index); | 33 void ReadDeviceData(size_t index); |
38 | 34 |
39 // File descriptor for the /dev/input/js* devices. -1 if not in use. | 35 // File descriptor for the /dev/input/js* devices. -1 if not in use. |
40 int device_fd_[blink::WebGamepads::itemsLengthCap]; | 36 int device_fd_[blink::WebGamepads::itemsLengthCap]; |
41 | 37 |
42 scoped_ptr<UdevLinux> udev_; | 38 scoped_ptr<UdevLinux> udev_; |
43 | 39 |
44 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); | 40 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); |
45 }; | 41 }; |
46 | 42 |
47 } // namespace content | 43 } // namespace content |
48 | 44 |
49 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 45 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
OLD | NEW |