2020-10-14 13:54:25 +02:00
# include <coreinit/debug.h>
# include <whb/proc.h>
# include <whb/log.h>
2020-10-15 20:14:00 +02:00
# include <whb/log_udp.h>
2020-10-14 13:54:25 +02:00
# include <iosuhax.h>
# include <iosuhax_devoptab.h>
2020-10-15 20:14:00 +02:00
# include <string_view>
2020-10-14 13:54:25 +02:00
# include "WiiUScreen.h"
2020-10-15 20:14:00 +02:00
# include "InstallerService.h"
2020-10-14 13:54:25 +02:00
2020-10-16 19:48:13 +02:00
# include "ApplicationState.h"
2020-12-02 23:37:31 +01:00
# include "WPADInput.h"
2020-11-30 17:49:32 +01:00
# include "../build/safe_payload.h"
2020-10-14 13:54:25 +02:00
2020-10-15 20:14:00 +02:00
constexpr bool strings_equal ( char const * a , char const * b ) {
return std : : string_view ( a ) = = b ;
}
2020-10-14 13:54:25 +02:00
2020-11-30 17:49:32 +01:00
static_assert ( strings_equal ( RPX_HASH , " 116cff322148216f38b1eaaf296d1cffc6a3a98f " ) , " Built with an untested root.rpx! Remove this check if you really know what you're doing. " ) ;
2020-10-14 13:54:25 +02:00
2020-10-15 20:14:00 +02:00
void initIOSUHax ( ) ;
2020-10-14 13:54:25 +02:00
2020-10-15 20:14:00 +02:00
void deInitIOSUHax ( ) ;
2020-10-14 13:54:25 +02:00
2020-10-16 19:48:13 +02:00
int sFSAFd = - 1 ;
bool sIosuhaxMount = false ;
2020-10-14 13:54:25 +02:00
2020-10-16 19:48:13 +02:00
int main_loop ( ) {
2020-10-15 20:14:00 +02:00
DEBUG_FUNCTION_LINE ( " Creating state " ) ;
2020-10-16 19:48:13 +02:00
ApplicationState state ;
2020-12-02 23:37:31 +01:00
VPadInput vpadInput ;
WPADInput wpadInputs [ 4 ] = {
WPAD_CHAN_0 ,
WPAD_CHAN_1 ,
WPAD_CHAN_2 ,
WPAD_CHAN_3
} ;
2020-10-16 19:48:13 +02:00
if ( sFSAFd < 0 | | ! sIosuhaxMount ) {
state . setError ( ApplicationState : : eErrorState : : ERROR_IOSUHAX_FAILED ) ;
}
2020-10-14 13:54:25 +02:00
2020-10-15 20:14:00 +02:00
DEBUG_FUNCTION_LINE ( " Entering main loop " ) ;
while ( WHBProcIsRunning ( ) ) {
2020-12-02 23:37:31 +01:00
vpadInput . update ( 1280 , 720 ) ;
for ( int i = 0 ; i < 4 ; i + + ) {
wpadInputs [ i ] . update ( 1280 , 720 ) ;
2020-12-03 01:00:38 +01:00
vpadInput . combine ( wpadInputs [ i ] ) ;
2020-12-02 23:37:31 +01:00
}
2020-12-03 01:00:38 +01:00
state . update ( & vpadInput ) ;
2020-10-15 20:14:00 +02:00
state . render ( ) ;
2020-10-14 13:54:25 +02:00
}
return 0 ;
}
int main ( int argc , char * * argv ) {
2020-10-15 20:14:00 +02:00
WHBLogUdpInit ( ) ;
DEBUG_FUNCTION_LINE ( " Hello from Aroma Installer! " ) ;
2020-10-14 13:54:25 +02:00
WHBProcInit ( ) ;
WiiUScreen : : Init ( ) ;
initIOSUHax ( ) ;
2020-12-02 23:37:31 +01:00
WPADInput : : init ( ) ;
2020-10-16 19:48:13 +02:00
main_loop ( ) ;
2020-10-14 13:54:25 +02:00
2020-12-02 23:37:31 +01:00
WPADInput : : close ( ) ;
2020-10-14 13:54:25 +02:00
deInitIOSUHax ( ) ;
WiiUScreen : : DeInit ( ) ;
WHBProcShutdown ( ) ;
return 0 ;
}
void initIOSUHax ( ) {
sIosuhaxMount = false ;
int res = IOSUHAX_Open ( nullptr ) ;
if ( res < 0 ) {
DEBUG_FUNCTION_LINE ( " IOSUHAX_open failed " ) ;
OSFatal ( " IOSUHAX_open failed, please start this installer with an CFW " ) ;
} else {
sIosuhaxMount = true ;
sFSAFd = IOSUHAX_FSA_Open ( ) ;
2020-10-15 20:14:00 +02:00
if ( sFSAFd < 0 ) {
2020-10-14 13:54:25 +02:00
DEBUG_FUNCTION_LINE ( " IOSUHAX_FSA_Open failed " ) ;
} else {
2020-10-15 20:14:00 +02:00
mount_fs ( " storage_slc_installer " , sFSAFd , nullptr , " /vol/system " ) ;
mount_fs ( " storage_mlc_installer " , sFSAFd , nullptr , " /vol/storage_mlc01 " ) ;
2020-10-14 13:54:25 +02:00
}
DEBUG_FUNCTION_LINE ( " IOSUHAX done " ) ;
}
}
void deInitIOSUHax ( ) {
if ( sIosuhaxMount ) {
unmount_fs ( " storage_slc_installer " ) ;
unmount_fs ( " storage_mlc_installer " ) ;
if ( sFSAFd > = 0 ) {
IOSUHAX_FSA_Close ( sFSAFd ) ;
}
IOSUHAX_Close ( ) ;
}
}