Skip to content

Instantly share code, notes, and snippets.

@leiradel
Created December 1, 2020 16:25
Show Gist options
  • Save leiradel/c44e0536d7b169311baab0e5dae25479 to your computer and use it in GitHub Desktop.
Save leiradel/c44e0536d7b169311baab0e5dae25479 to your computer and use it in GitHub Desktop.
#ifndef LRCPP_COMPONENTS_H__
#define LRCPP_COMPONENTS_H__
#include "libretro.h"
namespace lrcpp {
/**
* A logger component for Core instances.
*/
class Logger {
public:
// Environment calls
virtual bool getLogInterface(struct retro_log_callback* callback) = 0;
};
/**
* A component that returns configuration values for SimpleCore instances.
*/
class Config {
public:
// Environment calls
virtual bool getSystemDirectory(char const** directory) = 0;
virtual bool getVariable(struct retro_variable* variable) = 0;
bool setVariables(struct retro_variable const* variables);
virtual bool getVariableUpdate(bool* const updated) = 0;
virtual bool setSupportNoGame(bool const supports) = 0;
virtual bool getLibretroPath(char const** path) = 0;
virtual bool getCoreAssetsDirectory(char const** directory) = 0;
virtual bool getSaveDirectory(char const** directory) = 0;
virtual bool setProcAddressCallback(struct retro_get_proc_address_interface const* callback) = 0;
virtual bool setSubsystemInfo(struct retro_subsystem_info const* info) = 0;
virtual bool setMemoryMaps(struct retro_memory_map const* map) = 0;
virtual bool getUsername(char const** data) = 0;
virtual bool getLanguage(unsigned* language) = 0;
virtual bool setSupportAchievements(bool supports) = 0;
virtual bool setSerializationQuirks(uint64_t quirks) = 0;
virtual bool getAudioVideoEnable(int* data) = 0;
virtual bool getFastForwarding(bool* is) = 0;
bool getCoreOptionsVersion(unsigned* version);
virtual bool setCoreOptions(struct retro_core_option_definition const** options) = 0;
virtual bool setCoreOptionsIntl(struct retro_core_options_intl const* intl) = 0;
virtual bool setCoreOptionsDisplay(struct retro_core_option_display const* display) = 0;
// Getters
virtual bool supportsNoGame() = 0;
// Misc
static bool preprocessMemoryDescriptors(struct retro_memory_descriptor* descriptors, unsigned count);
};
/**
* A Video component.
*/
class Video {
public:
// Environment calls
virtual bool setRotation(unsigned rotation) = 0;
virtual bool getOverscan(bool* data) = 0;
virtual bool getCanDupe(bool* data) = 0;
virtual bool showMessage(struct retro_message const* message) = 0;
virtual bool setPixelFormat(enum retro_pixel_format format) = 0;
virtual bool setHWRender(struct retro_hw_render_callback* callback) = 0;
virtual bool setFrameTimeCallback(struct retro_frame_time_callback const* callback) = 0;
virtual bool setSystemAVInfo(struct retro_system_av_info const* info) = 0;
virtual bool setGeometry(struct retro_game_geometry const* geometry) = 0;
virtual bool getCurrentSoftwareFramebuffer(struct retro_framebuffer* const framebuffer) = 0;
virtual bool getHWRenderInterface(struct retro_hw_render_interface const** interface) = 0;
virtual bool setHWRenderContextNegotiationInterface(
struct retro_hw_render_context_negotiation_interface const* interface) = 0;
virtual bool setHWSharedContext() = 0;
virtual bool getLEDInterface(struct retro_led_interface* interface) = 0;
virtual bool getTargetRefreshRate(float* rate) = 0;
virtual bool getPreferredHWRender(unsigned* preferred) = 0;
// Callbacks
virtual void refresh(void const* data, unsigned width, unsigned height, size_t pitch) = 0;
};
/**
* An audio component.
*/
class Audio {
public:
// Environment calls
virtual bool setAudioCallback(struct retro_audio_callback const* callback) = 0;
virtual bool getMIDIInterface(struct retro_midi_interface** const interface) = 0;
// Callbacks
virtual size_t sampleBatch(int16_t const* data, size_t frames) = 0;
virtual void sample(int16_t left, int16_t right) = 0;
};
/**
* A component that provides input state to CoreWrap instances.
*/
class Input {
public:
// Environment calls
virtual bool setInputDescriptors(struct retro_input_descriptor const* descriptors) = 0;
virtual bool setKeyboardCallback(struct retro_keyboard_callback const* callback) = 0;
virtual bool getRumbleInterface(struct retro_rumble_interface* interface) = 0;
virtual bool getInputDeviceCapabilities(uint64_t* capabilities) = 0;
virtual bool getSensorInterface(struct retro_sensor_interface* interface) = 0;
virtual bool getCameraInterface(struct retro_camera_callback* interface) = 0;
virtual bool getLocationInterface(struct retro_location_callback* interface) = 0;
virtual bool setControllerInfo(struct retro_controller_info const* info) = 0;
virtual bool getInputBitmasks(bool* supports) = 0;
// Callbacks
virtual int16_t state(unsigned port, unsigned device, unsigned index, unsigned id) = 0;
virtual void poll() = 0;
virtual bool setRumbleState(unsigned port, enum retro_rumble_effect effect, uint16_t strength) = 0;
};
/**
* A component responsible for dealing with the file systems, both real and
* virtual.
*/
class Filesystem {
public:
virtual bool setDiskControlInterface(struct retro_disk_control_callback const* callback) = 0;
virtual bool getVFSInterface(struct retro_vfs_interface_info* interface) = 0;
virtual bool getDiskControlInterfaceVersion(unsigned* const version) = 0;
virtual bool setDiskControlExtInterface(struct retro_disk_control_ext_callback const* callback) = 0;
virtual void* load(char const* path, size_t* size) = 0;
virtual void free(void const* data) = 0;
};
/**
* A component to get performance information from the system.
*/
class Perf {
public:
virtual bool setPerformanceLevel(unsigned level) = 0;
virtual bool getPerfInterface(struct retro_perf_callback* interface) = 0;
};
}
#endif // LRCPP_COMPONENTS_H__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment