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

Side by Side Diff: device/gamepad/gamepad_platform_data_fetcher_linux.h

Issue 2129003002: Refactored gamepad polling to support dynamic sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test issue and Mac XBoxDataFetcher constructor Created 4 years, 5 months 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
OLDNEW
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 GamepadPlatformDataFetcherLinux : public GamepadDataFetcher {
28 public: 28 public:
29 typedef GamepadDataFetcherFactoryImpl<GamepadPlatformDataFetcherLinux,
30 GAMEPAD_SOURCE_LINUX_UDEV>
31 Factory;
32
29 GamepadPlatformDataFetcherLinux(); 33 GamepadPlatformDataFetcherLinux();
30 ~GamepadPlatformDataFetcherLinux() override; 34 ~GamepadPlatformDataFetcherLinux() override;
31 35
36 GamepadSource source() override;
37
32 // GamepadDataFetcher implementation. 38 // GamepadDataFetcher implementation.
33 void GetGamepadData(blink::WebGamepads* pads, 39 void GetGamepadData(bool devices_changed_hint) override;
34 bool devices_changed_hint) override;
35 40
36 private: 41 private:
42 void OnAddedToProvider() override;
43
37 void RefreshDevice(udev_device* dev); 44 void RefreshDevice(udev_device* dev);
38 void EnumerateDevices(); 45 void EnumerateDevices();
39 void ReadDeviceData(size_t index); 46 void ReadDeviceData(size_t index);
40 47
41 // File descriptor for the /dev/input/js* devices. -1 if not in use. 48 // File descriptor for the /dev/input/js* devices. -1 if not in use.
42 int device_fd_[blink::WebGamepads::itemsLengthCap]; 49 int device_fd_[blink::WebGamepads::itemsLengthCap];
43 50
44 std::unique_ptr<device::UdevLinux> udev_; 51 std::unique_ptr<device::UdevLinux> udev_;
45 52
46 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux); 53 DISALLOW_COPY_AND_ASSIGN(GamepadPlatformDataFetcherLinux);
47 }; 54 };
48 55
49 } // namespace device 56 } // namespace device
50 57
51 #endif // DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_ 58 #endif // DEVICE_GAMEPAD_GAMEPAD_PLATFORM_DATA_FETCHER_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698