first pass, broken on xdg-portal because of course it is. thanks dbus
This commit is contained in:
parent
a687f0bed0
commit
2eb14f09e1
1 changed files with 24 additions and 1 deletions
25
main.c
25
main.c
|
@ -1,6 +1,8 @@
|
|||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include "SDL3/SDL_atomic.h"
|
||||
#include "SDL3/SDL_blendmode.h"
|
||||
#include "SDL3/SDL_camera.h"
|
||||
#include "SDL3/SDL_dialog.h"
|
||||
#include "SDL3/SDL_error.h"
|
||||
#include "SDL3/SDL_events.h"
|
||||
#include "SDL3/SDL_init.h"
|
||||
|
@ -79,6 +81,17 @@ enum mColorFormat pixfmt_sdl_to_mgba(uint32_t sdl_fmt) {
|
|||
}
|
||||
}
|
||||
|
||||
const SDL_DialogFileFilter DIALOG_FILENAME_FILTER[1] = {{ "Gameboy Camera ROM", "gb" }};
|
||||
|
||||
static void SDLCALL dialog_callback(void* userdata, const char* const* files, int filter) {
|
||||
if (files && *files) {
|
||||
SDL_Log("\nSelected: %s", *files);
|
||||
SDL_SetAtomicPointer((void**)userdata, strdup(*files));
|
||||
} else {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void myStartRequestImageRed(struct mImageSource* self, unsigned w, unsigned h, int colorFormats) {
|
||||
SDL_DestroySurface(scaled);
|
||||
SDL_DestroySurface(filtered[0]);
|
||||
|
@ -256,7 +269,7 @@ bool SelectCamera(struct AppState* st) {
|
|||
return true;
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_AppInit(void** appstate, int argc, char *argv[]) {
|
||||
SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]) {
|
||||
int i;
|
||||
unsigned w, h;
|
||||
|
||||
|
@ -275,6 +288,16 @@ SDL_AppResult SDL_AppInit(void** appstate, int argc, char *argv[]) {
|
|||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (!args.fname) {
|
||||
SDL_ShowOpenFileDialog(dialog_callback, &args.fname, NULL, DIALOG_FILENAME_FILTER, 1, NULL, false);
|
||||
printf("Must provide a Gameboy Camera ROM");
|
||||
do {
|
||||
putchar('.');
|
||||
fflush(stdout);
|
||||
SDL_Delay(1000);
|
||||
} while (!SDL_GetAtomicPointer((void**)&args.fname));
|
||||
}
|
||||
|
||||
gb_img_src[0].requestImage = myRequestImageRed;
|
||||
gb_img_src[0].startRequestImage = myStartRequestImageRed;
|
||||
gb_img_src[0].stopRequestImage = myStopRequestImageRed;
|
||||
|
|
Loading…
Add table
Reference in a new issue