Add argument to the WUPS_OpenOverlay function which can be used to pass data to the callback.

This commit is contained in:
Maschell 2018-07-15 16:04:22 +02:00
parent 3e3b66b581
commit 8c99eb42d1
4 changed files with 11 additions and 22 deletions

View File

@ -1,17 +1,10 @@
#include <utils/logger.h> #include <utils/logger.h>
#include <malloc.h> #include <malloc.h>
#include "libfat.h"
#include <iosuhax.h>
#include <wups.h> #include <wups.h>
#include <fat.h>
#include "common/retain_vars.h" #include "common/retain_vars.h"
#include "overlay_helper.h" #include "overlay_helper.h"
#include <dynamic_libs/gx2_functions.h> #include <dynamic_libs/gx2_functions.h>
#ifdef __cplusplus
extern "C" {
#endif
uint32_t * getFromGX2Buffer(struct buffer_store store, uint32_t size) { uint32_t * getFromGX2Buffer(struct buffer_store store, uint32_t size) {
if(store.buffer != NULL) { if(store.buffer != NULL) {
DEBUG_FUNCTION_LINE("We try to use the GX2 buffer. Needed space %08X (%d kb), available %08X (%d kb).\n",size,size/1024,store.buffer_size,store.buffer_size/1024); DEBUG_FUNCTION_LINE("We try to use the GX2 buffer. Needed space %08X (%d kb), available %08X (%d kb).\n",size,size/1024,store.buffer_size,store.buffer_size/1024);
@ -24,7 +17,7 @@ uint32_t * getFromGX2Buffer(struct buffer_store store, uint32_t size) {
return NULL; return NULL;
} }
void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callback) { void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callback, void * args) {
if(callback == NULL) return; if(callback == NULL) return;
if(!OSIsHomeButtonMenuEnabled()) return; // This pauses the game. Make sure to only do it when the home button is allowed. if(!OSIsHomeButtonMenuEnabled()) return; // This pauses the game. Make sure to only do it when the home button is allowed.
@ -151,7 +144,7 @@ void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callbac
// call the callback. // call the callback.
if(real_screen_type != WUPS_OVERLAY_NONE) { if(real_screen_type != WUPS_OVERLAY_NONE) {
callback(real_screen_type); callback(real_screen_type, args);
} }
if(tv_store.buffer != NULL) { if(tv_store.buffer != NULL) {
@ -175,7 +168,3 @@ error_exit:
return; return;
} }
#ifdef __cplusplus
}
#endif

View File

@ -1,12 +1,12 @@
#ifndef __OVERLAY_HELPER_H_ #ifndef __OVERLAY_HELPER_H_
#define __OVERLAY_HELPER_H_ #define __OVERLAY_HELPER_H_
#include <wups.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <wups.h>
struct buffer_store { struct buffer_store {
void * buffer; void * buffer;
int32_t buffer_size; int32_t buffer_size;
@ -15,10 +15,10 @@ struct buffer_store {
volatile int32_t buffering_mode; volatile int32_t buffering_mode;
}; };
void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callback);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
void overlay_helper(wups_overlay_options_type_t screen, overlay_callback callback, void * args);
#endif #endif

View File

@ -78,9 +78,9 @@ void WUPS_Overlay_FlipBuffers(wups_overlay_options_type_t screen) {
} }
} }
void WUPS_OpenOverlay(wups_overlay_options_type_t screen, overlay_callback callback) { void WUPS_OpenOverlay(wups_overlay_options_type_t screen, overlay_callback callback, void* arg) {
if(overlayfunction_ptr != NULL) { if(overlayfunction_ptr != NULL) {
overlayfunction_ptr(screen,callback); overlayfunction_ptr(screen, callback, arg);
} }
} }

View File

@ -33,9 +33,9 @@ typedef enum wups_overlay_options_type_t {
} }
wups_overlay_options_type_t; wups_overlay_options_type_t;
typedef void (*overlay_callback)(wups_overlay_options_type_t); typedef void (*overlay_callback)(wups_overlay_options_type_t, void*);
typedef void (*OverlayOpenFunction)(wups_overlay_options_type_t screen, overlay_callback callback); typedef void (*OverlayOpenFunction)(wups_overlay_options_type_t screen, overlay_callback callback, void*);
typedef struct wups_loader_init_overlay_args_t { typedef struct wups_loader_init_overlay_args_t {
OverlayOpenFunction overlayfunction_ptr; OverlayOpenFunction overlayfunction_ptr;
@ -109,7 +109,7 @@ void WUPS_Overlay_OSScreenClear(wups_overlay_options_type_t screen);
void WUPS_Overlay_FlipBuffers(wups_overlay_options_type_t screen); void WUPS_Overlay_FlipBuffers(wups_overlay_options_type_t screen);
void WUPS_OpenOverlay(wups_overlay_options_type_t screen, overlay_callback callback); void WUPS_OpenOverlay(wups_overlay_options_type_t screen, overlay_callback callback, void* args);
/** /**
Reads a 32bit value from a given address with kernel rights. Reads a 32bit value from a given address with kernel rights.