| 389 | static concurrency::concurrent_unordered_set <HANDLE> SK_Input_DeviceFiles; |
| 390 | |
| 391 | std::tuple <SK_Input_DeviceFileType, void*, bool> |
| 392 | SK_Input_GetDeviceFileAndState (HANDLE hFile) |
| 393 | { |
| 394 | // Unnecessary for now, since we only use a single list of HID |
| 395 | // devices... |
| 396 | #ifdef SK_HAS_DIFFERENT_DEVICE_CLASSES |
| 397 | // Bloom filter since most file reads -are not- for input devices |
| 398 | if ( SK_Input_DeviceFiles.find (hFile) == |
| 399 | SK_Input_DeviceFiles.cend ( ) ) |
| 400 | { |
| 401 | return |
| 402 | { SK_Input_DeviceFileType::None, nullptr, true }; |
| 403 | } |
| 404 | #endif |
| 405 | |
| 406 | // |
| 407 | // Figure out device type |
| 408 | // |
| 409 | if ( const auto hid_iter = SK_HID_DeviceFiles.find (hFile); |
| 410 | hid_iter != SK_HID_DeviceFiles.cend ( ) ) |
| 411 | { |
| 412 | auto& hid_device = |
| 413 | hid_iter->second; |
| 414 | |
| 415 | if (hid_device.device_type != sk_input_dev_type::Other) |
| 416 | { |
| 417 | return |
| 418 | { SK_Input_DeviceFileType::HID, &hid_device, hid_device.isInputAllowed () }; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | #ifdef SK_HAS_DIFFERENT_DEVICE_CLASSES |
| 423 | else if ( const auto nv_iter = SK_NVIDIA_DeviceFiles.find (hFile); |
| 424 | nv_iter != SK_NVIDIA_DeviceFiles.cend ( ) ) |
| 425 | { |
| 426 | return |
| 427 | { SK_Input_DeviceFileType::NVIDIA, &nv_iter->second, true }; |
| 428 | } |
| 429 | #endif |
| 430 | |
| 431 | return |
| 432 | { SK_Input_DeviceFileType::Invalid, nullptr, true }; |
| 433 | } |
| 434 | |
| 435 | SetupDiGetClassDevsW_pfn SK_SetupDiGetClassDevsW = nullptr; |
| 436 | SetupDiGetClassDevsExW_pfn SK_SetupDiGetClassDevsExW = nullptr; |
no test coverage detected