Add detection of SD card present in Wii for list devices.

This commit is contained in:
2019-10-20 23:19:37 +01:00
parent 0a2fb891b7
commit 73aa71c5ce
2 changed files with 27 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
*/
#include "../dicmote.h"
#include "wii.h"
#include <gccore.h>
#include <stdbool.h>
@@ -27,8 +28,8 @@
DeviceInfoList* WiiListDevices()
{
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
u32 deviceId = 0;
u32 deviceId = 0;
s32 sd_fd;
list_next = malloc(sizeof(DeviceInfoList));
memset(list_next, 0, sizeof(DeviceInfoList));
@@ -45,5 +46,26 @@ DeviceInfoList* WiiListDevices()
list_start = list_next;
list_current = list_start;
sd_fd = IOS_Open("/dev/sdio/slot0", IPC_OPEN_READ);
if(sd_fd >= 0)
{
deviceId = 0;
IOS_Ioctl(sd_fd, DICREMOTE_WII_IOCTL_SD_GET_DEVICE_STATUS, 0, 0, &deviceId, sizeof(deviceId));
if(deviceId == DICREMOTE_WII_SD_INSERTED)
{
strncpy(list_next->this.path, "/dev/flash", 1024);
strncpy(list_next->this.vendor, "Nintendo", 256);
strncpy(list_next->this.model, "Wii SD", 256);
strncpy(list_next->this.bus, "MMC/SD", 256);
list_next->this.supported = false; // TODO: Implement SD/MMC reading
list_current->next = list_next;
list_current = list_next;
}
IOS_Close(sd_fd);
}
return list_start;
}

View File

@@ -26,6 +26,9 @@
#define DICREMOTE_WII_DEVICE_FD_GCMM_A 4
#define DICREMOTE_WII_DEVICE_FD_GCMM_B 5
#define DICREMOTE_WII_IOCTL_SD_GET_DEVICE_STATUS 0x0B
#define DICREMOTE_WII_SD_INSERTED 1
DeviceInfoList* WiiListDevices();
#endif // DICREMOTE_WII_WII_H_