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