Overlay cleanups; replace bools with flags (#14661)

This commit is contained in:
neil4 2022-11-22 11:29:11 -06:00 committed by GitHub
parent 92e0403aeb
commit 3b0db75782
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 175 additions and 144 deletions

View file

@ -1144,7 +1144,7 @@ static bool input_overlay_add_inputs_inner(overlay_desc_t *desc,
{
int i;
/* Check each bank of the mask */
/* Check custom binds in the mask */
for (i = 0; i < CUSTOM_BINDS_U32_COUNT; ++i)
{
/* Get bank */
@ -1185,31 +1185,29 @@ static bool input_overlay_add_inputs_inner(overlay_desc_t *desc,
case OVERLAY_TYPE_ANALOG_LEFT:
case OVERLAY_TYPE_ANALOG_RIGHT:
if (ol_state)
{
if (ol_state)
{
unsigned index_offset = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? 2 : 0;
desc->updated |= (ol_state->analog[index_offset] |
ol_state->analog[index_offset + 1]);
}
else
{
unsigned index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
float analog_x = input_state_internal(port, RETRO_DEVICE_ANALOG,
index, RETRO_DEVICE_ID_ANALOG_X);
float analog_y = input_state_internal(port, RETRO_DEVICE_ANALOG,
index, RETRO_DEVICE_ID_ANALOG_Y);
/* Only modify overlay delta_x/delta_y values
* if we are monitoring input from a physical
* controller */
desc->delta_x = (analog_x / (float)0x8000) * (desc->range_x / 2.0f);
desc->delta_y = (analog_y / (float)0x8000) * (desc->range_y / 2.0f);
}
return (desc->updated != 0);
unsigned index_offset = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? 2 : 0;
desc->updated |= (ol_state->analog[index_offset] |
ol_state->analog[index_offset + 1]);
}
else
{
unsigned index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
float analog_x = input_state_internal(port, RETRO_DEVICE_ANALOG,
index, RETRO_DEVICE_ID_ANALOG_X);
float analog_y = input_state_internal(port, RETRO_DEVICE_ANALOG,
index, RETRO_DEVICE_ID_ANALOG_Y);
/* Only modify overlay delta_x/delta_y values
* if we are monitoring input from a physical
* controller */
desc->delta_x = (analog_x / (float)0x8000) * (desc->range_x / 2.0f);
desc->delta_y = (analog_y / (float)0x8000) * (desc->range_y / 2.0f);
}
return (desc->updated != 0);
case OVERLAY_TYPE_DPAD_AREA:
case OVERLAY_TYPE_ABXY_AREA:
@ -1403,7 +1401,7 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y)
/**
* input_overlay_poll:
* @out : Polled output data.
* @ptr_idx : Pointer index
* @ptr_idx : Input pointer index.
* @norm_x : Normalized X coordinate.
* @norm_y : Normalized Y coordinate.
*
@ -1446,10 +1444,10 @@ void input_overlay_poll(
/* Check for exclusive hitbox, which blocks other input.
* range_mod_exclusive has priority over exclusive. */
if (desc->range_mod_exclusive
if ((desc->flags & OVERLAY_DESC_RANGE_MOD_EXCLUSIVE)
&& desc->range_x_mod != desc->range_x_hitbox)
desc_prio = 2;
else if (desc->exclusive)
else if (desc->flags & OVERLAY_DESC_EXCLUSIVE)
desc_prio = 1;
if (highest_prio > desc_prio)
@ -1503,7 +1501,7 @@ void input_overlay_poll(
break;
}
if (desc->movable)
if (desc->flags & OVERLAY_DESC_MOVABLE)
{
desc->delta_x = clamp_float(x_dist, -desc->range_x, desc->range_x)
* ol->active->mod_w;
@ -1513,8 +1511,8 @@ void input_overlay_poll(
}
if (!bits_any_set(out->buttons.data, ARRAY_SIZE(out->buttons.data)))
ol->blocked = false;
else if (ol->blocked)
ol->flags &= ~INPUT_OVERLAY_BLOCKED;
else if (ol->flags & INPUT_OVERLAY_BLOCKED)
memset(out, 0, sizeof(*out));
}
@ -1528,7 +1526,7 @@ void input_overlay_poll(
static void input_overlay_update_desc_geom(input_overlay_t *ol,
struct overlay_desc *desc)
{
if (!desc->image.pixels || !desc->movable)
if (!desc->image.pixels || !(desc->flags & OVERLAY_DESC_MOVABLE))
return;
if (ol->iface->vertex_geom)
@ -1706,7 +1704,7 @@ void input_overlay_parse_layout(
/* Sanity check - if scaling is blocked,
* or aspect ratios are invalid, then we
* can do nothing */
if (ol->block_scale ||
if ((ol->flags & OVERLAY_BLOCK_SCALE) ||
(ol->aspect_ratio <= 0.0f) ||
(display_aspect_ratio <= 0.0f))
return;
@ -1727,7 +1725,7 @@ void input_overlay_parse_layout(
/* If X separation is permitted, move elements
* horizontally towards the edges of the screen */
if (!ol->block_x_separation)
if (!(ol->flags & OVERLAY_BLOCK_X_SEPARATION))
overlay_layout->x_separation = ((1.0f / overlay_layout->x_scale) - 1.0f) * 0.5f;
}
/* If display is taller than overlay,
@ -1750,7 +1748,7 @@ void input_overlay_parse_layout(
* below the centre line, so Y separation
* provides no real benefit */
if ((display_aspect_ratio > 1.0f) &&
!ol->block_y_separation)
!(ol->flags & OVERLAY_BLOCK_Y_SEPARATION))
overlay_layout->y_separation = ((1.0f / overlay_layout->y_scale) - 1.0f) * 0.5f;
}
@ -1770,12 +1768,12 @@ void input_overlay_parse_layout(
overlay_layout->x_offset = layout_desc->x_offset_landscape;
overlay_layout->y_offset = layout_desc->y_offset_landscape * -1.0f;
if (!ol->block_x_separation)
if (!(ol->flags & OVERLAY_BLOCK_X_SEPARATION))
overlay_layout->x_separation = layout_desc->x_separation_landscape;
if (!ol->block_y_separation)
if (!(ol->flags & OVERLAY_BLOCK_Y_SEPARATION))
overlay_layout->y_separation = layout_desc->y_separation_landscape;
if (!ol->block_scale)
if (!(ol->flags & OVERLAY_BLOCK_SCALE))
{
/* In landscape orientations, aspect correction
* adjusts the overlay width */
@ -1794,12 +1792,12 @@ void input_overlay_parse_layout(
overlay_layout->x_offset = layout_desc->x_offset_portrait;
overlay_layout->y_offset = layout_desc->y_offset_portrait * -1.0f;
if (!ol->block_x_separation)
if (!(ol->flags & OVERLAY_BLOCK_X_SEPARATION))
overlay_layout->x_separation = layout_desc->x_separation_portrait;
if (!ol->block_y_separation)
if (!(ol->flags & OVERLAY_BLOCK_Y_SEPARATION))
overlay_layout->y_separation = layout_desc->y_separation_portrait;
if (!ol->block_scale)
if (!(ol->flags & OVERLAY_BLOCK_SCALE))
{
/* In portrait orientations, aspect correction
* adjusts the overlay height */
@ -1845,7 +1843,8 @@ void input_overlay_load_active(
input_overlay_set_vertex_geom(ol);
if (ol->iface->full_screen)
ol->iface->full_screen(ol->iface_data, ol->active->full_screen);
ol->iface->full_screen(ol->iface_data,
(ol->active->flags & OVERLAY_FULL_SCREEN));
}
void input_overlay_poll_clear(
@ -1854,7 +1853,7 @@ void input_overlay_poll_clear(
{
size_t i;
ol->blocked = false;
ol->flags &= ~INPUT_OVERLAY_BLOCKED;
input_overlay_set_alpha_mod(visibility, ol, opacity);
@ -1963,7 +1962,7 @@ void input_overlay_auto_rotate_(
bool tmp = false;
/* Sanity check */
if (!ol || !ol->alive || !input_overlay_enable)
if (!ol || !(ol->flags & INPUT_OVERLAY_ALIVE) || !input_overlay_enable)
return;
/* Get current screen orientation */
@ -2032,7 +2031,6 @@ void input_poll_overlay(
int i, j;
input_overlay_t *ol = (input_overlay_t*)ol_data;
uint16_t key_mod = 0;
bool polled = false;
bool button_pressed = false;
input_driver_state_t *input_st = &input_driver_st;
void *input_data = input_st->current_data;
@ -2044,8 +2042,8 @@ void input_poll_overlay(
unsigned input_overlay_show_inputs_port = settings->uints.input_overlay_show_inputs_port;
float touch_scale = (float)settings->uints.input_touch_scale;
bool osk_state_changed = false;
unsigned pointer_count = 0;
static unsigned old_pointer_count;
unsigned touch_count = 0;
static unsigned old_touch_count;
if (!ol_state)
return;
@ -2057,7 +2055,7 @@ void input_poll_overlay(
if (current_input->input_state)
{
rarch_joypad_info_t joypad_info;
unsigned device = ol->active->full_screen
unsigned device = (ol->active->flags & OVERLAY_FULL_SCREEN)
? RARCH_DEVICE_POINTER_SCREEN
: RETRO_DEVICE_POINTER;
const input_device_driver_t
@ -2114,10 +2112,10 @@ void input_poll_overlay(
memset(&polled_data, 0, sizeof(struct input_overlay_state));
if (ol->enable)
if (ol->flags & INPUT_OVERLAY_ENABLE)
input_overlay_poll(ol, &polled_data, i, x, y, touch_scale);
else
ol->blocked = false;
ol->flags &= ~INPUT_OVERLAY_BLOCKED;
bits_or_bits(ol_state->buttons.data,
polled_data.buttons.data,
@ -2131,19 +2129,17 @@ void input_poll_overlay(
for (j = 0; j < 4; j++)
if (polled_data.analog[j])
ol_state->analog[j] = polled_data.analog[j];
polled = true;
}
pointer_count = i;
touch_count = i;
}
if ( OVERLAY_GET_KEY(ol_state, RETROK_LSHIFT) ||
OVERLAY_GET_KEY(ol_state, RETROK_RSHIFT))
key_mod |= RETROKMOD_SHIFT;
if (OVERLAY_GET_KEY(ol_state, RETROK_LCTRL) ||
OVERLAY_GET_KEY(ol_state, RETROK_RCTRL))
if ( OVERLAY_GET_KEY(ol_state, RETROK_LCTRL) ||
OVERLAY_GET_KEY(ol_state, RETROK_RCTRL))
key_mod |= RETROKMOD_CTRL;
if ( OVERLAY_GET_KEY(ol_state, RETROK_LALT) ||
@ -2228,18 +2224,18 @@ void input_poll_overlay(
if (input_overlay_show_inputs == OVERLAY_SHOW_INPUT_NONE)
button_pressed = false;
if (button_pressed || polled)
if (button_pressed || touch_count)
input_overlay_post_poll(overlay_visibility, ol,
button_pressed, opacity);
else
input_overlay_poll_clear(overlay_visibility, ol, opacity);
/* Create haptic feedback for any change in button/key state,
* unless pointer_count decreased. */
* unless touch_count decreased. */
if ( current_input->keypress_vibrate
&& settings->bools.vibrate_on_keypress
&& pointer_count && pointer_count >= old_pointer_count
&& !ol->blocked)
&& touch_count && touch_count >= old_touch_count
&& !(ol->flags & INPUT_OVERLAY_BLOCKED))
{
if ( osk_state_changed
|| bits_any_different(
@ -2250,7 +2246,7 @@ void input_poll_overlay(
current_input->keypress_vibrate();
}
old_pointer_count = pointer_count;
old_touch_count = touch_count;
}
#endif
@ -3537,7 +3533,7 @@ static void input_overlay_loaded(retro_task_t *task,
if (err)
return;
if (data->overlay_enable)
if (data->flags & OVERLAY_LOADER_ENABLE)
{
#ifdef HAVE_MENU
struct menu_state *menu_st = menu_state_get_ptr();
@ -3551,19 +3547,19 @@ static void input_overlay_loaded(retro_task_t *task,
}
/* We can't display when the menu is up */
if ( data->hide_in_menu
&& (menu_st->flags & MENU_ST_FLAG_ALIVE))
if ( (data->flags & OVERLAY_LOADER_HIDE_IN_MENU) &&
(menu_st->flags & MENU_ST_FLAG_ALIVE))
goto abort_load;
#endif
/* If 'hide_when_gamepad_connected' is enabled,
* we can't display when a gamepad is connected */
if (data->hide_when_gamepad_connected &&
(input_config_get_device_name(0) != NULL))
if ( (data->flags & OVERLAY_LOADER_HIDE_WHEN_GAMEPAD_CONNECTED) &&
(input_config_get_device_name(0) != NULL))
goto abort_load;
}
if ( !data->overlay_enable ||
if ( !(data->flags & OVERLAY_LOADER_ENABLE) ||
!video_driver_overlay_interface(&iface) ||
!iface)
{
@ -3583,17 +3579,20 @@ static void input_overlay_loaded(retro_task_t *task,
ol, data->overlay_opacity);
/* Enable or disable the overlay. */
ol->enable = data->overlay_enable;
if (data->flags & OVERLAY_LOADER_ENABLE)
ol->flags |= INPUT_OVERLAY_ENABLE;
else
ol->flags &= ~INPUT_OVERLAY_ENABLE;
if (ol->iface->enable)
ol->iface->enable(ol->iface_data, data->overlay_enable);
ol->iface->enable(ol->iface_data, (ol->flags & INPUT_OVERLAY_ENABLE));
input_overlay_set_scale_factor(ol, &data->layout_desc,
video_st->width, video_st->height);
ol->next_index = (unsigned)((ol->index + 1) % ol->size);
ol->state = OVERLAY_STATUS_NONE;
ol->alive = true;
ol->flags |= INPUT_OVERLAY_ALIVE;
/* Due to the asynchronous nature of overlay loading
* it is possible for overlay_ptr to be non-NULL here
@ -3928,7 +3927,7 @@ int16_t input_state_device(
* corresponding to 'id' has been pressed */
if ( (port == 0)
&& input_st->overlay_ptr
&& input_st->overlay_ptr->alive
&& (input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE)
&& BIT256_GET(input_st->overlay_ptr->overlay_state.buttons, id))
{
#ifdef HAVE_MENU
@ -4070,7 +4069,8 @@ MENU_ST_FLAG_ALIVE;
#ifdef HAVE_OVERLAY
if (port == 0)
{
if (input_st->overlay_ptr && input_st->overlay_ptr->alive)
if (input_st->overlay_ptr
&& (input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE))
{
input_overlay_state_t
*ol_state = &input_st->overlay_ptr->overlay_state;
@ -4136,7 +4136,7 @@ MENU_ST_FLAG_ALIVE;
#ifdef HAVE_OVERLAY
if (input_st->overlay_ptr &&
input_st->overlay_ptr->alive &&
(input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE) &&
(port == 0) &&
(idx != RETRO_DEVICE_INDEX_ANALOG_BUTTON) &&
!(((input_analog_dpad_mode == ANALOG_DPAD_LSTICK) &&
@ -4286,7 +4286,8 @@ void input_driver_poll(void)
}
#ifdef HAVE_OVERLAY
if (input_st->overlay_ptr && input_st->overlay_ptr->alive)
if (input_st->overlay_ptr &&
(input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE))
{
unsigned input_analog_dpad_mode = settings->uints.input_analog_dpad_mode[0];
@ -4328,7 +4329,8 @@ void input_driver_poll(void)
{
#ifdef HAVE_OVERLAY
input_overlay_t *overlay_pointer = (input_overlay_t*)input_st->overlay_ptr;
bool poll_overlay = (input_st->overlay_ptr && input_st->overlay_ptr->alive);
bool poll_overlay = (overlay_pointer &&
(overlay_pointer->flags & INPUT_OVERLAY_ALIVE));
#endif
input_mapper_t *handle = &input_st->mapper;
float input_analog_deadzone = settings->floats.input_analog_deadzone;

View file

@ -121,6 +121,38 @@ enum overlay_show_input_type
OVERLAY_SHOW_INPUT_LAST
};
enum OVERLAY_LOADER_FLAGS
{
OVERLAY_LOADER_ENABLE = (1 << 0),
OVERLAY_LOADER_HIDE_IN_MENU = (1 << 1),
OVERLAY_LOADER_HIDE_WHEN_GAMEPAD_CONNECTED = (1 << 2),
OVERLAY_LOADER_RGBA_SUPPORT = (1 << 3)
};
enum INPUT_OVERLAY_FLAGS
{
INPUT_OVERLAY_ENABLE = (1 << 0),
INPUT_OVERLAY_ALIVE = (1 << 1),
INPUT_OVERLAY_BLOCKED = (1 << 2)
};
enum OVERLAY_FLAGS
{
OVERLAY_FULL_SCREEN = (1 << 0),
OVERLAY_BLOCK_SCALE = (1 << 1),
OVERLAY_BLOCK_X_SEPARATION = (1 << 2),
OVERLAY_BLOCK_Y_SEPARATION = (1 << 3)
};
enum OVERLAY_DESC_FLAGS
{
OVERLAY_DESC_MOVABLE = (1 << 0),
/* If true, blocks input from overlapped hitboxes */
OVERLAY_DESC_EXCLUSIVE = (1 << 1),
/* Similar, but only applies after range_mod takes effect */
OVERLAY_DESC_RANGE_MOD_EXCLUSIVE = (1 << 2)
};
typedef struct overlay_eightway_config
{
input_bits_t up;
@ -145,8 +177,6 @@ struct overlay_desc
enum overlay_hitbox hitbox;
enum overlay_type type;
uint16_t updated; /* one bit per pointer */
unsigned next_index;
unsigned image_index;
@ -175,13 +205,6 @@ struct overlay_desc
float range_x_hitbox, range_y_hitbox;
float reach_right, reach_left, reach_up, reach_down;
/* If true, blocks input from overlapped hitboxes */
bool exclusive;
/* Similar, but only applies after range_mod takes effect */
bool range_mod_exclusive;
bool movable;
/* This is a retro_key value for keyboards */
unsigned retro_key_idx;
@ -191,6 +214,11 @@ struct overlay_desc
overlay_eightway_config_t *eightway_config;
char next_index_name[64];
/* Nonzero if pressed. One bit per input pointer */
uint16_t updated;
uint8_t flags;
};
@ -244,12 +272,9 @@ struct overlay
bool normalized;
} config;
bool full_screen;
bool block_scale;
bool block_x_separation;
bool block_y_separation;
char name[64];
uint8_t flags;
};
typedef struct input_overlay_state
@ -276,9 +301,7 @@ struct input_overlay
enum overlay_status state;
bool enable;
bool blocked;
bool alive;
uint8_t flags;
};
/* Holds general layout information for an
@ -325,10 +348,8 @@ typedef struct
size_t size;
float overlay_opacity;
overlay_layout_desc_t layout_desc;
bool overlay_enable;
bool hide_in_menu;
bool hide_when_gamepad_connected;
uint16_t overlay_types;
uint8_t flags;
} overlay_task_data_t;
void input_overlay_free_overlay(struct overlay *overlay);

View file

@ -5669,7 +5669,7 @@ unsigned menu_event(
bool input_overlay_enable = settings->bools.input_overlay_enable;
bool overlay_active = input_overlay_enable
&& (input_st->overlay_ptr)
&& (input_st->overlay_ptr->alive);
&& (input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE);
#else
bool input_overlay_enable = false;
bool overlay_active = false;
@ -6838,7 +6838,7 @@ void retroarch_menu_running(void)
menu_st->flags & MENU_ST_FLAG_ALIVE,
#ifdef HAVE_OVERLAY
input_st->overlay_ptr &&
input_st->overlay_ptr->alive,
(input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE),
#else
false,
#endif
@ -6907,7 +6907,7 @@ void retroarch_menu_running_finished(bool quit)
menu_st->flags & MENU_ST_FLAG_ALIVE,
#ifdef HAVE_OVERLAY
input_st->overlay_ptr &&
input_st->overlay_ptr->alive,
(input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE),
#else
false,
#endif

View file

@ -2134,7 +2134,7 @@ bool command_event(enum event_command cmd, void *data)
input_overlay_load_active(input_st->overlay_visibility,
input_st->overlay_ptr, input_overlay_opacity);
input_st->overlay_ptr->blocked = true;
input_st->overlay_ptr->flags |= INPUT_OVERLAY_BLOCKED;
input_st->overlay_ptr->next_index = (unsigned)((input_st->overlay_ptr->index + 1) % input_st->overlay_ptr->size);
/* Check orientation, if required */

View file

@ -52,12 +52,9 @@ struct overlay_loader
enum overlay_status state;
enum overlay_image_transfer_status loading_status;
bool driver_rgba_support;
bool overlay_enable;
bool overlay_hide_in_menu;
bool overlay_hide_when_gamepad_connected;
uint16_t overlay_types;
uint8_t flags;
};
static void task_overlay_image_done(struct overlay *overlay)
@ -92,7 +89,7 @@ static void task_overlay_load_desc_image(
fill_pathname_resolve_relative(path, loader->overlay_path,
image_path, sizeof(path));
image_tex.supports_rgba = loader->driver_rgba_support;
image_tex.supports_rgba = (loader->flags & OVERLAY_LOADER_RGBA_SUPPORT);
if (image_texture_load(&image_tex, path))
{
@ -466,24 +463,27 @@ static bool task_overlay_load_desc(
snprintf(conf_key, sizeof(conf_key),
"overlay%u_desc%u_exclusive", ol_idx, desc_idx);
desc->exclusive = false;
if (config_get_bool(conf, conf_key, &tmp_bool))
desc->exclusive = tmp_bool;
desc->flags &= ~OVERLAY_DESC_EXCLUSIVE;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
desc->flags |= OVERLAY_DESC_EXCLUSIVE;
snprintf(conf_key, sizeof(conf_key),
"overlay%u_desc%u_range_mod_exclusive", ol_idx, desc_idx);
desc->range_mod_exclusive = false;
if (config_get_bool(conf, conf_key, &tmp_bool))
desc->range_mod_exclusive = tmp_bool;
desc->flags &= ~OVERLAY_DESC_RANGE_MOD_EXCLUSIVE;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
desc->flags |= OVERLAY_DESC_RANGE_MOD_EXCLUSIVE;
snprintf(conf_key, sizeof(conf_key),
"overlay%u_desc%u_movable", ol_idx, desc_idx);
desc->movable = false;
desc->delta_x = 0.0f;
desc->delta_y = 0.0f;
desc->flags &= ~OVERLAY_DESC_MOVABLE;
desc->delta_x = 0.0f;
desc->delta_y = 0.0f;
if (config_get_bool(conf, conf_key, &tmp_bool))
desc->movable = tmp_bool;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
desc->flags |= OVERLAY_DESC_MOVABLE;
input_overlay->pos ++;
@ -712,9 +712,10 @@ static void task_overlay_deferred_load(retro_task_t *task)
snprintf(overlay_full_screen_key, sizeof(overlay_full_screen_key),
"overlay%u_full_screen", loader->pos);
overlay->full_screen = false;
if (config_get_bool(conf, overlay_full_screen_key, &tmp_bool))
overlay->full_screen = tmp_bool;
overlay->flags &= ~OVERLAY_FULL_SCREEN;
if (config_get_bool(conf, overlay_full_screen_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_FULL_SCREEN;
overlay->config.normalized = false;
overlay->config.alpha_mod = 1.0f;
@ -723,7 +724,8 @@ static void task_overlay_deferred_load(retro_task_t *task)
snprintf(conf_key, sizeof(conf_key),
"overlay%u_normalized", loader->pos);
if (config_get_bool(conf, conf_key, &tmp_bool))
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->config.normalized = tmp_bool;
snprintf(conf_key, sizeof(conf_key), "overlay%u_alpha_mod", loader->pos);
@ -765,7 +767,8 @@ static void task_overlay_deferred_load(retro_task_t *task)
loader->overlay_path,
overlay->config.paths.path, sizeof(overlay_resolved_path));
image_tex.supports_rgba = loader->driver_rgba_support;
image_tex.supports_rgba =
(loader->flags & OVERLAY_LOADER_RGBA_SUPPORT);
if (!image_texture_load(&image_tex, overlay_resolved_path))
{
@ -837,7 +840,7 @@ static void task_overlay_deferred_load(retro_task_t *task)
/* Assume for now that scaling center is in the middle.
* TODO: Make this configurable. */
overlay->block_scale = false;
overlay->flags &= ~OVERLAY_BLOCK_SCALE;
overlay->center_x = overlay->x + 0.5f * overlay->w;
overlay->center_y = overlay->y + 0.5f * overlay->h;
@ -845,15 +848,17 @@ static void task_overlay_deferred_load(retro_task_t *task)
* for this overlay */
snprintf(conf_key, sizeof(conf_key),
"overlay%u_block_x_separation", loader->pos);
overlay->block_x_separation = false;
if (config_get_bool(conf, conf_key, &tmp_bool))
overlay->block_x_separation = tmp_bool;
overlay->flags &= ~OVERLAY_BLOCK_X_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_BLOCK_X_SEPARATION;
snprintf(conf_key, sizeof(conf_key),
"overlay%u_block_y_separation", loader->pos);
overlay->block_y_separation = false;
if (config_get_bool(conf, conf_key, &tmp_bool))
overlay->block_y_separation = tmp_bool;
overlay->flags &= ~OVERLAY_BLOCK_Y_SEPARATION;
if (config_get_bool(conf, conf_key, &tmp_bool)
&& tmp_bool)
overlay->flags |= OVERLAY_BLOCK_Y_SEPARATION;
}
return;
@ -927,9 +932,7 @@ static void task_overlay_handler(retro_task_t *task)
data->active = loader->active;
data->size = loader->size;
data->overlay_opacity = loader->overlay_opacity;
data->overlay_enable = loader->overlay_enable;
data->hide_in_menu = loader->overlay_hide_in_menu;
data->hide_when_gamepad_connected = loader->overlay_hide_when_gamepad_connected;
data->flags = loader->flags;
data->overlay_types = loader->overlay_types;
memcpy(&data->layout_desc, &loader->layout_desc,
@ -1010,21 +1013,26 @@ bool task_push_overlay_load_default(
return false;
}
loader->overlay_hide_in_menu = overlay_hide_in_menu;
loader->overlay_hide_when_gamepad_connected = overlay_hide_when_gamepad_connected;
loader->overlay_enable = input_overlay_enable;
loader->overlay_opacity = input_overlay_opacity;
loader->conf = conf;
loader->state = OVERLAY_STATUS_DEFERRED_LOAD;
loader->pos_increment = (loader->size / 4) ? (loader->size / 4) : 4;
loader->overlay_opacity = input_overlay_opacity;
loader->conf = conf;
loader->state = OVERLAY_STATUS_DEFERRED_LOAD;
loader->pos_increment = (loader->size / 4) ? (loader->size / 4) : 4;
if (overlay_hide_in_menu)
loader->flags |= OVERLAY_LOADER_HIDE_IN_MENU;
if (overlay_hide_when_gamepad_connected)
loader->flags |= OVERLAY_LOADER_HIDE_WHEN_GAMEPAD_CONNECTED;
if (input_overlay_enable)
loader->flags |= OVERLAY_LOADER_ENABLE;
#ifdef RARCH_INTERNAL
loader->driver_rgba_support = video_driver_supports_rgba();
if (video_driver_supports_rgba())
loader->flags |= OVERLAY_LOADER_RGBA_SUPPORT;
#endif
memcpy(&loader->layout_desc, layout_desc,
sizeof(overlay_layout_desc_t));
t = task_init();
t = task_init();
if (!t)
{
@ -1034,13 +1042,13 @@ bool task_push_overlay_load_default(
return false;
}
loader->overlay_path = strdup(overlay_path);
loader->overlay_path = strdup(overlay_path);
t->handler = task_overlay_handler;
t->cleanup = task_overlay_free;
t->state = loader;
t->callback = cb;
t->user_data = user_data;
t->handler = task_overlay_handler;
t->cleanup = task_overlay_free;
t->state = loader;
t->callback = cb;
t->user_data = user_data;
task_queue_push(t);