Skip to content

Commit

Permalink
Swap port and device; Add extra debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
XerTheSquirrel committed Dec 25, 2023
1 parent a5cfcfc commit da49581
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libretro-common/include/libretro.h
Original file line number Diff line number Diff line change
Expand Up @@ -3384,12 +3384,12 @@ struct retro_core_extended_retropad_button
/** The controller port or player this is attached to. */
unsigned port;

/** The index of the device. */
unsigned index;

/** The device that this is associated with, either @c RETRO_DEVICE_JOYPAD or @c RETRO_DEVICE_ANALOG. */
unsigned device;

/** The index of the device. */
unsigned index;

/**
* The logical bind ID number of the specific command.
* The value will be between @c 0 and @c out_num_extra .
Expand Down
17 changes: 15 additions & 2 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ static void rarch_set_core_extended_retropad(rarch_system_info_t *sys_info,
const char** user_inputs;

/* Debug. */
RARCH_LOG("[Core]: Initializing extra core buttons!\n");
RARCH_LOG("[Environ]: Setting extended retropad buttons.\n");

/* Erase all the previous extended binds for all users. */
rarch_erase_input_desc_btn(sys_info,
Expand Down Expand Up @@ -1473,8 +1473,15 @@ static void rarch_set_core_extended_retropad(rarch_system_info_t *sys_info,

/* Set description. */
sys_info->input_desc_btn[usernum][bind] = action->description;

/* Debug. */
RARCH_LOG("[Environ]: Bound %d to %s.\n",
bind, action->description);
}

/* Debug. */
RARCH_LOG("[Environ]: Set %d extended buttons.\n", at);

/* Indicate that the input descriptors changed. */
runloop_st->current_core.flags |=
RETRO_CORE_FLAG_HAS_SET_EXTENDED_INPUT;
Expand All @@ -1486,9 +1493,15 @@ static void rarch_set_input_descriptors(const void *data,
unsigned retro_id;
const struct retro_input_descriptor *desc = NULL;
unsigned int p;
bool did_extra;

/* Check if extended inputs were set. */
did_extra = (runloop_st->current_core.flags & RETRO_CORE_FLAG_HAS_SET_EXTENDED_INPUT) != 0;
if (!did_extra)
RARCH_LOG("[Environ]: SET_INPUT_DESCRIPTORS: Extra was not previously set.\n");

/* If extended descriptors were set, only erase the standard ones. */
if ((runloop_st->current_core.flags & RETRO_CORE_FLAG_HAS_SET_EXTENDED_INPUT) != 0)
if (did_extra)
rarch_erase_input_desc_btn(sys_info, 0, rarch_first_logical_bind_game_controller());

/* Otherwise, erase everything to keep legacy behavior. */
Expand Down

0 comments on commit da49581

Please sign in to comment.