Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Fix #746 (CLI) Auto-detect Core when -L isn't present #15458

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

zig-for
Copy link

@zig-for zig-for commented Jul 5, 2023

Guidelines

  1. Rebase before opening a pull request
  2. If you are sending several unrelated fixes or features, use a branch and a separate pull request for each
  3. If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises

Description

This allows Retroarch to attempt to pick the proper core when loading. Windows already does this on drag and drop.

The PR as is doesn't handle missing cores, nor does it delegate to the frontend if there's multiple possible cores. Happy to put work towards that if there's a desire for this to go in. The main desire is to try to push for a "good" solution even if no perfect solution exists (I'd rather a happy path of being able to easily set file extensions associated with RA to do the right thing, then give up on every case just because some cases are hard to handle).

To repeat - as is, the PR is not ready, just looking for direction on both implementation and probability of acceptance later

EDIT: Additional changes:

  • Always allows downloading cores when suggesting cores
  • Fixes bug that caused cancelling "Core Downloader" to pop the entire menu stack if run from anywhere but "Online Updater"
  • The core download menu is now filtered when appropriate

Current bugs:

  • When backing out from the content suggester, the main menu on the left isn't scrolled properly
  • Suggested cores don't show licenses (is this desired? I kind of like the slim, clean look)

Related Issues

#746
#9275
https://forums.libretro.com/t/autodetect-core-when-opening-a-rom-file/1863
#1704
#8557

Reviewers

[If possible @mention all the people that should review your pull request]

@hizzlekizzle
Copy link
Contributor

I think this is welcome functionality and indeed picking some core behind the scenes is better than failing with no core at all. For multiple cores, I think the ideal behavior would be to launch into the menu at the point of the core picker dialog, just as you would if you just 'load content'.

runloop.c Outdated Show resolved Hide resolved
runloop.c Show resolved Hide resolved
@zig-for
Copy link
Author

zig-for commented Jul 6, 2023

I attempted to get @hizzlekizzle 's idea working, but can't figure out how to control the menu programatically. I tried something along the lines of menu_displaylist_ctl(DISPLAYLIST_CORES, &info, settings); and deferred_push_core_list(&info); (with empty lists for now), but neither control the menu. I'm not sure if:

  1. Calling these with empty lists just doesn't work
  2. I'm calling the wrong function
  3. The menu system isn't in a proper state to accept control at this point in execution

Could I get a hint for what to do?

@zig-for
Copy link
Author

zig-for commented Jul 6, 2023

