dom/gamepad/GamepadButton.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/gamepad/GamepadButton.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_dom_gamepad_GamepadButton_h
     1.9 +#define mozilla_dom_gamepad_GamepadButton_h
    1.10 +
    1.11 +#include <stdint.h>
    1.12 +#include "nsCOMPtr.h"
    1.13 +#include "nsWrapperCache.h"
    1.14 +
    1.15 +namespace mozilla {
    1.16 +namespace dom {
    1.17 +
    1.18 +class GamepadButton : public nsISupports,
    1.19 +                      public nsWrapperCache
    1.20 +{
    1.21 +public:
    1.22 +  GamepadButton(nsISupports* aParent) : mParent(aParent),
    1.23 +                                        mPressed(false),
    1.24 +                                        mValue(0)
    1.25 +  {
    1.26 +    SetIsDOMBinding();
    1.27 +  }
    1.28 +
    1.29 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.30 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GamepadButton)
    1.31 +
    1.32 +  nsISupports* GetParentObject() const
    1.33 +  {
    1.34 +    return mParent;
    1.35 +  }
    1.36 +
    1.37 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.38 +
    1.39 +  void SetPressed(bool aPressed)
    1.40 +  {
    1.41 +    mPressed = aPressed;
    1.42 +  }
    1.43 +
    1.44 +  void SetValue(double aValue)
    1.45 +  {
    1.46 +    mValue = aValue;
    1.47 +  }
    1.48 +
    1.49 +  bool Pressed() const
    1.50 +  {
    1.51 +    return mPressed;
    1.52 +  }
    1.53 +
    1.54 +  double Value() const
    1.55 +  {
    1.56 +    return mValue;
    1.57 +  }
    1.58 +
    1.59 +private:
    1.60 +  virtual ~GamepadButton() {}
    1.61 +
    1.62 +protected:
    1.63 +  nsCOMPtr<nsISupports> mParent;
    1.64 +  bool mPressed;
    1.65 +  double mValue;
    1.66 +};
    1.67 +
    1.68 +} // namespace dom
    1.69 +} // namespace mozilla
    1.70 +
    1.71 +#endif // mozilla_dom_gamepad_GamepadButton_h

mercurial