mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 10:20:51 +00:00
Merge pull request #6672 from gblues/master
Cleanup of Wii U launcher code
This commit is contained in:
commit
8484ea4154
@ -29,9 +29,10 @@ ifneq ($(V), 1)
|
||||
endif
|
||||
|
||||
OBJ :=
|
||||
OBJ += wiiu/input/wpad_driver.o
|
||||
OBJ += wiiu/input/kpad_driver.o
|
||||
OBJ += wiiu/input/pad_functions.o
|
||||
OBJ += wiiu/main.o
|
||||
OBJ += input/drivers_joypad/wiiu/wpad_driver.o
|
||||
OBJ += input/drivers_joypad/wiiu/kpad_driver.o
|
||||
OBJ += input/drivers_joypad/wiiu/pad_functions.o
|
||||
OBJ += wiiu/system/memory.o
|
||||
OBJ += wiiu/system/atomic.o
|
||||
OBJ += wiiu/system/exception_handler.o
|
||||
@ -47,8 +48,8 @@ endif
|
||||
|
||||
ifeq ($(WIIU_HID),1)
|
||||
DEFINES += -DWIIU_HID
|
||||
OBJ += wiiu/input/hidpad_driver.o
|
||||
OBJ += wiiu/input/wiiu_hid.o
|
||||
OBJ += input/drivers_joypad/wiiu/hidpad_driver.o
|
||||
OBJ += input/drivers_hid/wiiu_hid.o
|
||||
OBJ += input/connect/joypad_connection.o \
|
||||
input/common/hid/hid_device_driver.o \
|
||||
input/common/hid/device_wiiu_gca.o \
|
||||
@ -197,7 +198,16 @@ else
|
||||
ELF2RPL := $(ELF2RPL).exe
|
||||
endif
|
||||
|
||||
INCDIRS := -I. -Ideps -Ideps/stb -Ideps/libz -Ideps/7zip -Ilibretro-common/include -Iwiiu -Iwiiu/include -I$(DEVKITPRO)/portlibs/ppc/include
|
||||
INCDIRS := -I.
|
||||
INCDIRS += -Ideps
|
||||
INCDIRS += -Ideps/stb
|
||||
INCDIRS += -Ideps/libz
|
||||
INCDIRS += -Ideps/7zip
|
||||
INCDIRS += -Ilibretro-common/include
|
||||
INCDIRS += -Iinput/include
|
||||
INCDIRS += -Iwiiu
|
||||
INCDIRS += -Iwiiu/include
|
||||
INCDIRS += -I$(DEVKITPRO)/portlibs/ppc/include
|
||||
LIBDIRS := -L. -L$(DEVKITPRO)/portlibs/ppc/lib
|
||||
|
||||
CFLAGS := -mwup -mcpu=750 -meabi -mhard-float
|
||||
|
@ -14,54 +14,45 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <boolean.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/iosupport.h>
|
||||
#include <net/net_compat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <wiiu/types.h>
|
||||
#include <file/file_path.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <retro_timers.h>
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
#include <lists/file_list.h>
|
||||
#endif
|
||||
|
||||
#include "../frontend_driver.h"
|
||||
#include "../frontend.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../defaults.h"
|
||||
#include "../../paths.h"
|
||||
#include "retroarch.h"
|
||||
#include "file_path_special.h"
|
||||
#include "audio/audio_driver.h"
|
||||
#include <string/stdstring.h>
|
||||
|
||||
|
||||
#include "tasks/tasks_internal.h"
|
||||
#include "../../retroarch.h"
|
||||
#include <net/net_compat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "fs/fs_utils.h"
|
||||
#include "fs/sd_fat_devoptab.h"
|
||||
#include "system/dynamic.h"
|
||||
#include "system/memory.h"
|
||||
#include "system/exception_handler.h"
|
||||
#include <sys/iosupport.h>
|
||||
#include <wiiu/syshid.h>
|
||||
#include <wiiu/os/foreground.h>
|
||||
#include <wiiu/gx2/event.h>
|
||||
#include <wiiu/gx2.h>
|
||||
#include <wiiu/kpad.h>
|
||||
#include <wiiu/ios.h>
|
||||
#include <wiiu/os.h>
|
||||
#include <wiiu/procui.h>
|
||||
#include <wiiu/sysapp.h>
|
||||
#include <wiiu/ios.h>
|
||||
#include <wiiu/vpad.h>
|
||||
#include <wiiu/kpad.h>
|
||||
|
||||
#include <fat.h>
|
||||
#include <iosuhax.h>
|
||||
#include "wiiu_dbg.h"
|
||||
#include "file_path_special.h"
|
||||
|
||||
#include "../frontend.h"
|
||||
#include "../frontend_driver.h"
|
||||
#include "../../defaults.h"
|
||||
#include "../../paths.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../gfx/video_driver.h"
|
||||
|
||||
|
||||
#include "hbl.h"
|
||||
#include "wiiu_dbg.h"
|
||||
#include "system/exception_handler.h"
|
||||
#include "tasks/tasks_internal.h"
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
#ifdef HAVE_MENU
|
||||
@ -69,10 +60,13 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//#define WIIU_SD_PATH "/vol/external01/"
|
||||
#define WIIU_SD_PATH "sd:/"
|
||||
#define WIIU_USB_PATH "usb:/"
|
||||
|
||||
/**
|
||||
* The Wii U frontend driver, along with the main() method.
|
||||
*/
|
||||
|
||||
static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE;
|
||||
static const char *elf_path_cst = WIIU_SD_PATH "retroarch/retroarch.elf";
|
||||
|
||||
@ -311,16 +305,191 @@ frontend_ctx_driver_t frontend_ctx_wiiu =
|
||||
NULL, /* get_video_driver */
|
||||
};
|
||||
|
||||
/* main() and its supporting functions */
|
||||
|
||||
static void main_setup(void);
|
||||
static void get_arguments(int *argc, char ***argv);
|
||||
static void do_rarch_main(int argc, char **argv);
|
||||
static void main_loop(void);
|
||||
static void main_teardown(void);
|
||||
|
||||
static void init_network(void);
|
||||
static void init_logging(void);
|
||||
static void deinit_logging(void);
|
||||
static void wiiu_log_init(const char *ipString, int port);
|
||||
static void wiiu_log_deinit(void);
|
||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len);
|
||||
static void init_pad_libraries(void);
|
||||
static void deinit_pad_libraries(void);
|
||||
static void SaveCallback(void);
|
||||
static bool swap_is_pending(void *start_time);
|
||||
|
||||
static int wiiu_log_socket = -1;
|
||||
static volatile int wiiu_log_lock = 0;
|
||||
|
||||
void wiiu_log_init(const char *ipString, int port)
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
static devoptab_t dotab_stdout =
|
||||
{
|
||||
"stdout_net", /* device name */
|
||||
0, /* size of file structure */
|
||||
NULL, /* device open */
|
||||
NULL, /* device close */
|
||||
wiiu_log_write, /* device write */
|
||||
NULL, /* ... */
|
||||
};
|
||||
#endif /* defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
main_setup();
|
||||
get_arguments(&argc, &argv);
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
int salamander_main(argc, argv);
|
||||
salamander_main(argc, argv);
|
||||
#else
|
||||
do_rarch_main(argc, argv);
|
||||
main_loop();
|
||||
main_exit(NULL);
|
||||
#endif /* IS_SALAMANDER */
|
||||
main_teardown();
|
||||
|
||||
/* We always return 0 because if we don't, it can prevent loading a
|
||||
* different RPX/ELF in HBL. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_arguments(int *argc, char ***argv)
|
||||
{
|
||||
DEBUG_VAR(ARGV_PTR);
|
||||
if(ARGV_PTR && ((u32)ARGV_PTR < 0x01000000))
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 magic;
|
||||
u32 argc;
|
||||
char *argv[3];
|
||||
} *param = ARGV_PTR;
|
||||
if(param->magic == ARGV_MAGIC)
|
||||
{
|
||||
*argc = param->argc;
|
||||
*argv = param->argv;
|
||||
}
|
||||
ARGV_PTR = NULL;
|
||||
}
|
||||
|
||||
DEBUG_VAR(argc);
|
||||
DEBUG_VAR(argv[0]);
|
||||
DEBUG_VAR(argv[1]);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void main_setup(void)
|
||||
{
|
||||
setup_os_exceptions();
|
||||
ProcUIInit(&SaveCallback);
|
||||
init_network();
|
||||
init_logging();
|
||||
init_pad_libraries();
|
||||
verbosity_enable();
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void main_teardown(void)
|
||||
{
|
||||
deinit_pad_libraries();
|
||||
ProcUIShutdown();
|
||||
deinit_logging();
|
||||
}
|
||||
|
||||
static void main_loop(void)
|
||||
{
|
||||
unsigned sleep_ms = 0;
|
||||
OSTime start_time;
|
||||
int status;
|
||||
|
||||
do
|
||||
{
|
||||
if(video_driver_get_ptr(false))
|
||||
{
|
||||
start_time = OSGetSystemTime();
|
||||
task_queue_wait(swap_is_pending, &start_time);
|
||||
}
|
||||
else
|
||||
task_queue_wait(NULL, NULL);
|
||||
|
||||
status = runloop_iterate(&sleep_ms);
|
||||
|
||||
if(status == 1 && sleep_ms > 0)
|
||||
usleep(sleep_ms);
|
||||
|
||||
if(status == -1)
|
||||
break;
|
||||
} while(true);
|
||||
}
|
||||
|
||||
static void do_rarch_main(int argc, char **argv)
|
||||
{
|
||||
#if 0
|
||||
int argc_ = 2;
|
||||
char *argv_[] = { WIIU_SD_PATH "retroarch/retroarch.elf",
|
||||
WIIU_SD_PATH "rom.sfc",
|
||||
NULL };
|
||||
rarch_main(argc_, argv_, NULL);
|
||||
#else
|
||||
rarch_main(argc, argv, NULL);
|
||||
#endif /* if 0 */
|
||||
}
|
||||
|
||||
static void SaveCallback(void)
|
||||
{
|
||||
OSSavesDone_ReadyToRelease();
|
||||
}
|
||||
|
||||
static bool swap_is_pending(void *start_time)
|
||||
{
|
||||
uint32_t swap_count, flip_count;
|
||||
OSTime last_flip, last_vsync;
|
||||
|
||||
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
|
||||
return last_vsync < *(OSTime *)start_time;
|
||||
}
|
||||
|
||||
static void init_network(void)
|
||||
{
|
||||
#ifdef IS_SALAMANDER
|
||||
socket_lib_init();
|
||||
#else
|
||||
network_init();
|
||||
#endif /* IS_SALAMANDER */
|
||||
}
|
||||
|
||||
static void init_logging(void)
|
||||
{
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_init(PC_DEVELOPMENT_IP_ADDRESS, PC_DEVELOPMENT_TCP_PORT);
|
||||
devoptab_list[STD_OUT] = &dotab_stdout;
|
||||
devoptab_list[STD_ERR] = &dotab_stdout;
|
||||
#endif /* defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) */
|
||||
}
|
||||
|
||||
static void deinit_logging(void)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_deinit();
|
||||
#endif /* defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) */
|
||||
}
|
||||
|
||||
|
||||
static void wiiu_log_init(const char *ipString, int port)
|
||||
{
|
||||
wiiu_log_lock = 0;
|
||||
|
||||
wiiu_log_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (wiiu_log_socket < 0)
|
||||
if(wiiu_log_socket < 0)
|
||||
return;
|
||||
|
||||
struct sockaddr_in connect_addr;
|
||||
@ -329,50 +498,42 @@ void wiiu_log_init(const char *ipString, int port)
|
||||
connect_addr.sin_port = port;
|
||||
inet_aton(ipString, &connect_addr.sin_addr);
|
||||
|
||||
if (connect(wiiu_log_socket, (struct sockaddr *)&connect_addr, sizeof(connect_addr)) < 0)
|
||||
if(connect(wiiu_log_socket,
|
||||
(struct sockaddr *)&connect_addr,
|
||||
sizeof(connect_addr)) < 0)
|
||||
{
|
||||
socketclose(wiiu_log_socket);
|
||||
wiiu_log_socket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void wiiu_log_deinit(void)
|
||||
static void wiiu_log_deinit(void)
|
||||
{
|
||||
if (wiiu_log_socket >= 0)
|
||||
if(wiiu_log_socket >= 0)
|
||||
{
|
||||
socketclose(wiiu_log_socket);
|
||||
wiiu_log_socket = -1;
|
||||
}
|
||||
}
|
||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
|
||||
|
||||
static void init_pad_libraries(void)
|
||||
{
|
||||
if (wiiu_log_socket < 0)
|
||||
return len;
|
||||
|
||||
while (wiiu_log_lock)
|
||||
OSSleepTicks(((248625000 / 4)) / 1000);
|
||||
|
||||
wiiu_log_lock = 1;
|
||||
|
||||
int ret;
|
||||
int remaining = len;
|
||||
|
||||
while (remaining > 0)
|
||||
{
|
||||
int block = remaining < 1400 ? remaining : 1400; // take max 1400 bytes per UDP packet
|
||||
ret = send(wiiu_log_socket, ptr, block, 0);
|
||||
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
remaining -= ret;
|
||||
ptr += ret;
|
||||
}
|
||||
|
||||
wiiu_log_lock = 0;
|
||||
|
||||
return len;
|
||||
#ifndef IS_SALAMANDER
|
||||
KPADInit();
|
||||
WPADEnableURCC(true);
|
||||
WPADEnableWiiRemote(true);
|
||||
#endif /* IS_SALAMANDER */
|
||||
}
|
||||
|
||||
static void deinit_pad_libraries(void)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
KPADShutdown();
|
||||
#endif /* IS_SALAMANDER */
|
||||
}
|
||||
|
||||
/* logging routines */
|
||||
|
||||
void net_print(const char *str)
|
||||
{
|
||||
wiiu_log_write(NULL, 0, str, strlen(str));
|
||||
@ -383,273 +544,32 @@ void net_print_exp(const char *str)
|
||||
send(wiiu_log_socket, str, strlen(str), 0);
|
||||
}
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
static devoptab_t dotab_stdout =
|
||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
|
||||
{
|
||||
"stdout_net", // device name
|
||||
0, // size of file structure
|
||||
NULL, // device open
|
||||
NULL, // device close
|
||||
wiiu_log_write, // device write
|
||||
NULL,
|
||||
/* ... */
|
||||
};
|
||||
#endif
|
||||
if( wiiu_log_socket < 0)
|
||||
return len;
|
||||
|
||||
void SaveCallback(void)
|
||||
{
|
||||
OSSavesDone_ReadyToRelease();
|
||||
}
|
||||
while(wiiu_log_lock)
|
||||
OSSleepTicks(((248625000 / 4)) / 1000);
|
||||
|
||||
static bool swap_is_pending(void* start_time)
|
||||
{
|
||||
uint32_t swap_count, flip_count;
|
||||
OSTime last_flip , last_vsync;
|
||||
wiiu_log_lock = 1;
|
||||
|
||||
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
|
||||
int ret;
|
||||
int remaining = len;
|
||||
|
||||
return last_vsync < *(OSTime*)start_time;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setup_os_exceptions();
|
||||
ProcUIInit(&SaveCallback);
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
socket_lib_init();
|
||||
#else
|
||||
network_init();
|
||||
#endif
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_init(PC_DEVELOPMENT_IP_ADDRESS, PC_DEVELOPMENT_TCP_PORT);
|
||||
devoptab_list[STD_OUT] = &dotab_stdout;
|
||||
devoptab_list[STD_ERR] = &dotab_stdout;
|
||||
#endif
|
||||
#ifndef IS_SALAMANDER
|
||||
VPADInit();
|
||||
WPADEnableURCC(true);
|
||||
WPADEnableWiiRemote(true);
|
||||
KPADInit();
|
||||
#endif
|
||||
verbosity_enable();
|
||||
fflush(stdout);
|
||||
DEBUG_VAR(ARGV_PTR);
|
||||
if(ARGV_PTR && ((u32)ARGV_PTR < 0x01000000))
|
||||
while(remaining > 0)
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 magic;
|
||||
u32 argc;
|
||||
char * argv[3];
|
||||
}*param = ARGV_PTR;
|
||||
if(param->magic == ARGV_MAGIC)
|
||||
{
|
||||
argc = param->argc;
|
||||
argv = param->argv;
|
||||
}
|
||||
ARGV_PTR = NULL;
|
||||
}
|
||||
int block = remaining < 1400 ? remaining : 1400;
|
||||
ret = send(wiiu_log_socket, ptr, block, 0);
|
||||
|
||||
DEBUG_VAR(argc);
|
||||
DEBUG_STR(argv[0]);
|
||||
DEBUG_STR(argv[1]);
|
||||
fflush(stdout);
|
||||
#ifdef IS_SALAMANDER
|
||||
int salamander_main(int, char **);
|
||||
salamander_main(argc, argv);
|
||||
#else
|
||||
#if 1
|
||||
#if 0
|
||||
int argc_ = 2;
|
||||
// char* argv_[] = {WIIU_SD_PATH "retroarch/retroarch.elf", WIIU_SD_PATH "rom.nes", NULL};
|
||||
char *argv_[] = {WIIU_SD_PATH "retroarch/retroarch.elf", WIIU_SD_PATH "rom.sfc", NULL};
|
||||
|
||||
rarch_main(argc_, argv_, NULL);
|
||||
#else
|
||||
rarch_main(argc, argv, NULL);
|
||||
#endif
|
||||
do
|
||||
{
|
||||
unsigned sleep_ms = 0;
|
||||
|
||||
if(video_driver_get_ptr(false))
|
||||
{
|
||||
OSTime start_time = OSGetSystemTime();
|
||||
task_queue_wait(swap_is_pending, &start_time);
|
||||
}
|
||||
else
|
||||
task_queue_wait(NULL, NULL);
|
||||
|
||||
int ret = runloop_iterate(&sleep_ms);
|
||||
|
||||
if (ret == 1 && sleep_ms > 0)
|
||||
retro_sleep(sleep_ms);
|
||||
|
||||
|
||||
if (ret == -1)
|
||||
if(ret < 0)
|
||||
break;
|
||||
|
||||
}
|
||||
while (1);
|
||||
main_exit(NULL);
|
||||
#endif
|
||||
#endif
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
ProcUIShutdown();
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_deinit();
|
||||
#endif
|
||||
|
||||
/* returning non 0 here can prevent loading a different rpx/elf in the HBL environment */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __eabi(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void __init(void)
|
||||
{
|
||||
extern void (*const __CTOR_LIST__)(void);
|
||||
extern void (*const __CTOR_END__)(void);
|
||||
|
||||
void (*const *ctor)(void) = &__CTOR_LIST__;
|
||||
while (ctor < &__CTOR_END__) {
|
||||
(*ctor++)();
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void __fini(void)
|
||||
{
|
||||
extern void (*const __DTOR_LIST__)(void);
|
||||
extern void (*const __DTOR_END__)(void);
|
||||
|
||||
void (*const *dtor)(void) = &__DTOR_LIST__;
|
||||
while (dtor < &__DTOR_END__) {
|
||||
(*dtor++)();
|
||||
}
|
||||
}
|
||||
|
||||
/* libiosuhax related */
|
||||
|
||||
//just to be able to call async
|
||||
void someFunc(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
}
|
||||
|
||||
static int mcp_hook_fd = -1;
|
||||
|
||||
int MCPHookOpen(void)
|
||||
{
|
||||
//take over mcp thread
|
||||
mcp_hook_fd = IOS_Open("/dev/mcp", 0);
|
||||
|
||||
if (mcp_hook_fd < 0)
|
||||
return -1;
|
||||
|
||||
IOS_IoctlAsync(mcp_hook_fd, 0x62, (void *)0, 0, (void *)0, 0, someFunc, (void *)0);
|
||||
//let wupserver start up
|
||||
retro_sleep(1000);
|
||||
|
||||
if (IOSUHAX_Open("/dev/mcp") < 0)
|
||||
{
|
||||
IOS_Close(mcp_hook_fd);
|
||||
mcp_hook_fd = -1;
|
||||
return -1;
|
||||
remaining -= ret;
|
||||
ptr += ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MCPHookClose(void)
|
||||
{
|
||||
if (mcp_hook_fd < 0)
|
||||
return;
|
||||
|
||||
//close down wupserver, return control to mcp
|
||||
IOSUHAX_Close();
|
||||
//wait for mcp to return
|
||||
retro_sleep(1000);
|
||||
IOS_Close(mcp_hook_fd);
|
||||
mcp_hook_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
static int iosuhaxMount = 0;
|
||||
|
||||
static void fsdev_init(void)
|
||||
{
|
||||
iosuhaxMount = 0;
|
||||
int res = IOSUHAX_Open(NULL);
|
||||
|
||||
if (res < 0)
|
||||
res = MCPHookOpen();
|
||||
|
||||
if (res < 0)
|
||||
mount_sd_fat("sd");
|
||||
else
|
||||
{
|
||||
iosuhaxMount = 1;
|
||||
fatInitDefault();
|
||||
}
|
||||
}
|
||||
static void fsdev_exit(void)
|
||||
{
|
||||
if (iosuhaxMount)
|
||||
{
|
||||
fatUnmount("sd:");
|
||||
fatUnmount("usb:");
|
||||
|
||||
if (mcp_hook_fd >= 0)
|
||||
MCPHookClose();
|
||||
else
|
||||
IOSUHAX_Close();
|
||||
}
|
||||
else
|
||||
unmount_sd_fat("sd");
|
||||
|
||||
}
|
||||
|
||||
/* HBL elf entry point */
|
||||
int __entry_menu(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
InitFunctionPointers();
|
||||
memoryInitialize();
|
||||
__init();
|
||||
fsdev_init();
|
||||
|
||||
ret = main(argc, argv);
|
||||
|
||||
fsdev_exit();
|
||||
__fini();
|
||||
memoryRelease();
|
||||
return ret;
|
||||
}
|
||||
/* RPX entry point */
|
||||
__attribute__((noreturn))
|
||||
void _start(int argc, char **argv)
|
||||
{
|
||||
memoryInitialize();
|
||||
__init();
|
||||
fsdev_init();
|
||||
main(argc, argv);
|
||||
fsdev_exit();
|
||||
|
||||
/* TODO: fix elf2rpl so it doesn't error with "Could not find matching symbol
|
||||
for relocation" then uncomment this */
|
||||
#if 0
|
||||
__fini();
|
||||
#endif
|
||||
memoryRelease();
|
||||
SYSRelaunchTitle(0, 0);
|
||||
exit(0);
|
||||
wiiu_log_lock = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wiiu_hid.h"
|
||||
#include "../include/wiiu/hid.h"
|
||||
#include <wiiu/os/atomic.h>
|
||||
|
||||
static wiiu_event_list events;
|
@ -14,8 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include "wiiu_hid.h"
|
||||
#include "../../include/wiiu/input.h"
|
||||
|
||||
static bool hidpad_init(void *data);
|
||||
static bool hidpad_query_pad(unsigned pad);
|
@ -20,7 +20,7 @@
|
||||
* controllers.
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include "../../include/wiiu/input.h"
|
||||
|
||||
static bool kpad_init(void *data);
|
||||
static bool kpad_query_pad(unsigned pad);
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include "wiiu/input.h"
|
||||
|
||||
enum wiiu_pad_axes {
|
||||
AXIS_LEFT_ANALOG_X,
|
@ -21,7 +21,7 @@
|
||||
* - For HID controllers, see hid_driver.c
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include "../../include/wiiu/input.h"
|
||||
|
||||
#define PANIC_BUTTON_MASK (VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_STICK_R | VPAD_BUTTON_STICK_L)
|
||||
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../wiiu/input/wiiu_input.h"
|
||||
#include "../include/wiiu/input.h"
|
||||
|
||||
#include "wiiu_dbg.h"
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
#ifndef __WIIU_HID__H
|
||||
#define __WIIU_HID__H
|
||||
|
||||
#include "wiiu_hid_types.h"
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include "hid_types.h"
|
||||
#include "input.h"
|
||||
#include "../../common/hid/hid_device_driver.h"
|
||||
|
||||
#define DEVICE_UNUSED 0
|
||||
#define DEVICE_USED 1
|
@ -17,31 +17,33 @@
|
||||
#ifndef __WIIU_INPUT__H
|
||||
#define __WIIU_INPUT__H
|
||||
|
||||
#include "wiiu_hid_types.h"
|
||||
#include "../../input/include/gamepad.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hid_types.h"
|
||||
#include "../gamepad.h"
|
||||
|
||||
#include <wiiu/os.h>
|
||||
#include <wiiu/syshid.h>
|
||||
#include <wiiu/vpad.h>
|
||||
#include <wiiu/kpad.h>
|
||||
#include <wiiu/pad_strings.h>
|
||||
#include "hid.h"
|
||||
|
||||
#include "../../input/input_driver.h"
|
||||
#include "../../input/common/hid/hid_device_driver.h"
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../../input/connect/joypad_connection.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../command.h"
|
||||
#include "../../gfx/video_driver.h"
|
||||
#include "wiiu_hid.h"
|
||||
#include "../../input_driver.h"
|
||||
#include "../../common/hid/hid_device_driver.h"
|
||||
#include "../../connect/joypad_connection.h"
|
||||
#include "../../../retroarch.h"
|
||||
#include "../../../verbosity.h"
|
||||
#include "../../../command.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../../config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include "../../../gfx/video_driver.h"
|
||||
#include "../../../tasks/tasks_internal.h"
|
||||
|
||||
#define WIIMOTE_TYPE_WIIPLUS 0x00
|
||||
#define WIIMOTE_TYPE_NUNCHUK 0x01
|
@ -1,6 +1,8 @@
|
||||
#ifndef __WIIU_HBL_LOADER_H__
|
||||
#define __WIIU_HBL_LOADER_H__
|
||||
|
||||
#include "wiiu/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -65,9 +65,35 @@ typedef struct _KPADData
|
||||
|
||||
|
||||
void KPADInit (void);
|
||||
void KPADShutdown(void);
|
||||
s32 KPADRead(s32 chan, void * data, u32 size);
|
||||
s32 KPADReadEx(s32 chan, KPADData * data, u32 size, s32 *error);
|
||||
|
||||
typedef s32 WPADChannel;
|
||||
/* legal values for WPADChannel */
|
||||
enum {
|
||||
WPAD_CHAN0 = 0,
|
||||
WPAD_CHAN1 = 1,
|
||||
WPAD_CHAN2 = 2,
|
||||
WPAD_CHAN3 = 3
|
||||
};
|
||||
|
||||
typedef s8 WPADError;
|
||||
/* legal values for WPADError */
|
||||
enum {
|
||||
WPAD_ERROR_NONE = 0,
|
||||
WPAD_ERROR_NO_CONTROLLER = -1,
|
||||
WPAD_ERROR_BUSY = -2,
|
||||
WPAD_ERROR_TRANSFER = -3,
|
||||
WPAD_ERROR_INVALID = -4,
|
||||
WPAD_ERROR_NOPERM = -5,
|
||||
WPAD_ERROR_BROKEN = -6,
|
||||
WPAD_ERROR_CORRUPTED = -7
|
||||
};
|
||||
|
||||
typedef void (*WPADConnectCallback) (WPADChannel channel, WPADError reason);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
197
wiiu/main.c
Normal file
197
wiiu/main.c
Normal file
@ -0,0 +1,197 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2016 - Ali Bouhlel
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch 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 Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch 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 RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fat.h>
|
||||
#include <iosuhax.h>
|
||||
#include <sys/iosupport.h>
|
||||
|
||||
#include "hbl.h"
|
||||
|
||||
#include "fs/fs_utils.h"
|
||||
#include "fs/sd_fat_devoptab.h"
|
||||
|
||||
#include "system/dynamic.h"
|
||||
#include "system/memory.h"
|
||||
#include "system/exception_handler.h"
|
||||
|
||||
#include <wiiu/gx2.h>
|
||||
#include <wiiu/ios.h>
|
||||
#include <wiiu/kpad.h>
|
||||
#include <wiiu/os.h>
|
||||
#include <wiiu/procui.h>
|
||||
#include <wiiu/sysapp.h>
|
||||
|
||||
/**
|
||||
* This file contains the main entrypoints for the Wii U executable that
|
||||
* set up the call to main().
|
||||
*/
|
||||
|
||||
int main(int argc, char **argv);
|
||||
void __fini(void);
|
||||
void __init(void);
|
||||
|
||||
static void fsdev_init(void);
|
||||
static void fsdev_exit(void);
|
||||
|
||||
static int iosuhaxMount = 0;
|
||||
static int mcp_hook_fd = -1;
|
||||
|
||||
/* HBL elf entry point */
|
||||
int __entry_menu(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
InitFunctionPointers();
|
||||
memoryInitialize();
|
||||
__init();
|
||||
fsdev_init();
|
||||
|
||||
ret = main(argc, argv);
|
||||
|
||||
fsdev_exit();
|
||||
__fini();
|
||||
memoryRelease();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* RPX entry point */
|
||||
__attribute__((noreturn))
|
||||
void _start(int argc, char **argv)
|
||||
{
|
||||
memoryInitialize();
|
||||
__init();
|
||||
fsdev_init();
|
||||
main(argc, argv);
|
||||
fsdev_exit();
|
||||
|
||||
/* TODO: fix elf2rpl so it doesn't error with "Could not find matching symbol
|
||||
for relocation" then uncomment this */
|
||||
#if 0
|
||||
__fini();
|
||||
#endif
|
||||
memoryRelease();
|
||||
SYSRelaunchTitle(0, 0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void __eabi(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void __init(void)
|
||||
{
|
||||
extern void (*const __CTOR_LIST__)(void);
|
||||
extern void (*const __CTOR_END__)(void);
|
||||
|
||||
void (*const *ctor)(void) = &__CTOR_LIST__;
|
||||
while (ctor < &__CTOR_END__) {
|
||||
(*ctor++)();
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void __fini(void)
|
||||
{
|
||||
extern void (*const __DTOR_LIST__)(void);
|
||||
extern void (*const __DTOR_END__)(void);
|
||||
|
||||
void (*const *dtor)(void) = &__DTOR_LIST__;
|
||||
while (dtor < &__DTOR_END__) {
|
||||
(*dtor++)();
|
||||
}
|
||||
}
|
||||
|
||||
/* libiosuhax related */
|
||||
|
||||
//just to be able to call async
|
||||
void someFunc(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
}
|
||||
|
||||
int MCPHookOpen(void)
|
||||
{
|
||||
//take over mcp thread
|
||||
mcp_hook_fd = IOS_Open("/dev/mcp", 0);
|
||||
|
||||
if (mcp_hook_fd < 0)
|
||||
return -1;
|
||||
|
||||
IOS_IoctlAsync(mcp_hook_fd, 0x62, (void *)0, 0, (void *)0, 0, someFunc, (void *)0);
|
||||
//let wupserver start up
|
||||
usleep(1000);
|
||||
|
||||
if (IOSUHAX_Open("/dev/mcp") < 0)
|
||||
{
|
||||
IOS_Close(mcp_hook_fd);
|
||||
mcp_hook_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MCPHookClose(void)
|
||||
{
|
||||
if (mcp_hook_fd < 0)
|
||||
return;
|
||||
|
||||
//close down wupserver, return control to mcp
|
||||
IOSUHAX_Close();
|
||||
//wait for mcp to return
|
||||
usleep(1000);
|
||||
IOS_Close(mcp_hook_fd);
|
||||
mcp_hook_fd = -1;
|
||||
}
|
||||
|
||||
static void fsdev_init(void)
|
||||
{
|
||||
iosuhaxMount = 0;
|
||||
int res = IOSUHAX_Open(NULL);
|
||||
|
||||
if (res < 0)
|
||||
res = MCPHookOpen();
|
||||
|
||||
if (res < 0)
|
||||
mount_sd_fat("sd");
|
||||
else
|
||||
{
|
||||
iosuhaxMount = 1;
|
||||
fatInitDefault();
|
||||
}
|
||||
}
|
||||
|
||||
static void fsdev_exit(void)
|
||||
{
|
||||
if (iosuhaxMount)
|
||||
{
|
||||
fatUnmount("sd:");
|
||||
fatUnmount("usb:");
|
||||
|
||||
if (mcp_hook_fd >= 0)
|
||||
MCPHookClose();
|
||||
else
|
||||
IOSUHAX_Close();
|
||||
}
|
||||
else
|
||||
unmount_sd_fat("sd");
|
||||
}
|
@ -249,16 +249,17 @@ IMPORT_END();
|
||||
|
||||
/* padscore */
|
||||
IMPORT_BEGIN(padscore);
|
||||
|
||||
IMPORT(KPADInit);
|
||||
IMPORT(WPADProbe);
|
||||
IMPORT(KPADSetConnectCallback);
|
||||
|
||||
IMPORT(WPADSetDataFormat);
|
||||
IMPORT(WPADEnableURCC);
|
||||
IMPORT(WPADEnableWiiRemote);
|
||||
IMPORT(WPADRead);
|
||||
IMPORT(KPADRead);
|
||||
IMPORT(KPADReadEx);
|
||||
|
||||
IMPORT(KPADShutdown);
|
||||
IMPORT_END();
|
||||
|
||||
/* nsyskbd */
|
||||
|
Loading…
x
Reference in New Issue
Block a user