OLD | NEW |
(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_DELEGATE_H_ |
| 6 #define COMPONENTS_EXO_GAMEPAD_DELEGATE_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 |
| 10 namespace exo { |
| 11 class Gamepad; |
| 12 class Surface; |
| 13 |
| 14 // Handles events on multiple gamepad |
| 15 class GamepadDelegate { |
| 16 public: |
| 17 // Gives the delegate a chance to clean up when the Gamepad instance is |
| 18 // destroyed. |
| 19 virtual void OnGamepadDestroying(Gamepad* gamepad) = 0; |
| 20 |
| 21 // This should return true if |surface| is a valid target for this gamepad. |
| 22 // E.g. the surface is owned by the same client as the gamepad. |
| 23 virtual bool CanAcceptGamepadEventsForSurface(Surface* surface) const = 0; |
| 24 |
| 25 // Called when the state of the gamepad has changed. |
| 26 virtual void OnStateChange(bool connected) = 0; |
| 27 |
| 28 // Called when the user moved an axis of the gamepad. Valid axes are defined |
| 29 // by the W3C 'standard gamepad' specification. |
| 30 virtual void OnAxis(int axis, double value) = 0; |
| 31 |
| 32 // Called when the user pressed or moved a button of the gamepad. |
| 33 // Valid buttons are defined by the W3C 'standard gamepad' specification. |
| 34 virtual void OnButton(int button, bool pressed, double value) = 0; |
| 35 |
| 36 // Called after all gamepad information of this frame has been set and the |
| 37 // client should evaluate the updated state. |
| 38 virtual void OnFrame() = 0; |
| 39 |
| 40 protected: |
| 41 virtual ~GamepadDelegate() {} |
| 42 }; |
| 43 |
| 44 } // namespace exo |
| 45 |
| 46 #endif // COMPONENTS_EXO_GAMEPAD_DELEGATE_H_ |
OLD | NEW |