1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef DEVICE_GAMEPAD_XBOX_HID_CONTROLLER_H_ 6 #define DEVICE_GAMEPAD_XBOX_HID_CONTROLLER_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 12 #include "base/memory/weak_ptr.h" 13 #include "device/gamepad/abstract_haptic_gamepad.h" 14 #include "device/gamepad/gamepad_export.h" 15 #include "device/gamepad/gamepad_id_list.h" 16 17 namespace device { 18 19 class HidWriter; 20 21 class DEVICE_GAMEPAD_EXPORT XboxHidController final 22 : public AbstractHapticGamepad { 23 public: 24 XboxHidController(std::unique_ptr<HidWriter> writer); 25 ~XboxHidController() override; 26 27 static bool IsXboxHid(GamepadId gamepad_id); 28 29 // AbstractHapticGamepad public implementation. 30 void SetVibration(double strong_magnitude, double weak_magnitude) override; 31 base::WeakPtr<AbstractHapticGamepad> GetWeakPtr() override; 32 33 private: 34 // AbstractHapticGamepad private implementation. 35 void DoShutdown() override; 36 37 std::unique_ptr<HidWriter> writer_; 38 base::WeakPtrFactory<XboxHidController> weak_factory_{this}; 39 }; 40 41 } // namespace device 42 43 #endif // DEVICE_GAMEPAD_XBOX_HID_CONTROLLER_H_ 44