2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2010-06-12 11:15:16 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2015-10-25 20:28:15 -06:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
2014-02-17 03:18:15 -07:00
|
|
|
#include <vector>
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2019-01-10 08:02:38 -07:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2019-08-17 13:40:58 -06:00
|
|
|
#include "InputCommon/DynamicInputTextureManager.h"
|
2019-01-10 08:02:38 -07:00
|
|
|
|
2023-04-13 07:38:09 -06:00
|
|
|
namespace Common
|
|
|
|
{
|
|
|
|
class IniFile;
|
|
|
|
}
|
|
|
|
|
2017-02-08 20:15:43 -07:00
|
|
|
namespace ControllerEmu
|
|
|
|
{
|
|
|
|
class EmulatedController;
|
|
|
|
}
|
2010-06-03 12:05:08 -06:00
|
|
|
|
2014-08-30 22:04:15 -06:00
|
|
|
class InputConfig
|
2010-06-03 12:05:08 -06:00
|
|
|
{
|
|
|
|
public:
|
2024-02-04 07:29:36 -07:00
|
|
|
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
2024-02-04 09:36:15 -07:00
|
|
|
const std::string& profile_directory_name, const std::string& profile_key);
|
2024-02-04 07:29:36 -07:00
|
|
|
|
|
|
|
~InputConfig();
|
|
|
|
|
|
|
|
bool LoadConfig();
|
2010-06-03 12:05:08 -06:00
|
|
|
void SaveConfig();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2015-10-25 20:28:15 -06:00
|
|
|
template <typename T, typename... Args>
|
|
|
|
void CreateController(Args&&... args)
|
|
|
|
{
|
2021-02-27 15:41:50 -07:00
|
|
|
m_controllers.emplace_back(std::make_unique<T>(std::forward<Args>(args)...));
|
2015-10-25 20:28:15 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2021-05-04 14:47:55 -06:00
|
|
|
ControllerEmu::EmulatedController* GetController(int index) const;
|
2015-10-25 20:28:15 -06:00
|
|
|
void ClearControllers();
|
|
|
|
bool ControllersNeedToBeCreated() const;
|
2016-06-21 07:33:53 -06:00
|
|
|
bool IsControllerControlledByGamepadDevice(int index) const;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2015-10-25 20:28:15 -06:00
|
|
|
std::string GetGUIName() const { return m_gui_name; }
|
2024-02-04 09:36:15 -07:00
|
|
|
std::string GetProfileKey() const { return m_profile_key; }
|
2024-02-04 08:31:15 -07:00
|
|
|
std::string GetProfileDirectoryName() const { return m_profile_directory_name; }
|
|
|
|
std::string GetUserProfileDirectoryPath() const;
|
|
|
|
std::string GetSysProfileDirectoryPath() const;
|
2021-02-12 18:21:48 -07:00
|
|
|
int GetControllerCount() const;
|
2018-04-12 06:18:04 -06:00
|
|
|
|
2019-01-10 08:02:38 -07:00
|
|
|
// These should be used after creating all controllers and before clearing them, respectively.
|
|
|
|
void RegisterHotplugCallback();
|
|
|
|
void UnregisterHotplugCallback();
|
|
|
|
|
2023-04-13 07:38:09 -06:00
|
|
|
void GenerateControllerTextures(const Common::IniFile& file);
|
2021-02-27 15:41:50 -07:00
|
|
|
|
2015-10-25 20:28:15 -06:00
|
|
|
private:
|
2019-01-10 08:02:38 -07:00
|
|
|
ControllerInterface::HotplugCallbackHandle m_hotplug_callback_handle;
|
2017-02-08 20:15:43 -07:00
|
|
|
std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
|
2015-10-25 20:28:15 -06:00
|
|
|
const std::string m_ini_name;
|
|
|
|
const std::string m_gui_name;
|
2024-02-04 08:31:15 -07:00
|
|
|
const std::string m_profile_directory_name;
|
2024-02-04 09:36:15 -07:00
|
|
|
const std::string m_profile_key;
|
2019-08-17 13:40:58 -06:00
|
|
|
InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager;
|
2010-06-03 12:05:08 -06:00
|
|
|
};
|