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

Side by Side Diff: components/exo/gamepad.h

Issue 2076013002: exo: Implement wayland gamepad support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serv
Patch Set: more missing deps. I wonder why these do not come up during pre-submit 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
« no previous file with comments | « components/exo/DEPS ('k') | components/exo/gamepad.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 COMPONENTS_EXO_GAMEPAD_H_
6 #define COMPONENTS_EXO_GAMEPAD_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/sequenced_task_runner.h"
13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread.h"
15 #include "base/threading/thread_task_runner_handle.h"
16 #include "device/gamepad/gamepad_data_fetcher.h"
17 #include "ui/aura/client/focus_change_observer.h"
18
19 namespace exo {
20 class GamepadDelegate;
21
22 using CreateGamepadDataFetcherCallback =
23 base::Callback<std::unique_ptr<device::GamepadDataFetcher>()>;
24
25 // This class represents one or more gamepads, it uses a background thread
26 // for polling gamepad devices and notifies the GamepadDelegate of any
27 // changes.
28 class Gamepad : public aura::client::FocusChangeObserver {
29 public:
30 // This class will post tasks to invoke the delegate on the thread runner
31 // which is associated with the thread that is creating this instance.
32 Gamepad(GamepadDelegate* delegate,
33 base::SingleThreadTaskRunner* polling_task_runner);
34 // Allows test cases to specify a CreateGamepadDataFetcherCallback that
35 // overrides the default GamepadPlatformDataFetcher.
36 Gamepad(GamepadDelegate* delegate,
37 base::SingleThreadTaskRunner* polling_task_runner,
38 CreateGamepadDataFetcherCallback create_fetcher_callback);
39 ~Gamepad() override;
40
41 // Overridden aura::client::FocusChangeObserver:
42 void OnWindowFocused(aura::Window* gained_focus,
43 aura::Window* lost_focus) override;
44
45 private:
46 class ThreadSafeGamepadChangeFetcher;
47
48 // Processes updates of gamepad data and passes changes on to delegate.
49 void ProcessGamepadChanges(const blink::WebGamepad new_pad);
50
51 // Private implementation of methods and resources that are used on the
52 // polling thread.
53 scoped_refptr<ThreadSafeGamepadChangeFetcher> gamepad_change_fetcher_;
54
55 // The delegate instance that all events are dispatched to.
56 GamepadDelegate* const delegate_;
57
58 // The current state of the gamepad represented by this instance.
59 blink::WebGamepad pad_state_;
60
61 // ThreadChecker for the origin thread.
62 base::ThreadChecker thread_checker_;
63
64 base::WeakPtrFactory<Gamepad> weak_factory_;
65
66 DISALLOW_COPY_AND_ASSIGN(Gamepad);
67 };
68
69 } // namespace exo
70
71 #endif // COMPONENTS_EXO_GAMEPAD_H_
OLDNEW
« no previous file with comments | « components/exo/DEPS ('k') | components/exo/gamepad.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698