Chromium Code Reviews| Index: ui/events/ozone/gamepad/gamepad_provider_ozone.h |
| diff --git a/ui/events/ozone/gamepad/gamepad_provider_ozone.h b/ui/events/ozone/gamepad/gamepad_provider_ozone.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..42caf75ed5c83473066e665f7edd12f8c8f58b95 |
| --- /dev/null |
| +++ b/ui/events/ozone/gamepad/gamepad_provider_ozone.h |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_EVENTS_OZONE_GAMEPAD_GAMEPAD_PROVIDER_OZONE_H_ |
| +#define UI_EVENTS_OZONE_GAMEPAD_GAMEPAD_PROVIDER_OZONE_H_ |
| + |
| +#include <set> |
| +#include <vector> |
| +#include "base/macros.h" |
| +#include "base/time/time.h" |
| +#include "ui/events/devices/input_device.h" |
| +#include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| +#include "ui/events/ozone/gamepad/gamepad_observer.h" |
| + |
| +namespace base { |
| +template <typename T> |
| +struct DefaultSingletonTraits; |
| +} |
| + |
| +namespace ui { |
| + |
| +class EVENTS_OZONE_EVDEV_EXPORT GamepadProviderOzone { |
| + public: |
| + // Get the GamepadProviderOzone instance. |
| + static GamepadProviderOzone* GetInstance(); |
|
spang
2017/04/21 05:38:47
Can you get this through the existing OzonePlatfor
jkwang
2017/04/25 21:16:41
Will this result in a circular dependency? ui/ozon
|
| + |
| + // Dispatch GamepadDevicesUpdate event when gamepad device is connected or |
| + // disconnected. This function must be called on UI thread. |
| + void DispatchGamepadDevicesUpdated(std::vector<InputDevice> gamepad_devices); |
| + |
| + // Dispatch button event when gamepad event is seen. |
| + // Code is the index of gamepad button or gamepad axis defined in W3C standard |
| + // gamepad. |
| + // This function must be called on UI thread. |
| + void DispatchGamepadEvent(const GamepadEvent& event); |
| + |
| + // Add observer to gamepad provider. This function must be called on UI |
| + // thread. |
| + void AddGamepadObserver(GamepadObserver* observer); |
| + |
| + // Remove observer from gamepad provider. This function must be called on UI |
| + // thread. |
| + void RemoveGamepadObserver(GamepadObserver* observer); |
| + |
| + // Get the list of currently connected gamepad devices. This function must be |
| + // called on UI thread. |
| + std::vector<InputDevice> GetGamepadDevices(); |
| + |
| + private: |
| + GamepadProviderOzone(); |
| + |
| + ~GamepadProviderOzone(); |
| + |
| + // Make SingletonTraits friend to enable singleton. |
| + friend struct base::DefaultSingletonTraits<GamepadProviderOzone>; |
| + |
| + // Registered observers will receive gamepad device update event and gamepad |
| + // event. |
| + std::set<GamepadObserver*> observers_; |
|
spang
2017/04/21 05:38:47
set is a binary search tree; this is overkill. Jus
jkwang
2017/04/25 21:16:41
Done.
|
| + |
| + // List of current connected gamepad events. |
| + std::vector<InputDevice> gamepad_devices_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GamepadProviderOzone); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_EVENTS_OZONE_GAMEPAD_GAMEPAD_PROVIDER_OZONE_H_ |