Skip to content

Commit 3cbe9fa

Browse files
author
Lhaete
authored
Update xmb.c with "Kiosk Mode Fix"
Added Kiosk Mode Fix
1 parent c74164c commit 3cbe9fa

1 file changed

Lines changed: 106 additions & 17 deletions

File tree

menu/drivers/xmb.c

Lines changed: 106 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ typedef struct xmb_handle
473473

474474
/* Whether to show entry index for current list */
475475
bool entry_idx_enabled;
476+
477+
/* Kiosk Mode Fix - Makes sure we only call our function once after menu is ready */
478+
bool is_kiosk_init;
479+
476480
} xmb_handle_t;
477481

478482
static float xmb_scale_mod[8] = {
@@ -5855,6 +5859,12 @@ static enum menu_action xmb_parse_menu_entry_action(
58555859
}
58565860
else
58575861
{
5862+
/* Kiosk Mode Fix - Only jump to Main Menu if not in Kiosk Mode!*/
5863+
settings_t *settings = config_get_ptr();
5864+
if(settings->bools.kiosk_mode_enable)
5865+
{
5866+
return MENU_ACTION_NOOP;
5867+
}
58585868
/* Jump to Main Menu */
58595869
size_t i = 0;
58605870
size_t current_tab = xmb->categories_selection_ptr;
@@ -6507,11 +6517,14 @@ static bool xmb_context_reset_textures(
65076517
}
65086518
}
65096519
}
6510-
6511-
xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU];
6512-
xmb->main_menu_node.alpha = xmb->categories_active_alpha;
6513-
xmb->main_menu_node.zoom = xmb->categories_active_zoom;
6514-
6520+
/* Kiosk Mode Fix - Hide Main Menu Icon if kiosk mode is enabled */
6521+
settings_t *settings = config_get_ptr();
6522+
if (!settings->bools.kiosk_mode_enable)
6523+
{
6524+
xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU];
6525+
xmb->main_menu_node.alpha = xmb->categories_active_alpha;
6526+
xmb->main_menu_node.zoom = xmb->categories_active_zoom;
6527+
}
65156528
xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS];
65166529
xmb->settings_tab_node.alpha = xmb->categories_active_alpha;
65176530
xmb->settings_tab_node.zoom = xmb->categories_active_zoom;
@@ -8718,7 +8731,10 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
87188731
xmb->depth = 1;
87198732
xmb->old_depth = 1;
87208733
xmb->alpha = 1.0f;
8721-
8734+
8735+
/* Kiosk Mode Fix */
8736+
xmb->is_kiosk_init = false;
8737+
87228738
xmb_refresh_system_tabs_list(xmb);
87238739

87248740
for (i = 0; i < XMB_TAB_MAX_LENGTH; i++)
@@ -8787,6 +8803,45 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
87878803
return NULL;
87888804
}
87898805

