1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_MIDIInput_h
8 #define mozilla_dom_MIDIInput_h
10 #include "mozilla/dom/MIDIPort.h"
14 namespace mozilla::dom
{
19 * Represents a MIDI Input Port, handles generating incoming message events.
22 class MIDIInput final
: public MIDIPort
{
24 static MIDIInput
* Create(nsPIDOMWindowInner
* aWindow
,
25 MIDIAccess
* aMIDIAccessParent
,
26 const MIDIPortInfo
& aPortInfo
,
27 const bool aSysexEnabled
);
28 ~MIDIInput() = default;
30 JSObject
* WrapObject(JSContext
* aCx
,
31 JS::Handle
<JSObject
*> aGivenProto
) override
;
33 IMPL_EVENT_HANDLER(midimessage
);
35 void StateChange() override
;
36 void EventListenerAdded(nsAtom
* aType
) override
;
37 void DisconnectFromOwner() override
;
40 MIDIInput(nsPIDOMWindowInner
* aWindow
, MIDIAccess
* aMIDIAccessParent
);
41 // Takes an array of IPC MIDIMessage objects and turns them into
42 // MIDIMessageEvents, which it then fires.
43 void Receive(const nsTArray
<MIDIMessage
>& aMsgs
) override
;
45 void KeepAliveOnMidimessage();
46 void DontKeepAliveOnMidimessage();
48 // If true this object will be kept alive even without direct JS references
52 } // namespace mozilla::dom
54 #endif // mozilla_dom_MIDIInput_h