blob: a2eb0a94a8f6f80ed99514bd6d05fca0c240b779 [file] [log] [blame]
// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_GAMEPAD_WGI_GAMEPAD_DEVICE_H_
#define DEVICE_GAMEPAD_WGI_GAMEPAD_DEVICE_H_
#include <Windows.Gaming.Input.h>
#include <wrl/client.h>
#include <wrl/event.h>
#include "base/memory/weak_ptr.h"
#include "base/win/core_winrt_util.h"
#include "device/gamepad/abstract_haptic_gamepad.h"
namespace device {
class DEVICE_GAMEPAD_EXPORT WgiGamepadDevice final
: public AbstractHapticGamepad {
public:
explicit WgiGamepadDevice(
Microsoft::WRL::ComPtr<ABI::Windows::Gaming::Input::IGamepad> gamepad);
WgiGamepadDevice(const WgiGamepadDevice& other) = delete;
WgiGamepadDevice& operator=(const WgiGamepadDevice& other) = delete;
~WgiGamepadDevice() override;
// AbstractHapticGamepad implementation.
void SetVibration(double strong_magnitude, double weak_magnitude) override;
base::WeakPtr<AbstractHapticGamepad> GetWeakPtr() override;
Microsoft::WRL::ComPtr<ABI::Windows::Gaming::Input::IGamepad> GetGamepad() {
return gamepad_;
}
private:
Microsoft::WRL::ComPtr<ABI::Windows::Gaming::Input::IGamepad> gamepad_;
base::WeakPtrFactory<WgiGamepadDevice> weak_factory_{this};
};
} // namespace device
#endif // DEVICE_GAMEPAD_WGI_GAMEPAD_DEVICE_H_