8806+
/* Kiosk Mode Fix */
8807+
static void xmb_kiosk_mode_fix(xmb_handle_t *xmb)
8808+
{
8809+
settings_t *settings = config_get_ptr();
8810+
if (settings->bools.kiosk_mode_enable)
8811+
{
8812+
/* Only jump if we have a Horizontal Menu ( if Play lists Tab is not empty ! ) */
8813+
/* If we have no playlists on the playlists tab, disable Kiosk mode and reset !*/
8814+
if((unsigned)xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) <= 0)
8815+
{
8816+
/* Disable Kiosk Mode ( Prevents Crash when kiosk mode enabled with no playlists ) */
8817+
settings->bools.kiosk_mode_enable = false;
8818+
/* Re-Enable Main Menu Icon! */
8819+
xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU];
8820+
xmb->main_menu_node.alpha = xmb->categories_active_alpha;
8821+
xmb->main_menu_node.zoom = xmb->categories_active_zoom;
8822+
/* Refresh list */
8823+
xmb_refresh_system_tabs_list(xmb);
8824+
}
8825+
else
8826+
{
8827+
/* Jump one Categorie Right after init ( "hides" main menu ) */
8828+
/* Only happens once on init */
8829+
if (!xmb->is_kiosk_init)
8830+
{
8831+
struct menu_state *menu_st = menu_state_get_ptr();
8832+
menu_list_t *menu_list = menu_st->entries.list;
8833+
8834+
menu_entry_t entry;
8835+
MENU_ENTRY_INITIALIZE(entry);
8836+
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
8837+
8838+
xmb_menu_entry_action(xmb, &entry, menu_st->selection_ptr, MENU_ACTION_RIGHT);
8839+
xmb->is_kiosk_init = true;
8840+
}
8841+
}
8842+
}
8843+
}
8844+
87908845
static void xmb_free(void *data)
87918846
{
87928847
xmb_handle_t *xmb = (xmb_handle_t*)data;
@@ -9053,23 +9108,54 @@ static void xmb_list_cache(void *data, enum menu_list_type type,
90539108
switch (action)
90549109
{
90559110
case MENU_ACTION_LEFT:
9056-
if (xmb->categories_selection_ptr == 0)
9111+
/* Kiosk Mode Fix - Only allow categorie movement between idx 1 and last instead of 0 ( skips main menu ) */
9112+
if (settings->bools.kiosk_mode_enable)
90579113
{
9058-
xmb->categories_selection_ptr = list_size;
9059-
xmb->categories_active_idx = (unsigned)(list_size - 1);
9114+
if (xmb->categories_selection_ptr == 1)
9115+
{
9116+
xmb->categories_selection_ptr = list_size;
9117+
xmb->categories_active_idx = (unsigned)(list_size - 1);
9118+
}
9119+
else
9120+
xmb->categories_selection_ptr--;
9121+
break;
90609122
}
90619123
else
9062-
xmb->categories_selection_ptr--;
9063-
break;
9124+
{
9125+
if (xmb->categories_selection_ptr == 0)
9126+
{
9127+
xmb->categories_selection_ptr = list_size;
9128+
xmb->categories_active_idx = (unsigned)(list_size - 1);
9129+
}
9130+
else
9131+
xmb->categories_selection_ptr--;
9132+
break;
9133+
}
90649134
default:
9065-
if (xmb->categories_selection_ptr == list_size)
9135+
/* Kiosk Mode Fix - Only allow categorie movement between idx 1 and last instead of 0 ( skips main menu ) */
9136+
if (settings->bools.kiosk_mode_enable)
90669137
{
9067-
xmb->categories_selection_ptr = 0;
9068-
xmb->categories_active_idx = 1;
9138+
if (xmb->categories_selection_ptr == list_size)
9139+
{
9140+
xmb->categories_selection_ptr = 1;
9141+
xmb->categories_active_idx = 2;
9142+
}
9143+
else
9144+
xmb->categories_selection_ptr++;
9145+
break;
90699146
}
90709147
else
9071-
xmb->categories_selection_ptr++;
9072-
break;
9148+
{
9149+
if (xmb->categories_selection_ptr == list_size)
9150+
{
9151+
xmb->categories_selection_ptr = 0;
9152+
xmb->categories_active_idx = 1;
9153+
}
9154+
else
9155+
xmb->categories_selection_ptr++;
9156+
break;
9157+
}
9158+
90739159
}
90749160

90759161
stack_size = menu_stack->size;
@@ -9207,7 +9293,10 @@ static void xmb_toggle(void *userdata, bool menu_on)
92079293
xmb_fade_out(xmb);
92089294
return;
92099295
}
9210-
9296+
9297+
/* Kiosk Mode Fix */
9298+
xmb_kiosk_mode_fix(xmb);
9299+
92119300
/* Have to reset this, otherwise savestate
92129301
* thumbnail won't update after selecting
92139302
* 'save state' option */

0 commit comments

Comments
 (0)