-
Notifications
You must be signed in to change notification settings - Fork 9
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
ctypes getting core variables/settings does not always work #69
Comments
I noticed this too, and resulted in not updating several add-ons where the settings "disappeared". My thoughts were it's probably related to the new options api: https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L1109 Basically we need to set the int pointed to by *arg = 1; |
@Rechi are you familiar with python ctypes? |
Playing around with this, I got halfway there. A new cb_type=53 needs to be added, which I think was an API change for libretro. Something like:
But the part I can't figure out is the definition of the RetroOptions. The 'values' are structs within structs and I dont understand ctypes fully:
|
Good progress so far. I have a feeling a nontrivial understanding of ctypes is needed. Per the API, |
The API function we need to handle is RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION: https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h#L1117. The parameter is void environment_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, void *data)
{
unsigned int *version = reinterpret_cast<unsigned int*>(data);
*version = 2;
} So in ctypes, you take the |
Just adding some tinkering I've done with this. In libretro_ctypes.py I created two additional structs:
And then created another cb_type for testing:
This method does pull some of the settings for RETRO_ENVIRONMENT_SET_CORE_OPTIONS, but it quickly gets out of sync. I believe the issue is because retro_core_option_value struct is dynamically sized vs. actually sized to the MAX. My best stackexchange searching can't get past how to dynamically define the struct size within the cb call (I don't speak C, so thats probably the issue, and maybe thats what you were referring to with assigning the number 2 to the memory pointed to by the pointer.). |
Unfortunately I followed pretty much the exact same path and hit a wall when I couldn't find the documentation I needed to do certain things. I think the solution is to create a lightweight C++ program that loads the core, calls the retro_* functions, and translates their results to stdout, where it's then parsed by the Python code. |
Actually, I just remembered I already did this: https://github.com/garbear/repository.libretro/tree/master/libretro-extract. We could use the libretro-extract utility to get settings from the libretro options v2 API. |
Full disclosure, I'm trying to troubleshoot my own code utilizing kodi-game-scripting, but I think this would likely effect kodi-game-scripting's ability to generate the official addons as well.
The issue I've found with this code is that it doesn't consistently pull core settings from the binary. Here's an example:
From Retroarch directly, I can see the first binary should have the following variables:
The problem seems to be here, where the correct RETRO_ENVIRONMENT_SET_VARIABLES cb_type is never called to pull the variables for the first binary. Based on the code, I can't figure out why however.
The text was updated successfully, but these errors were encountered: