| 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 GamepadPlatformDataFetcherLinux : public GamepadDataFetcher { | 27 class DEVICE_GAMEPAD_EXPORT GamepadPlatformDataFetcherLinux |
| 28 : public GamepadDataFetcher { |
| 28 public: | 29 public: |
| 29 GamepadPlatformDataFetcherLinux(); | 30 GamepadPlatformDataFetcherLinux(); |
| 30 ~GamepadPlatformDataFetcherLinux() override; | 31 ~GamepadPlatformDataFetcherLinux() override; |
| 31 | 32 |
| 32 // GamepadDataFetcher implementation. | 33 // GamepadDataFetcher implementation. |
| 33 void GetGamepadData(blink::WebGamepads* pads, | 34 void GetGamepadData(blink::WebGamepads* pads, |
| 34 bool devices_changed_hint) override; | 35 bool devices_changed_hint) override; |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 void RefreshDevice(udev_device* dev); | 38 void RefreshDevice(udev_device* dev); |
| 38 void EnumerateDevices(); | 39 void EnumerateDevices(); |
| 39 void ReadDeviceData(size_t index); | 40 void ReadDeviceData(size_t index); |
| 40 | 41 |
| 41 // File descriptor for the /dev/input/js* devices. -1 if not in use. | 42 // File descriptor for the /dev/input/js* devices. -1 if not in use. |
| 42 int device_fd_[blink::WebGamepads::itemsLengthCap]; | 43 int device_fd_[blink::WebGamepads::itemsLengthCap]; |
| 43 | 44 |
| 44 std::unique_ptr<device::UdevLinux> udev_; | 45 std::unique_ptr<device::UdevLinux> udev_; |
| 45 | 46 |
| 46 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); | 47 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 } // namespace device | 50 } // namespace device |
| 50 | 51 |
| 51 #endif // DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ | 52 #endif // DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ |
| OLD | NEW |