InputConfig.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2010 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include <string>
  6. #include <utility>
  7. #include <vector>
  8. #include "InputCommon/ControllerInterface/ControllerInterface.h"
  9. #include "InputCommon/DynamicInputTextureManager.h"
  10. namespace Common
  11. {
  12. class IniFile;
  13. }
  14. namespace ControllerEmu
  15. {
  16. class EmulatedController;
  17. }
  18. class InputConfig
  19. {
  20. public:
  21. InputConfig(const std::string& ini_name, const std::string& gui_name,
  22. const std::string& profile_directory_name, const std::string& profile_key);
  23. ~InputConfig();
  24. bool LoadConfig();
  25. void SaveConfig();
  26. template <typename T, typename... Args>
  27. void CreateController(Args&&... args)
  28. {
  29. m_controllers.emplace_back(std::make_unique<T>(std::forward<Args>(args)...));
  30. }
  31. ControllerEmu::EmulatedController* GetController(int index) const;
  32. void ClearControllers();
  33. bool ControllersNeedToBeCreated() const;
  34. bool IsControllerControlledByGamepadDevice(int index) const;
  35. std::string GetGUIName() const { return m_gui_name; }
  36. std::string GetProfileKey() const { return m_profile_key; }
  37. std::string GetProfileDirectoryName() const { return m_profile_directory_name; }
  38. std::string GetUserProfileDirectoryPath() const;
  39. std::string GetSysProfileDirectoryPath() const;
  40. int GetControllerCount() const;
  41. // These should be used after creating all controllers and before clearing them, respectively.
  42. void RegisterHotplugCallback();
  43. void UnregisterHotplugCallback();
  44. void GenerateControllerTextures(const Common::IniFile& file);
  45. private:
  46. ControllerInterface::HotplugCallbackHandle m_hotplug_callback_handle;
  47. std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
  48. const std::string m_ini_name;
  49. const std::string m_gui_name;
  50. const std::string m_profile_directory_name;
  51. const std::string m_profile_key;
  52. InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager;
  53. };