MockGamepadProvider.h [plain text]
#pragma once
#if ENABLE(GAMEPAD)
#include "GamepadProvider.h"
#include "MockGamepad.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
class MockGamepadProvider : public GamepadProvider {
WTF_MAKE_NONCOPYABLE(MockGamepadProvider);
friend class NeverDestroyed<MockGamepadProvider>;
public:
WEBCORE_TESTSUPPORT_EXPORT static MockGamepadProvider& singleton();
WEBCORE_TESTSUPPORT_EXPORT void startMonitoringGamepads(GamepadProviderClient&) final;
WEBCORE_TESTSUPPORT_EXPORT void stopMonitoringGamepads(GamepadProviderClient&) final;
const Vector<PlatformGamepad*>& platformGamepads() final { return m_connectedGamepadVector; }
bool isMockGamepadProvider() const final { return true; }
void setMockGamepadDetails(unsigned index, const String& gamepadID, const String& mapping, unsigned axisCount, unsigned buttonCount);
bool setMockGamepadAxisValue(unsigned index, unsigned axisIndex, double value);
bool setMockGamepadButtonValue(unsigned index, unsigned buttonIndex, double value);
bool connectMockGamepad(unsigned index);
bool disconnectMockGamepad(unsigned index);
private:
MockGamepadProvider();
void gamepadInputActivity();
Vector<PlatformGamepad*> m_connectedGamepadVector;
Vector<std::unique_ptr<MockGamepad>> m_mockGamepadVector;
bool m_shouldScheduleActivityCallback { true };
};
}
#endif // ENABLE(GAMEPAD)