mirror of
https://github.com/libretro/parallel-gx1.git
synced 2026-11-07 04:26:01 -10:00
Every std::mutex, lock_guard, unique_lock, scoped_lock, condition_variable, call_once and semaphore left in Source/Core is replaced by a lock-free design: - Input: the device list, control bindings, stick calibration and default device are published snapshots read under a quiesce; a rebind requested while another thread is rebinding is handed to that thread instead of waited for. - WiimoteReal: the pool thread owns the slots and runs commands from an MPSC queue; the active Wiimotes are atomic slots. - EXI/SI/IOS devices: socket and packet traffic goes through SPSC rings or MPSC handoffs owned by one thread; USB scanning publishes its device list, and libusb transfers drain through a CallGate. - Memory cards: the flush thread applies change records queued by the CPU thread. - Custom assets: loads are scheduled as a published batch with an atomic cursor, results come back over an MPSC stack, and busy assets are skipped and retried. - D3D state and GL program caches use insert-only atomic maps (Common/AtomicHashMap.h). - Logging appends with O_APPEND / FILE_APPEND_DATA; FatFs reports busy instead of waiting; per-socket WSAStartup/WSACleanup. Deleted as unused by the libretro core: the profiler, the FIFO recorder, the volume verifier, the touch InputOverrider and the GameCube adapter's libusb path.
108 lines
2.6 KiB
C++
108 lines
2.6 KiB
C++
// Copyright 2017 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
|
|
|
namespace ControllerEmu
|
|
{
|
|
|
|
void AttachedController::LoadDefaults()
|
|
{
|
|
}
|
|
|
|
Attachments::Attachments(const std::string& name_) : ControlGroup(name_, GroupType::Attachments)
|
|
{
|
|
}
|
|
|
|
void Attachments::AddAttachment(std::unique_ptr<AttachedController> att)
|
|
{
|
|
m_attachments.emplace_back(std::move(att));
|
|
}
|
|
|
|
u32 Attachments::GetSelectedAttachment() const
|
|
{
|
|
// This is originally an int, treat it as such
|
|
const int value = m_selection_value.GetValue();
|
|
|
|
if (value > 0 && static_cast<size_t>(value) < m_attachments.size())
|
|
return u32(value);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Attachments::SetSelectedAttachment(u32 val)
|
|
{
|
|
m_selection_setting.SetValue(val);
|
|
}
|
|
|
|
NumericSetting<int>& Attachments::GetSelectionSetting()
|
|
{
|
|
return m_selection_setting;
|
|
}
|
|
|
|
SettingValue<int>& Attachments::GetAttachmentSetting()
|
|
{
|
|
return m_selection_value;
|
|
}
|
|
|
|
const std::vector<std::unique_ptr<AttachedController>>& Attachments::GetAttachmentList() const
|
|
{
|
|
return m_attachments;
|
|
}
|
|
|
|
void Attachments::LoadConfig(Common::IniFile::Section* sec, const std::string& base)
|
|
{
|
|
ControlGroup::LoadConfig(sec, base);
|
|
|
|
SetSelectedAttachment(0);
|
|
|
|
std::string attachment_text;
|
|
sec->Get(base + name, &attachment_text, "");
|
|
|
|
// First assume attachment string is a valid expression.
|
|
// If it instead matches one of the names of our attachments it is overridden below.
|
|
GetSelectionSetting().GetInputReference().SetExpression(attachment_text);
|
|
|
|
u32 n = 0;
|
|
for (auto& ai : GetAttachmentList())
|
|
{
|
|
ai->LoadGroupsConfig(sec, base + ai->GetName() + "/");
|
|
|
|
if (ai->GetName() == attachment_text)
|
|
SetSelectedAttachment(n);
|
|
|
|
++n;
|
|
}
|
|
}
|
|
|
|
void Attachments::SaveConfig(Common::IniFile::Section* sec, const std::string& base)
|
|
{
|
|
ControlGroup::SaveConfig(sec, base);
|
|
|
|
if (GetSelectionSetting().IsSimpleValue())
|
|
{
|
|
sec->Set(base + name, GetAttachmentList()[GetSelectedAttachment()]->GetName(), "None");
|
|
}
|
|
else
|
|
{
|
|
std::string expression = GetSelectionSetting().GetInputReference().GetExpression();
|
|
ReplaceBreaksWithSpaces(expression);
|
|
sec->Set(base + name, expression, "None");
|
|
}
|
|
|
|
for (auto& ai : GetAttachmentList())
|
|
ai->SaveGroupsConfig(sec, base + ai->GetName() + "/");
|
|
}
|
|
|
|
void Attachments::UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env)
|
|
{
|
|
ControlGroup::UpdateReferences(env);
|
|
|
|
GetSelectionSetting().GetInputReference().UpdateReference(env);
|
|
|
|
for (auto& attachment : GetAttachmentList())
|
|
attachment->UpdateGroupsReferences(env);
|
|
}
|
|
|
|
} // namespace ControllerEmu
|