| 250 | } |
| 251 | |
| 252 | void DInputSource::PollEvents() |
| 253 | { |
| 254 | for (size_t i = 0; i < m_controllers.size();) |
| 255 | { |
| 256 | ControllerData& cd = m_controllers[i]; |
| 257 | if (cd.needs_poll) |
| 258 | cd.device->Poll(); |
| 259 | |
| 260 | DIJOYSTATE2 js; |
| 261 | HRESULT hr = cd.device->GetDeviceState(sizeof(js), &js); |
| 262 | if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) |
| 263 | { |
| 264 | hr = cd.device->Acquire(); |
| 265 | if (hr == DI_OK) |
| 266 | hr = cd.device->GetDeviceState(sizeof(js), &js); |
| 267 | |
| 268 | if (hr != DI_OK) |
| 269 | { |
| 270 | InputManager::OnInputDeviceDisconnected( |
| 271 | {{.source_type = InputSourceType::DInput, .source_index = static_cast<u32>(i)}}, |
| 272 | GetDeviceIdentifier(static_cast<u32>(i))); |
| 273 | m_controllers.erase(m_controllers.begin() + i); |
| 274 | continue; |
| 275 | } |
| 276 | } |
| 277 | else if (hr != DI_OK) |
| 278 | { |
| 279 | Console.Warning("GetDeviceState() failed: %08X", hr); |
| 280 | i++; |
| 281 | continue; |
| 282 | } |
| 283 | |
| 284 | CheckForStateChanges(i, js); |
| 285 | i++; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | std::vector<std::pair<std::string, std::string>> DInputSource::EnumerateDevices() |
| 290 | { |