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

Side by Side Diff: ui/events/ozone/gamepad/gamepad_provider_ozone.h

Issue 2805793002: ozone: evdev: Add gamepad support (Closed)
Patch Set: Support Gamepad in Ozone. Created 3 years, 7 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_OZONE_GAMEPAD_GAMEPAD_PROVIDER_OZONE_H_
6 #define UI_EVENTS_OZONE_GAMEPAD_GAMEPAD_PROVIDER_OZONE_H_
7
8 #include <set>
9 #include <vector>
10 #include "base/macros.h"
11 #include "base/observer_list.h"
12 #include "base/time/time.h"
13 #include "ui/events/devices/input_device.h"
14 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
15 #include "ui/events/ozone/gamepad/gamepad_observer.h"
16
17 namespace base {
18 template <typename T>
19 struct DefaultSingletonTraits;
20 }
21
22 namespace ui {
23
24 class EVENTS_OZONE_EVDEV_EXPORT GamepadProviderOzone {
25 public:
26 // Get the GamepadProviderOzone instance.
27 static GamepadProviderOzone* GetInstance();
28
29 // Dispatch GamepadDevicesUpdate event when gamepad device is connected or
30 // disconnected. This function must be called on UI thread.
31 void DispatchGamepadDevicesUpdated(std::vector<InputDevice> gamepad_devices);
32
33 // Dispatch button event when gamepad event is seen.
34 // Code is the index of gamepad button or gamepad axis defined in W3C standard
35 // gamepad.
36 // This function must be called on UI thread.
37 void DispatchGamepadEvent(const GamepadEvent& event);
38
39 // Add observer to gamepad provider. This function must be called on UI
40 // thread.
41 void AddGamepadObserver(GamepadObserver* observer);
42
43 // Remove observer from gamepad provider. This function must be called on UI
44 // thread.
45 void RemoveGamepadObserver(GamepadObserver* observer);
46
47 // Get the list of currently connected gamepad devices. This function must be
48 // called on UI thread.
49 std::vector<InputDevice> GetGamepadDevices();
50
51 private:
52 GamepadProviderOzone();
53
54 ~GamepadProviderOzone();
55
56 // Make SingletonTraits friend to enable singleton.
57 friend struct base::DefaultSingletonTraits<GamepadProviderOzone>;
58
59 // Registered observers will receive gamepad device update event and gamepad
60 // event.
61 base::ObserverList<GamepadObserver> observers_;
62
63 // List of current connected gamepad events.
64 std::vector<InputDevice> gamepad_devices_;
65
66 DISALLOW_COPY_AND_ASSIGN(GamepadProviderOzone);
67 };
68
69 } // namespace ui
70
71 #endif // UI_EVENTS_OZONE_GAMEPAD_GAMEPAD_PROVIDER_OZONE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698