Help a n00b compile a new feature

Recently in RetroArch 1.9.0, a new feature was added “You can now selectively hide/enable widget notifications of several types.”

For reasons, I specifically loathe the state slot notifications (when you save a state it tells you what slot you’re saving to anyways), and I am trying to get this added and working in Settings/On-Screen Display/On-Screen Notifications/Notification Visibility.

I have succeeded in getting the setting to at least appear in the menu, however, the toggle does not actually do anything, and I can’t figure out where I’m going wrong.

I have edited the following files/lines:

osd.cpp, line 63

notificationsGroup->add(MENU_ENUM_LABEL_NOTIFICATION_SHOW_STATE_SLOT);

menu_cbs_sublabel.c, line 385

DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_notification_show_state_slot, MENU_ENUM_SUBLABEL_NOTIFICATION_SHOW_STATE_SLOT)

and line 3046

case MENU_ENUM_LABEL_NOTIFICATION_SHOW_STATE_SLOT: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_notification_show_state_slot);

menu_displaylist.c, line 7831

{MENU_ENUM_LABEL_NOTIFICATION_SHOW_STATE_SLOT, PARSE_ONLY_BOOL, true },

menu_setting.c, line 12754

	 CONFIG_BOOL(
           list, list_info,
           &settings->bools.notification_show_state_slot,
           MENU_ENUM_LABEL_NOTIFICATION_SHOW_STATE_SLOT,
           MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_STATE_SLOT,
           DEFAULT_NOTIFICATION_SHOW_STATE_SLOT,
           MENU_ENUM_LABEL_VALUE_OFF,
           MENU_ENUM_LABEL_VALUE_ON,
           &group_info,
           &subgroup_info,
           parent_group,
           general_write_handler,
           general_read_handler,
           SD_FLAG_NONE);	   

msg_hash.h, line 2609

MENU_LABEL(NOTIFICATION_SHOW_STATE_SLOT),

configuration.c, line 1483

SETTING_BOOL(“notification_show_state_slot”, &settings->bools.notification_show_state_slot, true, DEFAULT_NOTIFICATION_SHOW_STATE_SLOT, false);

configuration.h, line 510

  bool notification_show_state_slot;	  

msg_hash_us.h, line 3451

MSG_HASH( MENU_ENUM_LABEL_VALUE_NOTIFICATION_SHOW_STATE_SLOT, “State slot Notifications” ) MSG_HASH( MENU_ENUM_SUBLABEL_NOTIFICATION_SHOW_STATE_SLOT, “Display an on-screen message when the state slot is changed.” )

config.def.h, line 756

/* Display a notification when changing state slots

  • content */ #define DEFAULT_NOTIFICATION_SHOW_STATE_SLOT true

Before somebody rips on my feeble attempts, please understand I’m just a weekend warrior trying to be resourceful here. I have asked for this feature, I have offered a bounty for this feature, and finally since nobody seemed to be interested in this but me, I’ve tried to do it myself.

I’m not sure what I got right, what I got wrong, but to even get this far took a lot of trial and error, and it is at least showing up in the menu.

Can someone please, please help me finish what I started? I would be forever grateful.

I don’t think anyone is going to do that. Everyone starts somewhere, and we appreciate contributions of all levels.

I’m not very familiar with the menu/widget code, but I think the savestate notifications are “generic” widgets, so you’d need to either break them off from the rest of the generic events or go to the savestate task and make your option silence it from there.

1 Like

I have found the code responsible for the notification, in retroarch.c, line 38510.

static void update_savestate_slot(int state_slot)
{
   char msg[128];

   msg[0] = '\0';

   snprintf(msg, sizeof(msg), "%s: %d",
         msg_hash_to_str(MSG_STATE_SLOT),
         state_slot);

   runloop_msg_queue_push(msg, 2, 180, true, NULL,
         MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);

   RARCH_LOG("%s\n", msg);
}

And, I’ve compared it to the code for the Fast Forward notification, in retroarch.c, line 39324 The text in bold is the on/off toggle in the menu that I’m trying to add for 'state slot notifications.

#if defined(HAVE_GFX_WIDGETS)
      if (widgets_active)
         p_rarch->gfx_widgets_fast_forward =
               **settings->bools.notification_show_fast_forward ?**
                     p_rarch->runloop_fastmotion : false;
      else
#endif
      {
         /* > If widgets are disabled, display fast-forward
          *   status via OSD text for 1 frame every frame */
         if (p_rarch->runloop_fastmotion &&
             **settings->bools.notification_show_fast_forward**)
            runloop_msg_queue_push(
               msg_hash_to_str(MSG_FAST_FORWARD), 1, 1, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
      }
   }

I’ve already created the necessary settings->bools.notification_show_state_slot stuff, and confirmed that it worked elsewhere by inserting it into a pre-existing ‘if’ statement.

But I can’t get it to work here, where I need it, because I can’t figure out how create my own working ‘if’ statement for this particular case:

 static void update_savestate_slot(int state_slot)
{
   char msg[128];

   msg[0] = '\0';

   snprintf(msg, sizeof(msg), "%s: %d",
         msg_hash_to_str(MSG_STATE_SLOT),
         state_slot);

I want to try something like this, but don’t know how to make it work:

 static void update_savestate_slot(int state_slot)
{
   char msg[128];

   msg[0] = '\0';
**if (settings->bools.notification_show_state_slot)**
   snprintf(msg, sizeof(msg), "%s: %d",
         msg_hash_to_str(MSG_STATE_SLOT),
         state_slot);

Can somebody help me figure out how to get a working ‘if’ statement?

Also, is there a better way for me to display the code properly on this page? Text is appearing all on one line, and obviously that isn’t the way it is in the file.

For showing it on the page, use the codeblocks formatting (looks like </>) instead of the quotes. I edited your post accordingly.

The if statement looks right to me. Is it compiling properly and just not doing what you need?

1 Like

No, MinGW gives me the following text:

retroarch.c: In function ‘update_savestate_slot’: retroarch.c:38514:8: error: ‘settings’ undeclared (first use in this function) 38514 | if (settings->bools.notification_show_state_slot) | ^~~~~~~~ retroarch.c:38514:8: note: each undeclared identifier is reported only once for each function it appears in make: *** [Makefile:205: obj-unix/debug/retroarch.o] Error 1 make: *** Waiting for unfinished jobs… CC intl/msg_hash_ru.c

At this point, I’m not even sure I’m going about this the right way. IF I get this working, it will eliminate both the widget, and the regular OSD simultaneously (if widgets are disabled, no ‘regular’ notification will appear either). It looks as though the code for other elements such as ‘fast forward’ anticipates this and provides extra code for the widget and the OSD, making this significantly more complicated if I want it done ‘right’, and most likely beyond my ability. :frowning:

But, I’d still like to at least figure out why my ‘if’ statement isn’t working. I like to learn. Anything that can help me understand, and who knows, maybe one day contribute, is worth the effort.

ah, ok, based on the compiler error, it looks like ‘settings’ isn’t available in that function, so you would need to make it available, or move the savestate thing into the same area as the others that use it.

static enum runloop_state runloop_check_state(
      struct rarch_state *p_rarch,
      ----> settings_t *settings <----,
      retro_time_t current_time)
{
1 Like