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