1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_GAMEPAD_GAMEPAD_DISPATCHER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_GAMEPAD_GAMEPAD_DISPATCHER_H_
#include "base/memory/scoped_refptr.h"
#include "device/gamepad/public/mojom/gamepad.mojom-blink.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/platform_event_dispatcher.h"
#include "third_party/blink/renderer/modules/gamepad/gamepad_listener.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h"
namespace device {
template <class T>
class GamepadImpl;
using Gamepad = GamepadImpl<void>;
class Gamepads;
} // namespace device
namespace blink {
class GamepadSharedMemoryReader;
class GamepadDispatcher final : public GarbageCollected<GamepadDispatcher>,
public PlatformEventDispatcher,
public GamepadListener {
public:
explicit GamepadDispatcher(ExecutionContext& context);
~GamepadDispatcher() override;
void SampleGamepads(device::Gamepads&);
void PlayVibrationEffectOnce(uint32_t pad_index,
device::mojom::blink::GamepadHapticEffectType,
device::mojom::blink::GamepadEffectParametersPtr,
device::mojom::blink::GamepadHapticsManager::
PlayVibrationEffectOnceCallback);
void ResetVibrationActuator(uint32_t pad_index,
device::mojom::blink::GamepadHapticsManager::
ResetVibrationActuatorCallback);
void Trace(Visitor*) const override;
private:
void InitializeHaptics();
// GamepadListener
void DidConnectGamepad(uint32_t index, const device::Gamepad&) override;
void DidDisconnectGamepad(uint32_t index, const device::Gamepad&) override;
void ButtonOrAxisDidChange(uint32_t index, const device::Gamepad&) override;
// PlatformEventDispatcher
void StartListening(LocalDOMWindow*) override;
void StopListening() override;
void DispatchDidConnectOrDisconnectGamepad(uint32_t index,
const device::Gamepad&,
bool connected);
WeakMember<ExecutionContext> execution_context_;
Member<GamepadSharedMemoryReader> reader_;
HeapMojoRemote<device::mojom::blink::GamepadHapticsManager>
gamepad_haptics_manager_remote_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_GAMEPAD_GAMEPAD_DISPATCHER_H_
|