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_GamepadHapticActuator_h
8 : #define mozilla_dom_gamepad_GamepadHapticActuator_h
9 :
10 : #include "nsCOMPtr.h"
11 : #include "nsWrapperCache.h"
12 : #include "mozilla/dom/GamepadHapticActuatorBinding.h"
13 : #include "mozilla/dom/Gamepad.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 : class Promise;
18 :
19 : class GamepadHapticActuator : public nsISupports,
20 : public nsWrapperCache
21 : {
22 : public:
23 : GamepadHapticActuator(nsISupports* aParent, uint32_t aGamepadId,
24 : uint32_t aIndex);
25 : explicit GamepadHapticActuator(nsISupports* aParent)
26 : : mParent(aParent), mType(GamepadHapticActuatorType::Vibration)
27 : {
28 : }
29 :
30 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(GamepadHapticActuator)
32 :
33 : nsISupports* GetParentObject() const;
34 :
35 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
36 :
37 : already_AddRefed<Promise> Pulse(double aValue, double aDuration, ErrorResult& aRv);
38 :
39 : GamepadHapticActuatorType Type() const;
40 :
41 : void Set(const GamepadHapticActuator* aOther);
42 :
43 : private:
44 0 : virtual ~GamepadHapticActuator() {}
45 :
46 : protected:
47 : nsCOMPtr<nsISupports> mParent;
48 : uint32_t mGamepadId;
49 : GamepadHapticActuatorType mType;
50 : uint32_t mIndex;
51 : };
52 :
53 : } // namespace dom
54 : } // namespace mozilla
55 :
56 : #endif // mozilla_dom_gamepad_GamepadHapticActuator_h
|