tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GamepadButton.h (1502B)


      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 "nsCOMPtr.h"
     11 #include "nsWrapperCache.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 class GamepadButton : public nsISupports, public nsWrapperCache {
     16 public:
     17  explicit GamepadButton(nsISupports* aParent)
     18      : mParent(aParent), mValue(0), mPressed(false), mTouched(false) {}
     19 
     20  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     21  NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(GamepadButton)
     22 
     23  nsISupports* GetParentObject() const { return mParent; }
     24 
     25  virtual JSObject* WrapObject(JSContext* aCx,
     26                               JS::Handle<JSObject*> aGivenProto) override;
     27 
     28  void SetPressed(bool aPressed) { mPressed = aPressed; }
     29 
     30  void SetTouched(bool aTouched) { mTouched = aTouched; }
     31 
     32  void SetValue(double aValue) { mValue = aValue; }
     33 
     34  bool Pressed() const { return mPressed; }
     35 
     36  bool Touched() const { return mTouched; }
     37 
     38  double Value() const { return mValue; }
     39 
     40 private:
     41  virtual ~GamepadButton() = default;
     42 
     43 protected:
     44  nsCOMPtr<nsISupports> mParent;
     45  double mValue;
     46  bool mPressed;
     47  bool mTouched;
     48 };
     49 
     50 }  // namespace mozilla::dom
     51 
     52 #endif  // mozilla_dom_gamepad_GamepadButton_h