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

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: do not depend on webkit but device/gamepad 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
(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 a gamepad, 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(size_t id, GamepadDelegate* delegate);
27
28 // Allows test cases to specify a GamepadDataFetcher to provide mock gamepad
29 // data.
30 Gamepad(size_t id,
31 GamepadDelegate* delegate,
32 std::unique_ptr<device::GamepadDataFetcher> fetcher);
33 virtual ~Gamepad();
34
35 private:
36 // Schedules a poll on the polling thread. Can be called from any thread.
37 void ScheduleOnPoll();
38
39 // Polls devices for new data and posts delegate updates.
40 // Can only be called on the polling thread.
41 void OnPoll();
42
43 // Initializes the underlying gamepad data fetcher.
44 // Can only be called on the polling thread.
45 void InitializePollingThread();
46
47 // Gamepad id
48 size_t id_;
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') | components/exo/gamepad.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698