MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / ReloadDevices

Method ReloadDevices

pcsx2/Input/DInputSource.cpp:111–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111bool DInputSource::ReloadDevices()
112{
113 // detect any removals
114 PollEvents();
115
116 // look for new devices
117 std::vector<DIDEVICEINSTANCEW> devices;
118 m_dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallback, &devices, DIEDFL_ATTACHEDONLY);
119
120 DevCon.WriteLn("Enumerated %zu devices", devices.size());
121
122 bool changed = false;
123 for (DIDEVICEINSTANCEW inst : devices)
124 {
125 // do we already have this one?
126 if (std::any_of(
127 m_controllers.begin(), m_controllers.end(), [&inst](const ControllerData& cd) { return inst.guidInstance == cd.guid; }))
128 {
129 // yup, so skip it
130 continue;
131 }
132
133 ControllerData cd;
134 cd.guid = inst.guidInstance;
135 HRESULT hr = m_dinput->CreateDevice(inst.guidInstance, cd.device.put(), nullptr);
136 if (FAILED(hr))
137 {
138 Console.Warning("Failed to create instance of device [%s, %s]", inst.tszProductName, inst.tszInstanceName);
139 continue;
140 }
141
142 const std::string name(StringUtil::WideStringToUTF8String(inst.tszProductName));
143 if (AddDevice(cd, name))
144 {
145 const u32 index = static_cast<u32>(m_controllers.size());
146 m_controllers.push_back(std::move(cd));
147 InputManager::OnInputDeviceConnected(GetDeviceIdentifier(index), name);
148 changed = true;
149 }
150 }
151
152 return changed;
153}
154
155void DInputSource::Shutdown()
156{

Callers

nothing calls this directly

Calls 9

WideStringToUTF8StringFunction · 0.85
WriteLnMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
CreateDeviceMethod · 0.45
putMethod · 0.45
WarningMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected