| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
| 6 * | 6 * |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 23 * DAMAGE. | 23 * DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef Gamepad_h | 26 #ifndef Gamepad_h |
| 27 #define Gamepad_h | 27 #define Gamepad_h |
| 28 | 28 |
| 29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
| 30 #include "heap/Handle.h" | 30 #include "heap/Handle.h" |
| 31 #include "modules/gamepad/GamepadButton.h" |
| 31 #include "wtf/RefCounted.h" | 32 #include "wtf/RefCounted.h" |
| 32 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
| 33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 34 | 35 |
| 35 namespace WebCore { | 36 namespace WebCore { |
| 36 | 37 |
| 37 class Gamepad: public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public
ScriptWrappable { | 38 class Gamepad: public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public
ScriptWrappable { |
| 38 DECLARE_GC_INFO; | 39 DECLARE_GC_INFO; |
| 39 public: | 40 public: |
| 40 static PassRefPtrWillBeRawPtr<Gamepad> create() | 41 static PassRefPtrWillBeRawPtr<Gamepad> create() |
| 41 { | 42 { |
| 42 return adoptRefWillBeNoop(new Gamepad); | 43 return adoptRefWillBeNoop(new Gamepad); |
| 43 } | 44 } |
| 44 ~Gamepad(); | 45 ~Gamepad(); |
| 45 | 46 |
| 46 typedef Vector<float> FloatVector; | 47 typedef Vector<float> FloatVector; |
| 48 typedef Vector<GamepadButton> ButtonVector; |
| 47 | 49 |
| 48 const String& id() const { return m_id; } | 50 const String& id() const { return m_id; } |
| 49 void id(const String& id) { m_id = id; } | 51 void id(const String& id) { m_id = id; } |
| 50 | 52 |
| 51 unsigned index() const { return m_index; } | 53 unsigned index() const { return m_index; } |
| 52 void index(unsigned val) { m_index = val; } | 54 void index(unsigned val) { m_index = val; } |
| 53 | 55 |
| 56 bool connected() const { return m_connected; } |
| 57 void connected(const bool val) { m_connected = val; } |
| 58 |
| 54 unsigned long long timestamp() const { return m_timestamp; } | 59 unsigned long long timestamp() const { return m_timestamp; } |
| 55 void timestamp(unsigned long long val) { m_timestamp = val; } | 60 void timestamp(unsigned long long val) { m_timestamp = val; } |
| 56 | 61 |
| 62 const String& mapping() const { return m_mapping; } |
| 63 void mapping(const String& val) { m_mapping = val; } |
| 64 |
| 57 const FloatVector& axes() const { return m_axes; } | 65 const FloatVector& axes() const { return m_axes; } |
| 58 void axes(unsigned count, float* data); | 66 void axes(unsigned count, float* data); |
| 59 | 67 |
| 60 const FloatVector& buttons() const { return m_buttons; } | 68 const GamepadButtonVector& buttons() const { return m_buttons; } |
| 61 void buttons(unsigned count, float* data); | 69 void buttons(unsigned count, float* data); |
| 62 | 70 |
| 63 void trace(Visitor*); | 71 void trace(Visitor*); |
| 64 | 72 |
| 65 private: | 73 private: |
| 66 Gamepad(); | 74 Gamepad(); |
| 67 String m_id; | 75 String m_id; |
| 68 unsigned m_index; | 76 unsigned m_index; |
| 77 bool m_connected; |
| 69 unsigned long long m_timestamp; | 78 unsigned long long m_timestamp; |
| 79 String m_mapping; |
| 70 FloatVector m_axes; | 80 FloatVector m_axes; |
| 71 FloatVector m_buttons; | 81 GamepadButtonVector m_buttons; |
| 72 }; | 82 }; |
| 73 | 83 |
| 74 } // namespace WebCore | 84 } // namespace WebCore |
| 75 | 85 |
| 76 #endif // Gamepad_h | 86 #endif // Gamepad_h |
| OLD | NEW |