mirror of https://github.com/mgba-emu/mgba.git
Switch: Support file associations
This commit is contained in:
parent
aead90a2c1
commit
43b6004cea
1
CHANGES
1
CHANGES
|
@ -64,6 +64,7 @@ Misc:
|
|||
- mGUI: Remember name and position of last loaded game
|
||||
- Core: Create game-related paths if they don't exist (fixes mgba.io/i/1446)
|
||||
- Qt: Add option to pause on minimizing window (closes mgba.io/i/1379)
|
||||
- Switch: Support file associations
|
||||
|
||||
0.7.2: (2019-05-25)
|
||||
Emulation fixes:
|
||||
|
|
|
@ -42,9 +42,10 @@ add_custom_command(OUTPUT control.nacp
|
|||
add_custom_command(OUTPUT romfs.bin
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory romfs
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/res/font-new.png" romfs/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/fileassoc.cfg.in" romfs/
|
||||
COMMAND ${BUILD_ROMFS} romfs romfs.bin
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory romfs
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/res/font-new.png")
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/res/font-new.png" "${CMAKE_CURRENT_SOURCE_DIR}/fileassoc.cfg.in")
|
||||
|
||||
add_custom_target(${BINARY_NAME}.nro ALL
|
||||
${ELF2NRO} ${BINARY_NAME}.elf ${BINARY_NAME}.nro --romfs=romfs.bin --nacp=control.nacp --icon="${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
fileassoc={
|
||||
app_path="%s";
|
||||
|
||||
targets=(
|
||||
{
|
||||
file_extension=".gba";
|
||||
},
|
||||
{
|
||||
file_extension=".gb";
|
||||
},
|
||||
{
|
||||
file_extension=".gbc";
|
||||
},
|
||||
{
|
||||
file_extension=".sgb";
|
||||
}
|
||||
);
|
||||
};
|
|
@ -12,6 +12,7 @@
|
|||
#include <mgba-util/gui.h>
|
||||
#include <mgba-util/gui/font.h>
|
||||
#include <mgba-util/gui/menu.h>
|
||||
#include <mgba-util/vfs.h>
|
||||
|
||||
#include <switch.h>
|
||||
#include <EGL/egl.h>
|
||||
|
@ -921,6 +922,29 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
audoutStartAudioOut();
|
||||
|
||||
if (argc > 0) {
|
||||
struct VFile* vf = VFileOpen("romfs:/fileassoc.cfg.in", O_RDONLY);
|
||||
if (vf) {
|
||||
size_t size = vf->size(vf);
|
||||
const char* arg0 = strchr(argv[0], '/');
|
||||
char* buffer[2] = {
|
||||
calloc(size + 1, 1),
|
||||
malloc(size + strlen(arg0) + 1)
|
||||
};
|
||||
vf->read(vf, buffer[0], vf->size(vf));
|
||||
vf->close(vf);
|
||||
snprintf(buffer[1], size + strlen(arg0), buffer[0], arg0);
|
||||
mkdir("sdmc:/config/nx-hbmenu/fileassoc", 0755);
|
||||
vf = VFileOpen("sdmc:/config/nx-hbmenu/fileassoc/mgba.cfg", O_CREAT | O_TRUNC | O_WRONLY);
|
||||
if (vf) {
|
||||
vf->write(vf, buffer[1], strlen(buffer[1]));
|
||||
vf->close(vf);
|
||||
}
|
||||
free(buffer[0]);
|
||||
free(buffer[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
size_t i;
|
||||
for (i = 0; runner.keySources[i].id; ++i) {
|
||||
|
|
Loading…
Reference in New Issue