U-DESKTOP-SPFP6AQ\twistedtechre 6adeffd85c (winraw_joypad) Optimizations:
* scale_axis — float→integer arithmetic (called per axis per report)
Replaced the double division, multiply, clamp, and convert chain with a single int64_t multiply-divide
* hat_value_to_bitmask — switch→LUT (called per hat per report)
Replaced the 8-case switch (which the compiler may or may not optimize into a jump table) with an explicit static const uint8_t[8] lookup table
* parse_hid_report — targeted memset + hoisted locals (hottest function)
* joypad_state — fully inlined (called every frame per port)
* WM_INPUT handler — stack buffer fast path
The old code always called GetRawInputData twice per message: once to get the size, once to read. Since most gamepad HID reports fit in ~64-128 bytes, the new code tries a 256-byte stack buffer first. On the common path this cuts the syscall count in half.
* joypad_poll — removed TranslateMessage
Our message-only window only gets WM_INPUT and WM_INPUT_DEVICE_CHANGE. TranslateMessage is for keyboard virtual-key translation — calling it here was pure overhead.
* Struct layout — hot/cold field separation
Moved connected, hDevice, num_buttons, axes[], hats[], buttons[] to the top of the struct so the fields touched on every poll and every report share cache lines. Cold fields like name[256], caps, and the capability pointers are pushed to the bottom.
2026-04-05 16:20:30 +02:00
..
2026-03-18 20:05:19 +02:00
2026-02-14 14:01:13 +01:00
2025-11-05 19:15:11 +01:00