OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebKitGamepad_h | 5 #ifndef WebKitGamepad_h |
6 #define WebKitGamepad_h | 6 #define WebKitGamepad_h |
7 | 7 |
8 #include "bindings/v8/ScriptWrappable.h" | 8 #include "modules/gamepad/Gamepad.h" |
9 #include "heap/Handle.h" | |
10 #include "public/platform/WebGamepad.h" | |
11 #include "wtf/RefCounted.h" | |
12 #include "wtf/Vector.h" | 9 #include "wtf/Vector.h" |
13 #include "wtf/text/WTFString.h" | |
14 | 10 |
15 namespace WebCore { | 11 namespace WebCore { |
16 | 12 |
17 class WebKitGamepad FINAL : public RefCountedWillBeGarbageCollectedFinalized<Web KitGamepad>, public ScriptWrappable { | 13 // Inherit from concrete Gamepad class (instead of factoring out an abstract |
14 // GamepadCommon class) so Gamepad is simple (unfactored) and low-cruft. | |
15 class WebKitGamepad : public Gamepad { | |
18 public: | 16 public: |
19 static PassRefPtrWillBeRawPtr<WebKitGamepad> create() | 17 static PassRefPtrWillBeRawPtr<WebKitGamepad> create() |
20 { | 18 { |
21 return adoptRefWillBeNoop(new WebKitGamepad); | 19 return adoptRefWillBeNoop(new WebKitGamepad); |
22 } | 20 } |
23 ~WebKitGamepad(); | |
24 | 21 |
25 typedef Vector<float> FloatVector; | 22 typedef Vector<float> FloatVector; |
26 | 23 |
27 const String& id() const { return m_id; } | |
28 void setId(const String& id) { m_id = id; } | |
29 | |
30 unsigned index() const { return m_index; } | |
31 void setIndex(unsigned val) { m_index = val; } | |
32 | |
33 bool connected() const { return m_connected; } | |
34 void setConnected(bool val) { m_connected = val; } | |
35 | |
36 unsigned long long timestamp() const { return m_timestamp; } | |
37 void setTimestamp(unsigned long long val) { m_timestamp = val; } | |
38 | |
39 const String& mapping() const { return m_mapping; } | |
40 void setMapping(const String& val) { m_mapping = val; } | |
41 | |
42 const FloatVector& axes() const { return m_axes; } | |
43 void setAxes(unsigned count, const float* data); | |
44 | |
45 const FloatVector& buttons() const { return m_buttons; } | 24 const FloatVector& buttons() const { return m_buttons; } |
46 void setButtons(unsigned count, const blink::WebGamepadButton* data); | 25 void setButtons(unsigned count, const blink::WebGamepadButton* data); |
47 | 26 |
48 void trace(Visitor*); | 27 void trace(Visitor*) { }; |
49 | 28 |
50 private: | 29 private: |
51 WebKitGamepad(); | 30 WebKitGamepad() |
52 String m_id; | 31 { |
53 unsigned m_index; | 32 ScriptWrappable::init(this); |
haraken
2014/03/13 06:29:39
As discussed offline, we don't want to call Script
Nils Barth (inactive)
2014/03/13 06:42:21
kouhei will elaborate;
sounds like simplest/best a
| |
54 bool m_connected; | 33 } |
55 unsigned long long m_timestamp; | |
56 String m_mapping; | |
57 FloatVector m_axes; | |
58 FloatVector m_buttons; | 34 FloatVector m_buttons; |
59 }; | 35 }; |
60 | 36 |
61 } // namespace WebCore | 37 } // namespace WebCore |
62 | 38 |
63 #endif // WebKitGamepad_h | 39 #endif // WebKitGamepad_h |
OLD | NEW |