rawinput: fix incorrect usage of HidP_GetUsages when descriptor is not range (#565)

## Link to GitHub Issue or related Pull Request, if one exists
Fixes #563 

## Description of change
When buttons are presented as NotRange and instead an array of single
buttons, we are calling `HidP_GetUsages` expecting at most one result
back, but in reality we need to expect all possible buttons on that
usage page since `HidP_GetUsages` returns all buttons in the usage page
+ link collection which would be the entire array of buttons - see
documentation for `HidP_GetUsages` on MSDN.

## Testing
Tested with my own controller modifying USB descriptors... more
controller testing is needed.
This commit is contained in:
bicarus
2026-03-05 20:41:47 -08:00
committed by GitHub
parent 1e6b4c16cc
commit e4b08064b7
2 changed files with 71 additions and 33 deletions
+7
View File
@@ -4,6 +4,7 @@
#include <thread>
#include <mutex>
#include <vector>
#include <map>
#include <windows.h>
@@ -120,9 +121,15 @@ namespace rawinput {
std::vector<std::string> value_caps_names;
std::vector<HIDP_VALUE_CAPS> value_output_caps_list;
std::vector<std::string> value_output_caps_names;
std::vector<std::vector<bool>> button_states;
std::vector<std::vector<double>> button_up, button_down;
std::vector<std::vector<bool>> button_output_states;
// key: usage page, link collection
// value: number of buttons for that key (combine ranges and nonranges)
std::map<std::pair<USAGE, ULONG>, ULONG> button_usage_pages;
std::vector<float> value_states;
std::vector<LONG> value_states_raw;
std::vector<float> value_output_states;