|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef mozilla_dom_gamepad_GamepadButton_h |
|
6 #define mozilla_dom_gamepad_GamepadButton_h |
|
7 |
|
8 #include <stdint.h> |
|
9 #include "nsCOMPtr.h" |
|
10 #include "nsWrapperCache.h" |
|
11 |
|
12 namespace mozilla { |
|
13 namespace dom { |
|
14 |
|
15 class GamepadButton : public nsISupports, |
|
16 public nsWrapperCache |
|
17 { |
|
18 public: |
|
19 GamepadButton(nsISupports* aParent) : mParent(aParent), |
|
20 mPressed(false), |
|
21 mValue(0) |
|
22 { |
|
23 SetIsDOMBinding(); |
|
24 } |
|
25 |
|
26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GamepadButton) |
|
28 |
|
29 nsISupports* GetParentObject() const |
|
30 { |
|
31 return mParent; |
|
32 } |
|
33 |
|
34 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
35 |
|
36 void SetPressed(bool aPressed) |
|
37 { |
|
38 mPressed = aPressed; |
|
39 } |
|
40 |
|
41 void SetValue(double aValue) |
|
42 { |
|
43 mValue = aValue; |
|
44 } |
|
45 |
|
46 bool Pressed() const |
|
47 { |
|
48 return mPressed; |
|
49 } |
|
50 |
|
51 double Value() const |
|
52 { |
|
53 return mValue; |
|
54 } |
|
55 |
|
56 private: |
|
57 virtual ~GamepadButton() {} |
|
58 |
|
59 protected: |
|
60 nsCOMPtr<nsISupports> mParent; |
|
61 bool mPressed; |
|
62 double mValue; |
|
63 }; |
|
64 |
|
65 } // namespace dom |
|
66 } // namespace mozilla |
|
67 |
|
68 #endif // mozilla_dom_gamepad_GamepadButton_h |