mirror of
https://github.com/libretro/RetroArch.git
synced 2026-04-06 00:01:06 +08:00
* 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.