diff options
| author | Michael Maltese <michaeljosephmaltese@gmail.com> | 2017-02-07 16:25:27 -0800 |
|---|---|---|
| committer | Léo Lam <leo@innovatetechnologi.es> | 2017-11-19 16:07:00 +0100 |
| commit | c62d83a34b34fe591dca1d3c03354ff915c589f4 (patch) | |
| tree | bc2dad207404addb20dae8ac25d602cc5ebe9366 /Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp | |
| parent | 379e28b58ca335443e398692f0f22e36f5040761 (diff) | |
GCPadEmu: only connected if default device connected
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.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp index cf70fa8468..98b9e5828b 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp @@ -34,6 +34,8 @@ std::unique_lock<std::recursive_mutex> EmulatedController::GetStateLock() void EmulatedController::UpdateReferences(const ControllerInterface& devi) { const auto lock = GetStateLock(); + m_default_device_is_connected = devi.HasConnectedDevice(m_default_device); + for (auto& ctrlGroup : groups) { for (auto& control : ctrlGroup->controls) @@ -48,6 +50,11 @@ void EmulatedController::UpdateReferences(const ControllerInterface& devi) } } +bool EmulatedController::IsDefaultDeviceConnected() const +{ + return m_default_device_is_connected; +} + const ciface::Core::DeviceQualifier& EmulatedController::GetDefaultDevice() const { return m_default_device; |
