no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / gamepad / GamepadButton.h
blob74bde07fcf33a4a8acc3108d3770f1b0283896f6
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/. */
7 #ifndef mozilla_dom_gamepad_GamepadButton_h
8 #define mozilla_dom_gamepad_GamepadButton_h
10 #include <stdint.h>
11 #include "nsCOMPtr.h"
12 #include "nsWrapperCache.h"
14 namespace mozilla::dom {
16 class GamepadButton : public nsISupports, public nsWrapperCache {
17 public:
18 explicit GamepadButton(nsISupports* aParent)
19 : mParent(aParent), mValue(0), mPressed(false), mTouched(false) {}
21 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
22 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(GamepadButton)
24 nsISupports* GetParentObject() const { return mParent; }
26 virtual JSObject* WrapObject(JSContext* aCx,
27 JS::Handle<JSObject*> aGivenProto) override;
29 void SetPressed(bool aPressed) { mPressed = aPressed; }
31 void SetTouched(bool aTouched) { mTouched = aTouched; }
33 void SetValue(double aValue) { mValue = aValue; }
35 bool Pressed() const { return mPressed; }
37 bool Touched() const { return mTouched; }
39 double Value() const { return mValue; }
41 private:
42 virtual ~GamepadButton() = default;
44 protected:
45 nsCOMPtr<nsISupports> mParent;
46 double mValue;
47 bool mPressed;
48 bool mTouched;
51 } // namespace mozilla::dom
53 #endif // mozilla_dom_gamepad_GamepadButton_h