Made some progress, with the caveat that it involves moving menu initialization earlier. :(

@zig-for
Copy link
Author

zig-for commented Jul 6, 2023

Looking at the menu code, it's ok to initialize the menu multiple times, even early. @LibretroAdmin could you comment on direction here? The other option is figuring out some deferral method that waits until after the menu is actually initialized (some sort of hook in the main menu?).

There's a case that doesn't work as well as I'd like - downloading:

  1. Cores aren't filtered by the current content type (I think this is fixable, I can potentially read detect_content_path, please comment if this is desired)
  2. if you download a core it doesn't launch the core (this doesn't really look fixable - core downloads are very asynchronous - unless I disallow swapping away from the core download screen or put up some sort of modal menu I don't see options, also open to direction)
    EDIT: 3. It would be neat if "suggested cores" also included a download button - and then also would be neat if downloading added to the stack rather than replacing.

I need to do another pass at C89 compat, but will do so after I know I'm not barking up the wrong tree.

image

@zig-for
Copy link
Author

zig-for commented Jul 6, 2023

Fixed (2) and (3) - there was a bug in how the stack was popped - now downloading a core, waiting, and backing out does the right thing (it would be extra neat if the list refreshed itself, but I'm not super worried about it)

@zig-for
Copy link
Author

zig-for commented Jul 6, 2023

....ok, now when you go to download the core, you're only presented with cores associated with the content. The way I implemented the clear on cancel seems wrong, please lemme know if there's a nicer way. What I really want to do is associate a cancel option with the window, not every item on the window, even though I get why the extra flexibility would be nice. Please lemme know the "proper" way of doing this, I feel like I took a sledgehammer to the menu system.

@hizzlekizzle
Copy link
Contributor

being able to download a core from there is a great idea, and having it only show eligible cores is even better. :)

good stuff!

@keithbowes
Copy link
Contributor

I had been thinking about trying my hand at this, but I hadn't started yet. I have written a shell script that looks at .info files for file extensions and then prompts you to enter a number which core you want if more than one core supports a file extension, and was thinking about doing the same in RetroArch when it is built with --disable-menu.

@LibretroAdmin
Copy link
Contributor

Hi, quite a few CI tasks are failing. Can you check it out and fix it?

@zig-for
Copy link
Author

zig-for commented Jul 7, 2023

Yes, of course. I'm out of town for four days, but I will circle back to this next week.

@LibretroAdmin
Copy link
Contributor

Let us know when you're ready to look into the matter.

@RobLoach
Copy link
Member

RobLoach commented Jul 15, 2023

Just sharing that this has been on my wishlist FOREVER. Thanks a lot for picking it up.

I tried building locally, and got the following...

runloop.c:(.text+0x3652): undefined reference to `file_load_with_detect_core_wrapper'

As a side-note to #15458 (comment) , make sure to Update Assets.

@zig-for
Copy link
Author

zig-for commented Jul 16, 2023

I am going to try to work on this tomorrow. Got back from vacation, got slammed with work, and now MAGWEST is upon me. :)

@zig-for
Copy link
Author

zig-for commented Jul 17, 2023

@LibretroAdmin fixed the build errors

Copy link
Member

@RobLoach RobLoach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked for me! When loading from a .zip file, it resolves correctly too. When no cores are suggested, it says "No Cores Available". Nice work, so happy to see this get pushed forwards.

Curious about cleaning up the approach a bit, but this is incredible. Thanks so much!

Screenshot at 2023-07-17 01-46-45

{
core_info_list_t* core_info_list = NULL;

/* TODO: error printing */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error printing?

runloop.c Outdated Show resolved Hide resolved
runloop.c Outdated Show resolved Hide resolved
runloop.c Outdated Show resolved Hide resolved
runloop.c Outdated Show resolved Hide resolved
runloop_set_current_core_type(CORE_TYPE_DUMMY, false);
#ifdef HAVE_MENU
/* this is a hack, we should be deferring the core list until after we have loaded menu */
/* TODO: ask how to unhackify it */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, good point. I haven't tested this without the menu being available yet. Do you have any ideas on how we could "do it right"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think automatically picking the first in the list would be pretty much the only way to go.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other projects with similar issues I've printed out a list of options and asked the user to enter a number.

Copy link
Member

@gouchi gouchi Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, it seems we have to first fix an RA compilation issue when using ./configure --disable-menu

Compilation log
CC tasks/task_manual_content_scan.c
tasks/task_manual_content_scan.c: In function 'task_manual_content_scan_handler':
tasks/task_manual_content_scan.c:215:16: warning: implicit declaration of function 'runloop_msg_queue_push' [-Wimplicit-function-declaration]
  215 |                runloop_msg_queue_push(
      |                ^~~~~~~~~~~~~~~~~~~~~~
CC tasks/task_core_backup.c
CC libretro-common/encodings/encoding_utf.c
tasks/task_manual_content_scan.c:218:28: error: 'MESSAGE_QUEUE_ICON_DEFAULT' undeclared (first use in this function)
  218 |                      NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
tasks/task_manual_content_scan.c:218:28: note: each undeclared identifier is reported only once for each function it appears in
tasks/task_manual_content_scan.c:218:56: error: 'MESSAGE_QUEUE_CATEGORY_INFO' undeclared (first use in this function)
  218 |                      NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
      |                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
tasks/task_manual_content_scan.c: In function 'task_push_manual_content_scan':
tasks/task_manual_content_scan.c:576:19: error: 'MESSAGE_QUEUE_ICON_DEFAULT' undeclared (first use in this function)
  576 |             NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
CC libretro-common/encodings/encoding_crc32.c
tasks/task_manual_content_scan.c:576:47: error: 'MESSAGE_QUEUE_CATEGORY_INFO' undeclared (first use in this function)
  576 |             NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:209: obj-unix/release/tasks/task_manual_content_scan.o] Error 1
make: *** Waiting for unfinished jobs....

`

Edit
Compilation issue is fixed with this PR, last error is linking issue.

Linking issue log

`

/usr/bin/ld: obj-unix/release/retroarch.o: in function `retroarch_main_init':
retroarch.c:(.text+0x8b2d): undefined reference to `handle_dbscan_finished'
collect2: error: ld returned 1 exit status
make: *** [Makefile:204: retroarch] Error 1

`

Edit 2

Linking issue is fixed with f34481c

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zig-for will it be possible to rebase so that you can get the two fixes for the option --disable-menu ?

Thank you.

runloop.c Outdated Show resolved Hide resolved
runloop.c Outdated Show resolved Hide resolved
Comment on lines +3602 to +3604
/*This isn't needed, is it?*/
/*command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL);*/
core_info_get_list(&core_info_list);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

zig-for and others added 6 commits July 28, 2023 19:39
Co-authored-by: Rob Loach <robloach@gmail.com>
Co-authored-by: Rob Loach <robloach@gmail.com>
Co-authored-by: Rob Loach <robloach@gmail.com>
Co-authored-by: Rob Loach <robloach@gmail.com>
Co-authored-by: Rob Loach <robloach@gmail.com>
Co-authored-by: Rob Loach <robloach@gmail.com>
@zig-for
Copy link
Author

zig-for commented Sep 13, 2023 via email

@RobLoach
Copy link
Member

Thanks, brought in the latest from master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants