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" | |
32 #include "public/platform/WebGamepad.h" | |
33 #include "wtf/RefCounted.h" | 31 #include "wtf/RefCounted.h" |
34 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" |
35 #include "wtf/text/WTFString.h" | 33 #include "wtf/text/WTFString.h" |
36 | 34 |
37 namespace WebCore { | 35 namespace WebCore { |
38 | 36 |
39 class Gamepad: public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public
ScriptWrappable { | 37 class Gamepad: public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public
ScriptWrappable { |
40 DECLARE_GC_INFO; | 38 DECLARE_GC_INFO; |
41 public: | 39 public: |
42 static PassRefPtrWillBeRawPtr<Gamepad> create() | 40 static PassRefPtrWillBeRawPtr<Gamepad> create() |
43 { | 41 { |
44 return adoptRefWillBeNoop(new Gamepad); | 42 return adoptRefWillBeNoop(new Gamepad); |
45 } | 43 } |
46 ~Gamepad(); | 44 ~Gamepad(); |
47 | 45 |
48 typedef Vector<float> FloatVector; | 46 typedef Vector<float> FloatVector; |
49 typedef Vector<GamepadButton> ButtonVector; | |
50 | 47 |
51 const String& id() const { return m_id; } | 48 const String& id() const { return m_id; } |
52 void id(const String& id) { m_id = id; } | 49 void id(const String& id) { m_id = id; } |
53 | 50 |
54 unsigned index() const { return m_index; } | 51 unsigned index() const { return m_index; } |
55 void index(unsigned val) { m_index = val; } | 52 void index(unsigned val) { m_index = val; } |
56 | 53 |
57 bool connected() const { return m_connected; } | |
58 void connected(const bool val) { m_connected = val; } | |
59 | |
60 unsigned long long timestamp() const { return m_timestamp; } | 54 unsigned long long timestamp() const { return m_timestamp; } |
61 void timestamp(unsigned long long val) { m_timestamp = val; } | 55 void timestamp(unsigned long long val) { m_timestamp = val; } |
62 | 56 |
63 const String& mapping() const { return m_mapping; } | |
64 void mapping(const String& val) { m_mapping = val; } | |
65 | |
66 const FloatVector& axes() const { return m_axes; } | 57 const FloatVector& axes() const { return m_axes; } |
67 void axes(unsigned count, float* data); | 58 void axes(unsigned count, float* data); |
68 | 59 |
69 const GamepadButtonVector& buttons() const { return m_buttons; } | 60 const FloatVector& buttons() const { return m_buttons; } |
70 void buttons(unsigned count, blink::WebGamepadButton* data); | 61 void buttons(unsigned count, float* data); |
71 | 62 |
72 void trace(Visitor*); | 63 void trace(Visitor*); |
73 | 64 |
74 private: | 65 private: |
75 Gamepad(); | 66 Gamepad(); |
76 String m_id; | 67 String m_id; |
77 unsigned m_index; | 68 unsigned m_index; |
78 bool m_connected; | |
79 unsigned long long m_timestamp; | 69 unsigned long long m_timestamp; |
80 String m_mapping; | |
81 FloatVector m_axes; | 70 FloatVector m_axes; |
82 GamepadButtonVector m_buttons; | 71 FloatVector m_buttons; |
83 }; | 72 }; |
84 | 73 |
85 } // namespace WebCore | 74 } // namespace WebCore |
86 | 75 |
87 #endif // Gamepad_h | 76 #endif // Gamepad_h |
OLD | NEW |