Files
aaruremote/wii/list_devices.c

71 lines
2.3 KiB
C
Raw Normal View History

2019-10-20 23:05:34 +01:00
/*
2020-03-01 05:44:49 +00:00
* This file is part of the Aaru Remote Server.
2020-01-03 17:42:13 +00:00
* Copyright (c) 2019-2020 Natalia Portillo.
2019-10-20 23:05:34 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2020-03-01 05:46:10 +00:00
#include "../aaruremote.h"
#include "wii.h"
2019-10-20 23:05:34 +01:00
#include <gccore.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
DeviceInfoList* WiiListDevices()
{
DeviceInfoList *list_start = NULL, *list_current = NULL, *list_next = NULL;
u32 deviceId = 0;
s32 sd_fd;
2019-10-20 23:05:34 +01:00
list_next = malloc(sizeof(DeviceInfoList));
memset(list_next, 0, sizeof(DeviceInfoList));
// All Wiis do have flash
strncpy(list_next->this.path, DICREMOTE_WII_DEVICE_PATH_NAND, 1024);
2019-10-20 23:05:34 +01:00
strncpy(list_next->this.vendor, "Nintendo", 256);
strncpy(list_next->this.model, "Wii NAND", 256);
strncpy(list_next->this.bus, "NAND", 256);
list_next->this.supported = false; // TODO: Implement NAND reading
if(ES_GetDeviceID(&deviceId) < 0) snprintf(list_next->this.serial, 256, "%d", deviceId);
list_start = list_next;
list_current = list_start;
sd_fd = IOS_Open(DICREMOTE_WII_DEVICE_PATH_SD, 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);
}
2019-10-20 23:05:34 +01:00
return list_start;
}