Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_gamepad_GamepadButton_h
8 : #define mozilla_dom_gamepad_GamepadButton_h
9 :
10 : #include <stdint.h>
11 : #include "nsCOMPtr.h"
12 : #include "nsWrapperCache.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class GamepadButton : public nsISupports,
18 : public nsWrapperCache
19 : {
20 : public:
21 0 : explicit GamepadButton(nsISupports* aParent) : mParent(aParent),
22 : mValue(0),
23 : mPressed(false),
24 0 : mTouched(false)
25 : {
26 0 : }
27 :
28 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GamepadButton)
30 :
31 0 : nsISupports* GetParentObject() const
32 : {
33 0 : return mParent;
34 : }
35 :
36 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
37 :
38 0 : void SetPressed(bool aPressed)
39 : {
40 0 : mPressed = aPressed;
41 0 : }
42 :
43 0 : void SetTouched(bool aTouched)
44 : {
45 0 : mTouched = aTouched;
46 0 : }
47 :
48 0 : void SetValue(double aValue)
49 : {
50 0 : mValue = aValue;
51 0 : }
52 :
53 0 : bool Pressed() const
54 : {
55 0 : return mPressed;
56 : }
57 :
58 0 : bool Touched() const
59 : {
60 0 : return mTouched;
61 : }
62 :
63 0 : double Value() const
64 : {
65 0 : return mValue;
66 : }
67 :
68 : private:
69 0 : virtual ~GamepadButton() {}
70 :
71 : protected:
72 : nsCOMPtr<nsISupports> mParent;
73 : double mValue;
74 : bool mPressed;
75 : bool mTouched;
76 : };
77 :
78 : } // namespace dom
79 : } // namespace mozilla
80 :
81 : #endif // mozilla_dom_gamepad_GamepadButton_h
|