mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 23:38:49 +00:00
ControllerInterface: Switch to std::shared_ptr
Small cleanup by using std::shared_ptr and getting rid of ciface.Devices() which just returned the m_devices (which defeats the point of making m_devices protected). Incidentally, this should make the code safer when we have different threads accessing devices in the future (for hotplug?). A lot of code use Device references directly so there is no easy way to remove FindDevice() and make those unique_ptrs.
This commit is contained in:
parent
afa202738e
commit
8678133e87
18 changed files with 80 additions and 60 deletions
|
@ -218,8 +218,8 @@ void ControlDialog::UpdateListContents()
|
|||
{
|
||||
control_lbox->Clear();
|
||||
|
||||
ciface::Core::Device* const dev = g_controller_interface.FindDevice(m_devq);
|
||||
if (dev)
|
||||
const auto dev = g_controller_interface.FindDevice(m_devq);
|
||||
if (dev != nullptr)
|
||||
{
|
||||
if (control_reference->is_input)
|
||||
{
|
||||
|
@ -493,8 +493,8 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
|
|||
wxButton* const btn = (wxButton*)event.GetEventObject();
|
||||
const wxString lbl = btn->GetLabel();
|
||||
|
||||
ciface::Core::Device* const dev = g_controller_interface.FindDevice(m_devq);
|
||||
if (dev)
|
||||
const auto dev = g_controller_interface.FindDevice(m_devq);
|
||||
if (dev != nullptr)
|
||||
{
|
||||
m_event_filter.BlockEvents(true);
|
||||
btn->SetLabel(_("[ waiting ]"));
|
||||
|
@ -502,7 +502,8 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
|
|||
// This makes the "waiting" text work on Linux. true (only if needed) prevents crash on Windows
|
||||
wxTheApp->Yield(true);
|
||||
|
||||
ciface::Core::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||
ciface::Core::Device::Control* const ctrl =
|
||||
control_reference->Detect(DETECT_WAIT_TIME, dev.get());
|
||||
|
||||
// if we got input, select it in the list
|
||||
if (ctrl)
|
||||
|
@ -537,8 +538,8 @@ bool GamepadPage::DetectButton(ControlButton* button)
|
|||
{
|
||||
bool success = false;
|
||||
// find device :/
|
||||
ciface::Core::Device* const dev = g_controller_interface.FindDevice(controller->default_device);
|
||||
if (dev)
|
||||
const auto dev = g_controller_interface.FindDevice(controller->default_device);
|
||||
if (dev != nullptr)
|
||||
{
|
||||
m_event_filter.BlockEvents(true);
|
||||
button->SetLabel(_("[ waiting ]"));
|
||||
|
@ -547,7 +548,7 @@ bool GamepadPage::DetectButton(ControlButton* button)
|
|||
wxTheApp->Yield(true);
|
||||
|
||||
ciface::Core::Device::Control* const ctrl =
|
||||
button->control_reference->Detect(DETECT_WAIT_TIME, dev);
|
||||
button->control_reference->Detect(DETECT_WAIT_TIME, dev.get());
|
||||
|
||||
// if we got input, update expression and reference
|
||||
if (ctrl)
|
||||
|
@ -724,16 +725,12 @@ void GamepadPage::DeleteProfile(wxCommandEvent&)
|
|||
|
||||
void InputConfigDialog::UpdateDeviceComboBox()
|
||||
{
|
||||
ciface::Core::DeviceQualifier dq;
|
||||
for (GamepadPage* page : m_padpages)
|
||||
{
|
||||
page->device_cbox->Clear();
|
||||
|
||||
for (ciface::Core::Device* d : g_controller_interface.Devices())
|
||||
{
|
||||
dq.FromDevice(d);
|
||||
page->device_cbox->Append(StrToWxStr(dq.ToString()));
|
||||
}
|
||||
for (const std::string& device_string : g_controller_interface.GetAllDeviceStrings())
|
||||
page->device_cbox->Append(StrToWxStr(device_string));
|
||||
|
||||
page->device_cbox->SetValue(StrToWxStr(page->controller->default_device.ToString()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue