2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-09-21 00:43:16 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2022-02-02 17:12:22 +00:00
|
|
|
#include "common/common_funcs.h"
|
2021-11-01 20:17:53 +00:00
|
|
|
#include "core/hid/hid_types.h"
|
|
|
|
|
|
|
|
namespace Core::HID {
|
|
|
|
class EmulatedConsole;
|
|
|
|
class EmulatedController;
|
|
|
|
class EmulatedDevices;
|
|
|
|
} // namespace Core::HID
|
2021-09-21 00:43:16 +00:00
|
|
|
|
|
|
|
namespace Core::HID {
|
|
|
|
|
|
|
|
class HIDCore {
|
|
|
|
public:
|
|
|
|
explicit HIDCore();
|
|
|
|
~HIDCore();
|
|
|
|
|
|
|
|
YUZU_NON_COPYABLE(HIDCore);
|
|
|
|
YUZU_NON_MOVEABLE(HIDCore);
|
|
|
|
|
|
|
|
EmulatedController* GetEmulatedController(NpadIdType npad_id_type);
|
|
|
|
const EmulatedController* GetEmulatedController(NpadIdType npad_id_type) const;
|
|
|
|
|
|
|
|
EmulatedController* GetEmulatedControllerByIndex(std::size_t index);
|
|
|
|
const EmulatedController* GetEmulatedControllerByIndex(std::size_t index) const;
|
|
|
|
|
|
|
|
EmulatedConsole* GetEmulatedConsole();
|
|
|
|
const EmulatedConsole* GetEmulatedConsole() const;
|
|
|
|
|
|
|
|
EmulatedDevices* GetEmulatedDevices();
|
|
|
|
const EmulatedDevices* GetEmulatedDevices() const;
|
|
|
|
|
|
|
|
void SetSupportedStyleTag(NpadStyleTag style_tag);
|
|
|
|
NpadStyleTag GetSupportedStyleTag() const;
|
|
|
|
|
2021-10-20 22:53:14 +00:00
|
|
|
/// Counts the connected players from P1-P8
|
|
|
|
s8 GetPlayerCount() const;
|
|
|
|
|
|
|
|
/// Returns the first connected npad id
|
|
|
|
NpadIdType GetFirstNpadId() const;
|
|
|
|
|
2021-12-05 22:17:52 +00:00
|
|
|
/// Returns the first disconnected npad id
|
|
|
|
NpadIdType GetFirstDisconnectedNpadId() const;
|
|
|
|
|
2023-09-16 06:21:47 +00:00
|
|
|
/// Sets the npad id of the last active controller
|
|
|
|
void SetLastActiveController(NpadIdType npad_id);
|
|
|
|
|
|
|
|
/// Returns the npad id of the last controller that pushed a button
|
|
|
|
NpadIdType GetLastActiveController() const;
|
|
|
|
|
2021-11-29 22:59:58 +00:00
|
|
|
/// Sets all emulated controllers into configuring mode.
|
|
|
|
void EnableAllControllerConfiguration();
|
|
|
|
|
|
|
|
/// Sets all emulated controllers into normal mode.
|
|
|
|
void DisableAllControllerConfiguration();
|
|
|
|
|
2021-10-20 22:53:14 +00:00
|
|
|
/// Reloads all input devices from settings
|
2021-09-21 00:43:16 +00:00
|
|
|
void ReloadInputDevices();
|
|
|
|
|
2021-10-20 22:53:14 +00:00
|
|
|
/// Removes all callbacks from input common
|
2021-09-21 00:43:16 +00:00
|
|
|
void UnloadInputDevices();
|
|
|
|
|
2021-10-21 18:56:52 +00:00
|
|
|
/// Number of emulated controllers
|
2021-11-19 16:56:52 +00:00
|
|
|
static constexpr std::size_t available_controllers{10};
|
2021-10-21 18:56:52 +00:00
|
|
|
|
2021-09-21 00:43:16 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<EmulatedController> player_1;
|
|
|
|
std::unique_ptr<EmulatedController> player_2;
|
|
|
|
std::unique_ptr<EmulatedController> player_3;
|
|
|
|
std::unique_ptr<EmulatedController> player_4;
|
|
|
|
std::unique_ptr<EmulatedController> player_5;
|
|
|
|
std::unique_ptr<EmulatedController> player_6;
|
|
|
|
std::unique_ptr<EmulatedController> player_7;
|
|
|
|
std::unique_ptr<EmulatedController> player_8;
|
|
|
|
std::unique_ptr<EmulatedController> other;
|
|
|
|
std::unique_ptr<EmulatedController> handheld;
|
|
|
|
std::unique_ptr<EmulatedConsole> console;
|
|
|
|
std::unique_ptr<EmulatedDevices> devices;
|
2021-12-05 01:37:03 +00:00
|
|
|
NpadStyleTag supported_style_tag{NpadStyleSet::All};
|
2023-09-16 06:21:47 +00:00
|
|
|
NpadIdType last_active_controller{NpadIdType::Handheld};
|
2021-09-21 00:43:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Core::HID
|