| 99 | } |
| 100 | |
| 101 | void HandlerWinEvents::resetDevice_( void* handle ) |
| 102 | { |
| 103 | RID_DEVICE_INFO info; |
| 104 | unsigned infoSize = sizeof( RID_DEVICE_INFO ); |
| 105 | info.cbSize = infoSize; |
| 106 | |
| 107 | GetRawInputDeviceInfo( handle, RIDI_DEVICEINFO, &info, &infoSize ); |
| 108 | |
| 109 | VendorId vId = VendorId( info.hid.dwVendorId ); |
| 110 | ProductId pId = VendorId( info.hid.dwProductId ); |
| 111 | if ( !device_ ) |
| 112 | { |
| 113 | device_ = std::make_unique<Device>(); |
| 114 | numMsg_ = 0; |
| 115 | |
| 116 | unsigned pathSize = 0; |
| 117 | GetRawInputDeviceInfo( handle, RIDI_DEVICENAME, NULL, &pathSize ); // get size |
| 118 | std::wstring path; |
| 119 | path.resize( pathSize ); |
| 120 | |
| 121 | std::wstring productString; |
| 122 | productString.resize( 256 ); |
| 123 | std::wstring manufacturerString; |
| 124 | manufacturerString.resize( 256 ); |
| 125 | |
| 126 | bool gotProdStr = false; |
| 127 | bool gotManufacturerStr = false; |
| 128 | |
| 129 | GetRawInputDeviceInfo( handle, RIDI_DEVICENAME, path.data(), &pathSize ); // get name |
| 130 | |
| 131 | auto hidHandler = CreateFile( path.data(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); |
| 132 | if ( hidHandler != INVALID_HANDLE_VALUE ) |
| 133 | { |
| 134 | gotProdStr = HidD_GetProductString( hidHandler, productString.data(), unsigned( productString.size() ) ); |
| 135 | gotManufacturerStr = HidD_GetManufacturerString( hidHandler, manufacturerString.data(), unsigned( manufacturerString.size() ) ); |
| 136 | CloseHandle( hidHandler ); |
| 137 | } |
| 138 | |
| 139 | if ( gotProdStr && gotManufacturerStr ) |
| 140 | { |
| 141 | spdlog::info( "WIN API device found: {:04x}:{:04x}, name={}:{}", |
| 142 | vId, pId, wideToUtf8( manufacturerString.c_str() ), wideToUtf8( productString.c_str() ) ); |
| 143 | TelemetrySignal( fmt::format( "WIN API device {:04x}:{:04x} found: {}:{}", |
| 144 | vId, pId, wideToUtf8( manufacturerString.c_str() ), wideToUtf8( productString.c_str() ) ) ); |
| 145 | } |
| 146 | |
| 147 | |
| 148 | spdlog::info( "SpaceMouse connected: {:04x}:{:04x}, path={}", vId, pId, wideToUtf8( path.c_str() ) ); |
| 149 | TelemetrySignal( fmt::format( "WIN API device {:04x}:{:04x} opened", vId, pId ) ); |
| 150 | } |
| 151 | device_->updateDevice( vId, pId ); |
| 152 | } |
| 153 | |
| 154 | } |
| 155 |
nothing calls this directly
no test coverage detected