mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-05 07:13:07 +02:00

This lets Dolphin know if a configured GameCube Controller should actually be treated as connected or not. Talked to @JMC47 a bit about this last night. My use-case is that all of my controllers are the same hardware (Xbox One controllers) so share the same configuration (modulo device number). Treating them all as always connected isn't a problem for most games, but in some (Smash Bros.) it forces me to go find a keyboard/mouse and unconfigure any controllers that I don't actually have connected. Hotplugging devices (works on macOS, at least) + this patch remove my need to ever touch the Controller Config dialog while in a game. This patch makes the following changes: - A new `BooleanSetting` in `GCPadEmu` called "Always Connected", which defaults to false. - `ControllerEmu` tracks whether the default device is connected on every call to `UpdateReferences()`. - `GCPadEmu.GetStatus()` now sets err bit to `PAD_ERR_NO_CONTROLLER` if the default device isn't connected. - `SIDevice_GCController` handles `PAD_ERR_NO_CONTROLLER` by imitating the behaviour of `SIDevice_Null` (as far as I can tell, this is the only use of the error bit from `GCPadStatus`). I wanted to add an OSD message akin to the ones when Wiimotes get connected/disconnected, but I haven't yet found where to put the logic.
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
// Copyright 2010 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
|
|
|
struct GCPadStatus;
|
|
|
|
namespace ControllerEmu
|
|
{
|
|
class AnalogStick;
|
|
class Buttons;
|
|
class MixedTriggers;
|
|
}
|
|
|
|
enum class PadGroup
|
|
{
|
|
Buttons,
|
|
MainStick,
|
|
CStick,
|
|
DPad,
|
|
Triggers,
|
|
Rumble,
|
|
Mic,
|
|
Options
|
|
};
|
|
|
|
class GCPad : public ControllerEmu::EmulatedController
|
|
{
|
|
public:
|
|
explicit GCPad(unsigned int index);
|
|
GCPadStatus GetInput() const;
|
|
void SetOutput(const ControlState strength);
|
|
|
|
bool GetMicButton() const;
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControllerEmu::ControlGroup* GetGroup(PadGroup group);
|
|
|
|
void LoadDefaults(const ControllerInterface& ciface) override;
|
|
|
|
private:
|
|
ControllerEmu::Buttons* m_buttons;
|
|
ControllerEmu::AnalogStick* m_main_stick;
|
|
ControllerEmu::AnalogStick* m_c_stick;
|
|
ControllerEmu::Buttons* m_dpad;
|
|
ControllerEmu::MixedTriggers* m_triggers;
|
|
ControllerEmu::ControlGroup* m_rumble;
|
|
ControllerEmu::Buttons* m_mic;
|
|
ControllerEmu::ControlGroup* m_options;
|
|
ControllerEmu::BooleanSetting* m_always_connected;
|
|
|
|
const unsigned int m_index;
|
|
|
|
// Default analog stick radius for GameCube controllers.
|
|
static constexpr ControlState DEFAULT_PAD_STICK_RADIUS = 1.0;
|
|
};
|