Path: blob/master/dep/rcheevos/include/rc_runtime.h
4246 views
#ifndef RC_RUNTIME_H1#define RC_RUNTIME_H23#include "rc_error.h"45#include <stddef.h>6#include <stdint.h>78RC_BEGIN_C_DECLS910/*****************************************************************************\11| Forward Declarations (defined in rc_runtime_types.h) |12\*****************************************************************************/1314#ifndef RC_RUNTIME_TYPES_H /* prevents pedantic redefinition error */1516typedef struct rc_trigger_t rc_trigger_t;17typedef struct rc_lboard_t rc_lboard_t;18typedef struct rc_richpresence_t rc_richpresence_t;19typedef struct rc_memref_t rc_memref_t;20typedef struct rc_value_t rc_value_t;2122#endif2324/*****************************************************************************\25| Callbacks |26\*****************************************************************************/2728/**29* Callback used to read num_bytes bytes from memory starting at address. If30* num_bytes is greater than 1, the value is read in little-endian from31* memory.32*/33typedef uint32_t(RC_CCONV *rc_runtime_peek_t)(uint32_t address, uint32_t num_bytes, void* ud);3435/*****************************************************************************\36| Runtime |37\*****************************************************************************/3839typedef struct rc_runtime_trigger_t {40uint32_t id;41rc_trigger_t* trigger;42void* buffer;43rc_memref_t* invalid_memref;44uint8_t md5[16];45int32_t serialized_size;46}47rc_runtime_trigger_t;4849typedef struct rc_runtime_lboard_t {50uint32_t id;51int32_t value;52rc_lboard_t* lboard;53void* buffer;54rc_memref_t* invalid_memref;55uint8_t md5[16];56uint32_t serialized_size;57}58rc_runtime_lboard_t;5960typedef struct rc_runtime_richpresence_t {61rc_richpresence_t* richpresence;62void* buffer;63uint8_t md5[16];64}65rc_runtime_richpresence_t;6667typedef struct rc_runtime_t {68rc_runtime_trigger_t* triggers;69uint32_t trigger_count;70uint32_t trigger_capacity;7172rc_runtime_lboard_t* lboards;73uint32_t lboard_count;74uint32_t lboard_capacity;7576rc_runtime_richpresence_t* richpresence;7778struct rc_memrefs_t* memrefs;7980uint8_t owns_self;81}82rc_runtime_t;8384RC_EXPORT rc_runtime_t* RC_CCONV rc_runtime_alloc(void);85RC_EXPORT void RC_CCONV rc_runtime_init(rc_runtime_t* runtime);86RC_EXPORT void RC_CCONV rc_runtime_destroy(rc_runtime_t* runtime);8788RC_EXPORT int RC_CCONV rc_runtime_activate_achievement(rc_runtime_t* runtime, uint32_t id, const char* memaddr, void* unused_L, int unused_funcs_idx);89RC_EXPORT void RC_CCONV rc_runtime_deactivate_achievement(rc_runtime_t* runtime, uint32_t id);90RC_EXPORT rc_trigger_t* RC_CCONV rc_runtime_get_achievement(const rc_runtime_t* runtime, uint32_t id);91RC_EXPORT int RC_CCONV rc_runtime_get_achievement_measured(const rc_runtime_t* runtime, uint32_t id, unsigned* measured_value, unsigned* measured_target);92RC_EXPORT int RC_CCONV rc_runtime_format_achievement_measured(const rc_runtime_t* runtime, uint32_t id, char *buffer, size_t buffer_size);9394RC_EXPORT int RC_CCONV rc_runtime_activate_lboard(rc_runtime_t* runtime, uint32_t id, const char* memaddr, void* unused_L, int unused_funcs_idx);95RC_EXPORT void RC_CCONV rc_runtime_deactivate_lboard(rc_runtime_t* runtime, uint32_t id);96RC_EXPORT rc_lboard_t* RC_CCONV rc_runtime_get_lboard(const rc_runtime_t* runtime, uint32_t id);97RC_EXPORT int RC_CCONV rc_runtime_format_lboard_value(char* buffer, int size, int32_t value, int format);9899100RC_EXPORT int RC_CCONV rc_runtime_activate_richpresence(rc_runtime_t* runtime, const char* script, void* unused_L, int unused_funcs_idx);101RC_EXPORT int RC_CCONV rc_runtime_get_richpresence(const rc_runtime_t* runtime, char* buffer, size_t buffersize, rc_runtime_peek_t peek, void* peek_ud, void* unused_L);102RC_EXPORT int RC_CCONV rc_runtime_get_richpresence_strings(const rc_runtime_t* runtime, const char** buffer, size_t buffersize, size_t* count);103104enum {105RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED, /* from WAITING, PAUSED, or PRIMED to ACTIVE */106RC_RUNTIME_EVENT_ACHIEVEMENT_PAUSED,107RC_RUNTIME_EVENT_ACHIEVEMENT_RESET,108RC_RUNTIME_EVENT_ACHIEVEMENT_TRIGGERED,109RC_RUNTIME_EVENT_ACHIEVEMENT_PRIMED,110RC_RUNTIME_EVENT_LBOARD_STARTED,111RC_RUNTIME_EVENT_LBOARD_CANCELED,112RC_RUNTIME_EVENT_LBOARD_UPDATED,113RC_RUNTIME_EVENT_LBOARD_TRIGGERED,114RC_RUNTIME_EVENT_ACHIEVEMENT_DISABLED,115RC_RUNTIME_EVENT_LBOARD_DISABLED,116RC_RUNTIME_EVENT_ACHIEVEMENT_UNPRIMED,117RC_RUNTIME_EVENT_ACHIEVEMENT_PROGRESS_UPDATED118};119120typedef struct rc_runtime_event_t {121uint32_t id;122int32_t value;123uint8_t type;124}125rc_runtime_event_t;126127typedef void (RC_CCONV *rc_runtime_event_handler_t)(const rc_runtime_event_t* runtime_event);128129RC_EXPORT void RC_CCONV rc_runtime_do_frame(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_runtime_peek_t peek, void* ud, void* unused_L);130RC_EXPORT void RC_CCONV rc_runtime_reset(rc_runtime_t* runtime);131132typedef int (RC_CCONV *rc_runtime_validate_address_t)(uint32_t address);133RC_EXPORT void RC_CCONV rc_runtime_validate_addresses(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_runtime_validate_address_t validate_handler);134RC_EXPORT void RC_CCONV rc_runtime_invalidate_address(rc_runtime_t* runtime, uint32_t address);135136RC_EXPORT uint32_t RC_CCONV rc_runtime_progress_size(const rc_runtime_t* runtime, void* unused_L);137138/* [deprecated] use rc_runtime_serialize_progress_sized instead */139RC_EXPORT int RC_CCONV rc_runtime_serialize_progress(void* buffer, const rc_runtime_t* runtime, void* unused_L);140RC_EXPORT int RC_CCONV rc_runtime_serialize_progress_sized(uint8_t* buffer, uint32_t buffer_size, const rc_runtime_t* runtime, void* unused_L);141142/* [deprecated] use rc_runtime_deserialize_progress_sized instead */143RC_EXPORT int RC_CCONV rc_runtime_deserialize_progress(rc_runtime_t* runtime, const uint8_t* serialized, void* unused_L);144RC_EXPORT int RC_CCONV rc_runtime_deserialize_progress_sized(rc_runtime_t* runtime, const uint8_t* serialized, uint32_t serialized_size, void* unused_L);145146RC_END_C_DECLS147148#endif /* RC_RUNTIME_H */149150151