Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: Source/modules/gamepad/Gamepad.h

Issue 183313003: Added non-prefixed navigator.getGamepads() with updated API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressing review feedback Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 "public/platform/WebGamepad.h" 32 #include "public/platform/WebGamepad.h"
32 #include "wtf/RefCounted.h" 33 #include "wtf/RefCounted.h"
33 #include "wtf/Vector.h" 34 #include "wtf/Vector.h"
34 #include "wtf/text/WTFString.h" 35 #include "wtf/text/WTFString.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 class Gamepad: public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public ScriptWrappable { 39 class Gamepad FINAL : public RefCountedWillBeGarbageCollectedFinalized<Gamepad>, public ScriptWrappable {
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 virtual ~Gamepad();
45 46
46 typedef Vector<float> FloatVector; 47 typedef Vector<float> FloatVector;
47 48
48 const String& id() const { return m_id; } 49 const String& id() const { return m_id; }
49 void id(const String& id) { m_id = id; } 50 void setId(const String& id) { m_id = id; }
50 51
51 unsigned index() const { return m_index; } 52 unsigned index() const { return m_index; }
52 void index(unsigned val) { m_index = val; } 53 void setIndex(unsigned val) { m_index = val; }
53 54
54 bool connected() const { return m_connected; } 55 bool connected() const { return m_connected; }
55 void connected(bool val) { m_connected = val; } 56 void setConnected(bool val) { m_connected = val; }
56 57
57 unsigned long long timestamp() const { return m_timestamp; } 58 unsigned long long timestamp() const { return m_timestamp; }
58 void timestamp(unsigned long long val) { m_timestamp = val; } 59 void setTimestamp(unsigned long long val) { m_timestamp = val; }
59 60
60 const String& mapping() const { return m_mapping; } 61 const String& mapping() const { return m_mapping; }
61 void mapping(const String& val) { m_mapping = val; } 62 void setMapping(const String& val) { m_mapping = val; }
62 63
63 const FloatVector& axes() const { return m_axes; } 64 const FloatVector& axes() const { return m_axes; }
64 void axes(unsigned count, float* data); 65 void setAxes(unsigned count, const float* data);
65 66
66 const FloatVector& buttons() const { return m_buttons; } 67 const GamepadButtonVector& buttons() const { return m_buttons; }
67 #if defined(ENABLE_NEW_GAMEPAD_API) 68 void setButtons(unsigned count, const blink::WebGamepadButton* data);
68 void buttons(unsigned count, blink::WebGamepadButton* data);
69 #else
70 void buttons(unsigned count, float* data);
71 #endif
72 69
73 void trace(Visitor*); 70 void trace(Visitor*);
74 71
75 private: 72 private:
76 Gamepad(); 73 Gamepad();
77 String m_id; 74 String m_id;
78 unsigned m_index; 75 unsigned m_index;
79 bool m_connected; 76 bool m_connected;
80 unsigned long long m_timestamp; 77 unsigned long long m_timestamp;
81 String m_mapping; 78 String m_mapping;
82 FloatVector m_axes; 79 FloatVector m_axes;
83 FloatVector m_buttons; 80 GamepadButtonVector m_buttons;
sof 2014/03/06 22:33:10 If you change this typedef to have an Oilpan (tran
84 }; 81 };
85 82
86 } // namespace WebCore 83 } // namespace WebCore
87 84
88 #endif // Gamepad_h 85 #endif // Gamepad_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698