rawinput: avoid deadlock when binding analog axis as a button (#809)

## Link to GitHub Issue or related Pull Request, if one exists
Regressed by #793

## Description of change
Due to lock inversion, when binding an analog axis as a button, spice
deadlocks. Fix that.

Also create a separate `unordered_map` that keeps track of device
handles so that `WM_INPUT` handle can look up devices without having to
acquire the larger `devices_mutex` which could be held by (potentially)
lengthy operations like hotplug.

Fix more synchronization issues around hotplug. Latent bug exposed by
MIDI 2.0 issues.

## Testing
This commit is contained in:
bicarus
2026-07-18 03:09:27 -07:00
committed by GitHub
parent e1d1b39567
commit c080bbe301
8 changed files with 160 additions and 78 deletions
+4 -2
View File
@@ -197,8 +197,8 @@ namespace rawinput {
HANDLE handle = INVALID_HANDLE_VALUE;
DeviceType type = UNKNOWN;
DeviceInfo info;
std::mutex *mutex;
std::mutex *mutex_out;
std::mutex *mutex = nullptr;
std::mutex *mutex_out = nullptr;
bool updated = true;
bool output_pending = true;
bool output_enabled = false;
@@ -213,5 +213,7 @@ namespace rawinput {
double input_time = 0.0;
double input_hz = 0.f;
double input_hz_max = 0.f;
// when adding or removing a field, update replace_device_slot to match
};
}