mirror of https://github.com/mgba-emu/mgba.git
Wii: List devices at root
This commit is contained in:
parent
7d9a897700
commit
2495b650a4
|
@ -209,7 +209,7 @@ void GBAConfigDirectory(char* out, size_t outLength) {
|
||||||
sceIoMkdir(out, 0777);
|
sceIoMkdir(out, 0777);
|
||||||
#elif defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
UNUSED(portable);
|
UNUSED(portable);
|
||||||
snprintf(out, outLength, "/%s", projectName);
|
snprintf(out, outLength, "sd:/%s", projectName);
|
||||||
mkdir(out, 0777);
|
mkdir(out, 0777);
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
snprintf(out, outLength, "/%s", projectName);
|
snprintf(out, outLength, "/%s", projectName);
|
||||||
|
|
|
@ -4,7 +4,7 @@ find_program(RAW2C raw2c)
|
||||||
find_program(WIILOAD wiiload)
|
find_program(WIILOAD wiiload)
|
||||||
|
|
||||||
set(OS_DEFINES COLOR_16_BIT COLOR_5_6_5 USE_VFS_FILE)
|
set(OS_DEFINES COLOR_16_BIT COLOR_5_6_5 USE_VFS_FILE)
|
||||||
list(APPEND VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-file.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
|
list(APPEND VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-file.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-devlist.c)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ int main() {
|
||||||
|
|
||||||
font = GUIFontCreate();
|
font = GUIFontCreate();
|
||||||
|
|
||||||
fatInitDefault();
|
fatInit(4, false);
|
||||||
|
|
||||||
rumble.setRumble = _setRumble;
|
rumble.setRumble = _setRumble;
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ int main() {
|
||||||
struct GBAGUIRunner runner = {
|
struct GBAGUIRunner runner = {
|
||||||
.params = {
|
.params = {
|
||||||
vmode->fbWidth * 0.9, vmode->efbHeight * 0.9,
|
vmode->fbWidth * 0.9, vmode->efbHeight * 0.9,
|
||||||
font, "/",
|
font, "",
|
||||||
_drawStart, _drawEnd,
|
_drawStart, _drawEnd,
|
||||||
_pollInput, _pollCursor,
|
_pollInput, _pollCursor,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -32,6 +32,7 @@ static void _cleanFiles(struct GUIMenuItemList* currentFiles) {
|
||||||
static void _upDirectory(char* currentPath) {
|
static void _upDirectory(char* currentPath) {
|
||||||
char* end = strrchr(currentPath, '/');
|
char* end = strrchr(currentPath, '/');
|
||||||
if (!end) {
|
if (!end) {
|
||||||
|
currentPath[0] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (end == currentPath) {
|
if (end == currentPath) {
|
||||||
|
@ -163,7 +164,7 @@ bool GUISelectFile(struct GUIParams* params, char* outPath, size_t outLen, bool
|
||||||
} else {
|
} else {
|
||||||
size_t len = strlen(params->currentPath);
|
size_t len = strlen(params->currentPath);
|
||||||
const char* sep = PATH_SEP;
|
const char* sep = PATH_SEP;
|
||||||
if (params->currentPath[len - 1] == *sep) {
|
if (!len || params->currentPath[len - 1] == *sep) {
|
||||||
sep = "";
|
sep = "";
|
||||||
}
|
}
|
||||||
snprintf(outPath, outLen, "%s%s%s", params->currentPath, sep, item->title);
|
snprintf(outPath, outLen, "%s%s%s", params->currentPath, sep, item->title);
|
||||||
|
|
|
@ -80,6 +80,8 @@ struct VDir* VDirOpenZip(const char* path, int flags);
|
||||||
struct VDir* VDirOpen7z(const char* path, int flags);
|
struct VDir* VDirOpen7z(const char* path, int flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct VDir* VDeviceList(void);
|
||||||
|
|
||||||
struct VFile* VDirOptionalOpenFile(struct VDir* dir, const char* realPath, const char* prefix, const char* suffix,
|
struct VFile* VDirOptionalOpenFile(struct VDir* dir, const char* realPath, const char* prefix, const char* suffix,
|
||||||
int mode);
|
int mode);
|
||||||
struct VFile* VDirOptionalOpenIncrementFile(struct VDir* dir, const char* realPath, const char* prefix,
|
struct VFile* VDirOptionalOpenIncrementFile(struct VDir* dir, const char* realPath, const char* prefix,
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
/* Copyright (c) 2013-2015 Jeffrey Pfau
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
#include "util/vfs.h"
|
||||||
|
|
||||||
|
#include <fat.h>
|
||||||
|
|
||||||
|
static bool _vdlClose(struct VDir* vd);
|
||||||
|
static void _vdlRewind(struct VDir* vd);
|
||||||
|
static struct VDirEntry* _vdlListNext(struct VDir* vd);
|
||||||
|
static struct VFile* _vdlOpenFile(struct VDir* vd, const char* path, int mode);
|
||||||
|
static struct VDir* _vdlOpenDir(struct VDir* vd, const char* path);
|
||||||
|
|
||||||
|
static const char* _vdleName(struct VDirEntry* vde);
|
||||||
|
static enum VFSType _vdleType(struct VDirEntry* vde);
|
||||||
|
|
||||||
|
extern const struct {
|
||||||
|
const char* name;
|
||||||
|
const DISC_INTERFACE* (*getInterface)(void);
|
||||||
|
} _FAT_disc_interfaces[];
|
||||||
|
|
||||||
|
struct VDirEntryDevList {
|
||||||
|
struct VDirEntry d;
|
||||||
|
size_t index;
|
||||||
|
char* name;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VDirDevList {
|
||||||
|
struct VDir d;
|
||||||
|
struct VDirEntryDevList vde;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VDir* VDeviceList() {
|
||||||
|
struct VDirDevList* vd = malloc(sizeof(struct VDirDevList));
|
||||||
|
if (!vd) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vd->d.close = _vdlClose;
|
||||||
|
vd->d.rewind = _vdlRewind;
|
||||||
|
vd->d.listNext = _vdlListNext;
|
||||||
|
vd->d.openFile = _vdlOpenFile;
|
||||||
|
vd->d.openDir = _vdlOpenDir;
|
||||||
|
|
||||||
|
vd->vde.d.name = _vdleName;
|
||||||
|
vd->vde.d.type = _vdleType;
|
||||||
|
vd->vde.index = 0;
|
||||||
|
vd->vde.name = 0;
|
||||||
|
|
||||||
|
return &vd->d;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool _vdlClose(struct VDir* vd) {
|
||||||
|
struct VDirDevList* vdl = (struct VDirDevList*) vd;
|
||||||
|
free(vdl->vde.name);
|
||||||
|
free(vdl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _vdlRewind(struct VDir* vd) {
|
||||||
|
struct VDirDevList* vdl = (struct VDirDevList*) vd;
|
||||||
|
free(vdl->vde.name);
|
||||||
|
vdl->vde.name = 0;
|
||||||
|
vdl->vde.index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct VDirEntry* _vdlListNext(struct VDir* vd) {
|
||||||
|
struct VDirDevList* vdl = (struct VDirDevList*) vd;
|
||||||
|
if (vdl->vde.name) {
|
||||||
|
++vdl->vde.index;
|
||||||
|
free(vdl->vde.name);
|
||||||
|
vdl->vde.name = 0;
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!_FAT_disc_interfaces[vdl->vde.index].name || !_FAT_disc_interfaces[vdl->vde.index].getInterface) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
const DISC_INTERFACE* iface = _FAT_disc_interfaces[vdl->vde.index].getInterface();
|
||||||
|
if (iface && iface->isInserted()) {
|
||||||
|
vdl->vde.name = malloc(strlen(_FAT_disc_interfaces[vdl->vde.index].name) + 3);
|
||||||
|
sprintf(vdl->vde.name, "%s:", _FAT_disc_interfaces[vdl->vde.index].name);
|
||||||
|
return &vdl->vde.d;
|
||||||
|
}
|
||||||
|
|
||||||
|
++vdl->vde.index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct VFile* _vdlOpenFile(struct VDir* vd, const char* path, int mode) {
|
||||||
|
UNUSED(vd);
|
||||||
|
UNUSED(path);
|
||||||
|
UNUSED(mode);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct VDir* _vdlOpenDir(struct VDir* vd, const char* path) {
|
||||||
|
UNUSED(vd);
|
||||||
|
return VDirOpen(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* _vdleName(struct VDirEntry* vde) {
|
||||||
|
struct VDirEntryDevList* vdle = (struct VDirEntryDevList*) vde;
|
||||||
|
return vdle->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum VFSType _vdleType(struct VDirEntry* vde) {
|
||||||
|
UNUSED(vde);
|
||||||
|
return VFS_DIRECTORY;
|
||||||
|
}
|
|
@ -34,6 +34,11 @@ struct VDirDE {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VDir* VDirOpen(const char* path) {
|
struct VDir* VDirOpen(const char* path) {
|
||||||
|
#ifdef __wii__
|
||||||
|
if (!path || !path[0]) {
|
||||||
|
return VDeviceList();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
DIR* de = opendir(path);
|
DIR* de = opendir(path);
|
||||||
if (!de) {
|
if (!de) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue