Documentation
¶
Overview ¶
Package libretro is a cgo binding for the libretro API.
Libretro is a simple but powerful development interface that allows for the easy creation of emulators, games and multimedia applications that can plug straight into any libretro-compatible frontend. This development interface is open to others so that they can run these pluggable emulator and game cores also in their own programs or devices.
Index ¶
- Constants
- func DlOpen(path string) (unsafe.Pointer, error)
- func GetPixelFormat(data unsafe.Pointer) uint32
- func SetBool(data unsafe.Pointer, val bool)
- func SetString(data unsafe.Pointer, val string)
- type AudioCallback
- type Core
- func (core *Core) APIVersion() uint
- func (core *Core) BindLogCallback(data unsafe.Pointer, f logFunc)
- func (core *Core) BindPerfCallback(data unsafe.Pointer, f getTimeUsecFunc)
- func (core *Core) Deinit()
- func (core *Core) DlSym(name string) unsafe.Pointer
- func (core *Core) GetMemoryData(id uint32) unsafe.Pointer
- func (core *Core) GetMemorySize(id uint32) uint
- func (core *Core) GetSystemAVInfo() SystemAVInfo
- func (core *Core) GetSystemInfo() SystemInfo
- func (core *Core) Init()
- func (core *Core) LoadGame(gi GameInfo) bool
- func (core *Core) Reset()
- func (core *Core) Run()
- func (core *Core) Serialize(size uint) ([]byte, error)
- func (core *Core) SerializeSize() uint
- func (core *Core) SetAudioSample(f audioSampleFunc)
- func (core *Core) SetAudioSampleBatch(f audioSampleBatchFunc)
- func (core *Core) SetEnvironment(f environmentFunc)
- func (core *Core) SetInputPoll(f inputPollFunc)
- func (core *Core) SetInputState(f inputStateFunc)
- func (core *Core) SetVideoRefresh(f videoRefreshFunc)
- func (core *Core) UnloadGame()
- func (core *Core) Unserialize(bytes []byte, size uint) error
- type FrameTimeCallback
- type GameGeometry
- type GameInfo
- type SystemAVInfo
- type SystemInfo
- type SystemTiming
- type Variable
Constants ¶
const ( PixelFormat0RGB1555 = uint32(C.RETRO_PIXEL_FORMAT_0RGB1555) PixelFormatXRGB8888 = uint32(C.RETRO_PIXEL_FORMAT_XRGB8888) PixelFormatRGB565 = uint32(C.RETRO_PIXEL_FORMAT_RGB565) )
The pixel format the core must use to render into data. This format could differ from the format used in SET_PIXEL_FORMAT. Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.
const ( DeviceIDJoypadB = uint32(C.RETRO_DEVICE_ID_JOYPAD_B) DeviceIDJoypadY = uint32(C.RETRO_DEVICE_ID_JOYPAD_Y) DeviceIDJoypadSelect = uint32(C.RETRO_DEVICE_ID_JOYPAD_SELECT) DeviceIDJoypadStart = uint32(C.RETRO_DEVICE_ID_JOYPAD_START) DeviceIDJoypadUp = uint32(C.RETRO_DEVICE_ID_JOYPAD_UP) DeviceIDJoypadDown = uint32(C.RETRO_DEVICE_ID_JOYPAD_DOWN) DeviceIDJoypadLeft = uint32(C.RETRO_DEVICE_ID_JOYPAD_LEFT) DeviceIDJoypadRight = uint32(C.RETRO_DEVICE_ID_JOYPAD_RIGHT) DeviceIDJoypadA = uint32(C.RETRO_DEVICE_ID_JOYPAD_A) DeviceIDJoypadX = uint32(C.RETRO_DEVICE_ID_JOYPAD_X) DeviceIDJoypadL = uint32(C.RETRO_DEVICE_ID_JOYPAD_L) DeviceIDJoypadR = uint32(C.RETRO_DEVICE_ID_JOYPAD_R) DeviceIDJoypadL2 = uint32(C.RETRO_DEVICE_ID_JOYPAD_L2) DeviceIDJoypadR2 = uint32(C.RETRO_DEVICE_ID_JOYPAD_R2) DeviceIDJoypadL3 = uint32(C.RETRO_DEVICE_ID_JOYPAD_L3) DeviceIDJoypadR3 = uint32(C.RETRO_DEVICE_ID_JOYPAD_R3) )
Buttons for the RetroPad (JOYPAD). The placement of these is equivalent to placements on the Super Nintendo controller. L2/R2/L3/R3 buttons correspond to the PS1 DualShock.
const ( EnvironmentGetUsername = uint32(C.RETRO_ENVIRONMENT_GET_USERNAME) EnvironmentGetLogInterface = uint32(C.RETRO_ENVIRONMENT_GET_LOG_INTERFACE) EnvironmentGetCanDupe = uint32(C.RETRO_ENVIRONMENT_GET_CAN_DUPE) EnvironmentSetPixelFormat = uint32(C.RETRO_ENVIRONMENT_SET_PIXEL_FORMAT) EnvironmentGetSystemDirectory = uint32(C.RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY) EnvironmentGetSaveDirectory = uint32(C.RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY) EnvironmentShutdown = uint32(C.RETRO_ENVIRONMENT_SHUTDOWN) EnvironmentGetVariable = uint32(C.RETRO_ENVIRONMENT_GET_VARIABLE) EnvironmentSetVariables = uint32(C.RETRO_ENVIRONMENT_SET_VARIABLES) EnvironmentGetVariableUpdate = uint32(C.RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE) EnvironmentGetPerfInterface = uint32(C.RETRO_ENVIRONMENT_GET_PERF_INTERFACE) EnvironmentSetFrameTimeCallback = uint32(C.RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK) EnvironmentSetAudioCallback = uint32(C.RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK) )
Environment callback API. See libretro.h for details
const ( LogLevelDebug = uint32(C.RETRO_LOG_DEBUG) LogLevelInfo = uint32(C.RETRO_LOG_INFO) LogLevelWarn = uint32(C.RETRO_LOG_WARN) LogLevelError = uint32(C.RETRO_LOG_ERROR) LogLevelDummy = uint32(C.RETRO_LOG_DUMMY) )
Debug levels
const ( MemoryMask = uint32(C.RETRO_MEMORY_MASK) MemorySaveRAM = uint32(C.RETRO_MEMORY_SAVE_RAM) MemoryRTC = uint32(C.RETRO_MEMORY_RTC) MemorySystemRAM = uint32(C.RETRO_MEMORY_SYSTEM_RAM) MemoryVideoRAM = uint32(C.RETRO_MEMORY_VIDEO_RAM) )
Memory constants
const DeviceJoypad = uint32(C.RETRO_DEVICE_JOYPAD)
DeviceJoypad represents the RetroPad. It is essentially a Super Nintendo controller, but with additional L2/R2/L3/R3 buttons, similar to a PS1 DualShock.
Variables ¶
This section is empty.
Functions ¶
func GetPixelFormat ¶
GetPixelFormat is an environment callback helper that returns the pixel format. Should be used in the case of EnvironmentSetPixelFormat
Types ¶
type AudioCallback ¶
type AudioCallback struct { Callback func() SetState func(bool) }
AudioCallback stores the audio callback itself and the SetState callback
func SetAudioCallback ¶
func SetAudioCallback(data unsafe.Pointer) AudioCallback
SetAudioCallback is an environment callback helper to set the AudioCallback
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is an instance of a dynalically loaded libretro core
func (*Core) APIVersion ¶
APIVersion returns the RETRO_API_VERSION. Used to validate ABI compatibility when the API is revised.
func (*Core) BindLogCallback ¶
BindLogCallback binds f to the log callback
func (*Core) BindPerfCallback ¶
BindPerfCallback binds f to the perf callback get_time_usec
func (*Core) Deinit ¶
func (core *Core) Deinit()
Deinit takes care of the library global deinitialization
func (*Core) GetMemoryData ¶ added in v0.2.0
GetMemoryData returns the size of a region of the memory. See memory constants.
func (*Core) GetMemorySize ¶ added in v0.2.0
GetMemorySize returns the size of a region of the memory. See memory constants.
func (*Core) GetSystemAVInfo ¶
func (core *Core) GetSystemAVInfo() SystemAVInfo
GetSystemAVInfo returns information about system audio/video timings and geometry. Can be called only after retro_load_game() has successfully completed. NOTE: The implementation of this function might not initialize every variable if needed. E.g. geom.aspect_ratio might not be initialized if core doesn't desire a particular aspect ratio.
func (*Core) GetSystemInfo ¶
func (core *Core) GetSystemInfo() SystemInfo
GetSystemInfo returns statically known system info. Pointers provided in *info must be statically allocated. Can be called at any time, even before retro_init().
func (*Core) Run ¶
func (core *Core) Run()
Run runs the game for one video frame. During retro_run(), input_poll callback must be called at least once. If a frame is not rendered for reasons where a game "dropped" a frame, this still counts as a frame, and retro_run() should explicitly dupe a frame if GET_CAN_DUPE returns true. In this case, the video callback can take a NULL argument for data.
func (*Core) SerializeSize ¶
SerializeSize returns the amount of data the implementation requires to serialize internal state (save states). Between calls to retro_load_game() and retro_unload_game(), the returned size is never allowed to be larger than a previous returned value, to ensure that the frontend can allocate a save state buffer once.
func (*Core) SetAudioSample ¶
func (core *Core) SetAudioSample(f audioSampleFunc)
SetAudioSample sets the audio sample callback. Must be set before the first Run call
func (*Core) SetAudioSampleBatch ¶
func (core *Core) SetAudioSampleBatch(f audioSampleBatchFunc)
SetAudioSampleBatch sets the audio sample batch callback. Must be set before the first Run call
func (*Core) SetEnvironment ¶
func (core *Core) SetEnvironment(f environmentFunc)
SetEnvironment sets the environment callback. Must be called before Init
func (*Core) SetInputPoll ¶
func (core *Core) SetInputPoll(f inputPollFunc)
SetInputPoll sets the input poll callback. Must be set before the first Run call
func (*Core) SetInputState ¶
func (core *Core) SetInputState(f inputStateFunc)
SetInputState sets the input state callback. Must be set before the first Run call
func (*Core) SetVideoRefresh ¶
func (core *Core) SetVideoRefresh(f videoRefreshFunc)
SetVideoRefresh sets the video refresh callback. Must be set before the first Run call
type FrameTimeCallback ¶
FrameTimeCallback stores the frame time callback itself and the reference time
func SetFrameTimeCallback ¶
func SetFrameTimeCallback(data unsafe.Pointer) FrameTimeCallback
SetFrameTimeCallback is an environment callback helper to set the FrameTimeCallback
type GameGeometry ¶
GameGeometry represents the geometry of a game, with its aspect ratio, with and height
type SystemAVInfo ¶
type SystemAVInfo struct { Geometry GameGeometry Timing SystemTiming }
SystemAVInfo stores informations about the emulated system audio and video
type SystemInfo ¶
type SystemInfo struct { LibraryName string LibraryVersion string ValidExtensions string NeedFullpath bool BlockExtract bool }
SystemInfo stores informations about the emulated system
type SystemTiming ¶
SystemTiming stores informations about the timing of the emulated system
type Variable ¶
type Variable C.struct_retro_variable
Variable is a key value pair that represents a core option
func GetVariable ¶
GetVariable is an environment callback helper that returns a Variable
func GetVariables ¶
GetVariables is an environment callback helper that returns the list of Variables needed by a core