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
12 #include "nsWrapperCache.h"
14 namespace mozilla::dom
{
16 class GamepadButton
: public nsISupports
, public nsWrapperCache
{
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
; }
42 virtual ~GamepadButton() = default;
45 nsCOMPtr
<nsISupports
> mParent
;
51 } // namespace mozilla::dom
53 #endif // mozilla_dom_gamepad_GamepadButton_h