misc: various performance clean up (#844)

## Link to GitHub Issue or related Pull Request, if one exists
n/a

## Description of change

- Replace unnecessary precision timers with standard sleeps to reduce
wakeups and background CPU usage.
- Reuse buffers in raw input, touchscreen, and HID output paths to
eliminate steady-state allocations.
- Pre-index HID button groups and correctly process batched HID reports.

No functional changes.

## Testing
This commit is contained in:
bicarus
2026-07-28 21:05:32 -07:00
committed by GitHub
parent 7ccd938f9b
commit 5cabd026ae
10 changed files with 139 additions and 106 deletions
+12 -5
View File
@@ -4,7 +4,6 @@
#include <thread>
#include <mutex>
#include <vector>
#include <map>
#include <windows.h>
@@ -103,6 +102,13 @@ namespace rawinput {
std::vector<HIDTouchPoint> touch_points;
};
struct HIDButtonInputGroup {
USAGE usage_page;
USHORT link_collection;
std::vector<size_t> cap_indices;
std::vector<USAGE> usages;
};
struct DeviceHIDInfo {
HANDLE handle;
_HIDP_CAPS caps;
@@ -125,11 +131,12 @@ namespace rawinput {
std::vector<std::vector<bool>> button_states;
std::vector<std::vector<double>> button_up, button_down;
std::vector<std::vector<uint8_t>> button_report_states;
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<HIDButtonInputGroup> button_input_groups;
std::vector<CHAR> output_report;
std::vector<USAGE> button_output_usages;
std::vector<USAGE> button_output_usages_off;
std::vector<float> value_states;
std::vector<LONG> value_states_raw;