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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE | 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE |
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
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 GamepadBase_h |
27 #define Gamepad_h | 27 #define GamepadBase_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 "public/platform/WebGamepad.h" | 31 #include "public/platform/WebGamepad.h" |
32 #include "wtf/RefCounted.h" | 32 #include "wtf/RefCounted.h" |
33 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
34 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 class Gamepad: public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public ScriptWrappable { | 38 class GamepadBase: public RefCountedWillBeGarbageCollectedFinalized<GamepadBase> , public ScriptWrappable { |
39 public: | 39 public: |
40 static PassRefPtrWillBeRawPtr<Gamepad> create() | 40 virtual ~GamepadBase(); |
41 { | |
42 return adoptRefWillBeNoop(new Gamepad); | |
43 } | |
44 ~Gamepad(); | |
45 | 41 |
46 typedef Vector<float> FloatVector; | 42 typedef Vector<float> FloatVector; |
47 | 43 |
48 const String& id() const { return m_id; } | 44 const String& id() const { return m_id; } |
49 void id(const String& id) { m_id = id; } | 45 void id(const String& id) { m_id = id; } |
Inactive
2014/03/06 02:54:00
I know this is existing code but I find it odd tha
| |
50 | 46 |
51 unsigned index() const { return m_index; } | 47 unsigned index() const { return m_index; } |
52 void index(unsigned val) { m_index = val; } | 48 void index(unsigned val) { m_index = val; } |
53 | 49 |
54 bool connected() const { return m_connected; } | 50 bool connected() const { return m_connected; } |
55 void connected(bool val) { m_connected = val; } | 51 void connected(bool val) { m_connected = val; } |
56 | 52 |
57 unsigned long long timestamp() const { return m_timestamp; } | 53 unsigned long long timestamp() const { return m_timestamp; } |
58 void timestamp(unsigned long long val) { m_timestamp = val; } | 54 void timestamp(unsigned long long val) { m_timestamp = val; } |
59 | 55 |
60 const String& mapping() const { return m_mapping; } | 56 const String& mapping() const { return m_mapping; } |
61 void mapping(const String& val) { m_mapping = val; } | 57 void mapping(const String& val) { m_mapping = val; } |
62 | 58 |
63 const FloatVector& axes() const { return m_axes; } | 59 const FloatVector& axes() const { return m_axes; } |
64 void axes(unsigned count, float* data); | 60 void axes(unsigned count, const float* data); |
65 | 61 |
66 const FloatVector& buttons() const { return m_buttons; } | 62 virtual void buttons(unsigned count, const blink::WebGamepadButton* data) = 0; |
67 #if defined(ENABLE_NEW_GAMEPAD_API) | |
68 void buttons(unsigned count, blink::WebGamepadButton* data); | |
69 #else | |
70 void buttons(unsigned count, float* data); | |
71 #endif | |
72 | 63 |
73 void trace(Visitor*); | 64 void trace(Visitor*); |
74 | 65 |
75 private: | 66 protected: |
76 Gamepad(); | 67 GamepadBase(); |
77 String m_id; | 68 String m_id; |
78 unsigned m_index; | 69 unsigned m_index; |
79 bool m_connected; | 70 bool m_connected; |
80 unsigned long long m_timestamp; | 71 unsigned long long m_timestamp; |
81 String m_mapping; | 72 String m_mapping; |
82 FloatVector m_axes; | 73 FloatVector m_axes; |
83 FloatVector m_buttons; | |
84 }; | 74 }; |
85 | 75 |
86 } // namespace WebCore | 76 } // namespace WebCore |
87 | 77 |
88 #endif // Gamepad_h | 78 #endif // GamepadBase_h |
OLD | NEW |