mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 23:00:42 -07:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user