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

libretro: Add GET_CORE_DATA and SET_CORE_DATA environment callbacks #17012

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct retro_core_t

unsigned poll_type;
uint8_t flags;
void *core_data; /* Arbitrary core data. @see RETRO_ENVIRONMENT_GET_CORE_DATA */
};


Expand Down
25 changes: 25 additions & 0 deletions libretro-common/include/libretro.h
Original file line number Diff line number Diff line change
Expand Up @@ -2569,6 +2569,31 @@ enum retro_mod
*/
#define RETRO_ENVIRONMENT_GET_FILE_BROWSER_START_DIRECTORY 80

/**
* Sets a pointer to arbitrary data for the actively running core.
RobLoach marked this conversation as resolved.
Show resolved Hide resolved
*
* This is can be set in either \c retro_init() or \c retro_load_game().
*
* @param[in] data <tt>void *</tt>. Pointer to the data to set.
* @return \c true if the environment call is available.
*
* @see RETRO_ENVIRONMENT_GET_CORE_DATA
*/
#define RETRO_ENVIRONMENT_SET_CORE_DATA 81

/**
* Gets a pointer to arbitrary data for the actively running core.
*
* This is persistent for the lifetime of the core until \c retro_deinit() is called.
*
* @param[out] data <tt>void **</tt>. Pointer to the data that was set.
* May be \c NULL if the data was not set yet.
* @return \c true if the environment call is available.
*
* @see RETRO_ENVIRONMENT_SET_CORE_DATA
*/
#define RETRO_ENVIRONMENT_GET_CORE_DATA 82

/**@}*/

/**
Expand Down
12 changes: 12 additions & 0 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3583,6 +3583,18 @@ bool runloop_environment_cb(unsigned cmd, void *data)
}
}
break;

case RETRO_ENVIRONMENT_SET_CORE_DATA:
runloop_st->current_core.core_data = data;
break;

case RETRO_ENVIRONMENT_GET_CORE_DATA:
if (data != NULL) {
void **core_data = (void **)data;
*core_data = runloop_st->current_core.core_data;
}
break;

default:
RARCH_LOG("[Environ]: UNSUPPORTED (#%u).\n", cmd);
return false;
Expand Down
Loading