mirror of
https://github.com/libretro/mame2003-plus-libretro.git
synced 2026-11-07 04:16:07 -10:00
libretro input: build the joystick list only when a controller layout changes
osd_get_joy_list() rebuilt the whole list (4 players x all codes) at every call, and the input code calls it at every key check: about 100 times a frame, some 750k instructions a frame whatever the game. It is now built again only when a port's layout changes. doapp, 600 frames (callgrind): retro_run 15.02 G -> 14.57 G instructions (-3%), video and audio identical frame by frame. The saving is per frame, so it is a larger share on lighter games. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MEgow1uRCv8pxMErKhmoHZ
This commit is contained in:
1 file changed
+11
@@ -1167,11 +1167,22 @@ struct JoystickInfo alternate_joystick_maps[MAX_PLAYER_COUNT][IDX_NUMBER_OF_INPU
|
||||
|
||||
struct JoystickInfo mame_joy_map[(MAX_PLAYER_COUNT * OSD_INPUT_CODES_PER_PLAYER) + 1] = { { 0 } }; /* + 1 for final zeroed struct */
|
||||
|
||||
/* the list only changes with the controller layouts: the input code asks for
|
||||
it at every key check (about 100 times a frame), so it is built again only
|
||||
when a layout changed */
|
||||
static unsigned joy_map_types[MAX_PLAYER_COUNT];
|
||||
static int joy_map_built;
|
||||
|
||||
const struct JoystickInfo *osd_get_joy_list(void)
|
||||
{
|
||||
unsigned needle = 0;
|
||||
unsigned port_number = 0;
|
||||
|
||||
if(joy_map_built && memcmp(joy_map_types, options.active_control_type, sizeof(joy_map_types)) == 0)
|
||||
return mame_joy_map;
|
||||
memcpy(joy_map_types, options.active_control_type, sizeof(joy_map_types));
|
||||
joy_map_built = 1;
|
||||
|
||||
for(port_number = 0; port_number < MAX_PLAYER_COUNT; port_number++)
|
||||
{
|
||||
int osd_code;
|
||||
|
||||
Reference in new issue
Block a user