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

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: removed id from Gamepad and updated wording 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/sequenced_task_runner.h"
12 #include "base/threading/thread.h"
13 #include "base/threading/thread_task_runner_handle.h"
14 #include "device/gamepad/gamepad_data_fetcher.h"
15
16 namespace exo {
17 class GamepadDelegate;
18
19 // This class represents one or more gamepads, it implements a background thread
20 // for polling gamepad devices and notifies the GamepadDelegate of any
21 // changes.
22 class Gamepad {
23 public:
24 // This class will post tasks to invoke the delegate on the thread runner
25 // which is associated with the thread that is creating this instance.
26 Gamepad(GamepadDelegate* delegate);
reveman 2016/06/29 21:55:45 nit: explicit
denniskempin 2016/06/30 00:29:22 Done.
27
reveman 2016/06/29 21:55:45 nit: remove this blank line to ctors and dtor in o
denniskempin 2016/06/30 00:29:22 Done.
28 // Allows test cases to specify a GamepadDataFetcher to provide mock gamepad
29 // data.
30 Gamepad(GamepadDelegate* delegate,
31 std::unique_ptr<device::GamepadDataFetcher> fetcher);
32 virtual ~Gamepad();
33
34 private:
35 // Schedules a poll on the polling thread. Can be called from any thread.
36 void ScheduleOnPoll();
37
38 // Polls devices for new data and posts delegate updates.
39 // Can only be called on the polling thread.
40 void OnPoll();
41
42 // Posts updates of gamepad data to delegate.
43 // Can only be called on the polling thread.
44 void PostGamepadChanges(const blink::WebGamepads new_state);
45
46 // Initializes the underlying gamepad data fetcher.
47 // Can only be called on the polling thread.
48 void InitializePollingThread();
49
50 // The delegate instance that all events are dispatched to.
51 GamepadDelegate* const delegate_;
52
53 // Implements the logic to fetch gamepad information from connected devices.
54 std::unique_ptr<device::GamepadDataFetcher> fetcher_;
55
56 // The thread on which the polling is executed.
57 std::unique_ptr<base::Thread> polling_thread_;
58
59 // The current state of gamepad.
60 blink::WebGamepads state_;
61
62 // Reference to the task runner of the thread that created this instance.
63 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_;
64
65 base::ThreadChecker thread_checker_;
66
67 DISALLOW_COPY_AND_ASSIGN(Gamepad);
68 };
69
70 } // namespace exo
71
72 #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