int main(int argc, const char* argv[]) { gfxInitDefault(); Result setCpuTimeRes = APT_SetAppCpuTimeLimit(30); if(R_FAILED(setCpuTimeRes)) { util_panic("Failed to set syscore CPU time limit: %08lX", setCpuTimeRes); return 1; } romfsInit(); cfguInit(); acInit(); ptmuInit(); httpcInit(0); amInit(); AM_InitializeExternalTitleDatabase(false); soc_buffer = memalign(0x1000, 0x100000); if(soc_buffer != NULL) { socInit(soc_buffer, 0x100000); } screen_init(); ui_init(); mainmenu_open(); while(aptMainLoop() && ui_update()); cleanup(); return 0; }
bool ctr::wifi::init() { ctr::err::parse(ctr::err::SOURCE_AC_INIT, (u32) acInit()); initialized = !ctr::err::has(); if(!initialized) { initError = ctr::err::get(); ctr::err::set(initError); } return initialized; }
int main(int argc, const char* argv[]) { gfxInitDefault(); gfxSet3D(false); if(argc > 0) { svchax_init(true); if(!__ctr_svchax || !__ctr_svchax_srv) { util_panic("Failed to acquire kernel access."); return 1; } } aptOpenSession(); Result setCpuTimeRes = APT_SetAppCpuTimeLimit(30); aptCloseSession(); if(R_FAILED(setCpuTimeRes)) { util_panic("Failed to set syscore CPU time limit: %08lX", setCpuTimeRes); return 1; } romfsInit(); cfguInit(); acInit(); ptmuInit(); httpcInit(0); amInit(); AM_InitializeExternalTitleDatabase(false); soc_buffer = memalign(0x1000, 0x100000); if(soc_buffer != NULL) { socInit(soc_buffer, 0x100000); } screen_init(); ui_init(); task_init(); mainmenu_open(); while(aptMainLoop() && ui_update()); cleanup(); return 0; }
int main(int argc, char **argv) { (void) argc, (void) argv; Result res = MAKERESULT(RL_SUCCESS, RS_SUCCESS, 0, RD_SUCCESS); gfxInitDefault(); PrintConsole top; consoleInit(GFX_TOP, &top); util_debug_init(); consoleSelect(&top); if (R_FAILED(res = acInit())) { util_presult("acInit failed", res); goto ac_failure; } u32 wifi = 0; if (R_FAILED(res = ACU_GetWifiStatus(&wifi))) { util_presult("ACU_GetWifiStatus failed", res); fprintf(stderr, "Did you enable Wifi?\n"); goto wifi_check_failure; } if (!wifi) { fprintf(stderr, "Wifi disabled.\n"); goto wifi_check_failure; } if ((sock_ctx = memalign(SOCU_BUFSZ, SOCU_ALIGN)) == NULL) { util_perror("Allocating SOC buffer"); res = MAKERESULT( RL_PERMANENT, RS_OUTOFRESOURCE, RM_SOC, RD_OUT_OF_MEMORY); goto soc_alloc_failure; } if (R_FAILED(res = socInit(sock_ctx, SOCU_BUFSZ))) { util_presult("socInit failed", res); goto soc_failure; } if (R_FAILED(res = hidInit())) { util_presult("hidInit failed", res); goto hid_failure; } if (R_FAILED(res = HIDUSER_EnableAccelerometer())) { util_presult("Failed to enable accelerometer", res); goto accel_failure; } if (R_FAILED(res = ctrollerInit())) { fprintf(stderr, "Do you have a valid IP in\n '" CFG_FILE "'?"); goto failure; } bool isHomebrew = envIsHomebrew(); printf("Press %s to exit.\n", isHomebrew ? EXIT_DESC : "HOME"); fflush(stdout); while (aptMainLoop()) { if (isHomebrew) { if (hidKeysHeld() == EXIT_KEYS) { res = RL_SUCCESS; break; } } if (ctrollerSendHIDInfo()) { util_perror("Sending HID info"); fflush(stderr); for (int i = 3; i > 0; i--) { util_debug_printf("\rRetrying in %ds... ", i); svcSleepThread(1000000000L); } util_debug_printf("\rRetrying now.\x1b[K\n"); } gspWaitForVBlank(); gfxFlushBuffers(); gfxSwapBuffers(); } puts("Exiting..."); failure: HIDUSER_DisableAccelerometer(); accel_failure: hidExit(); hid_failure: socExit(); soc_failure: free(sock_ctx); soc_alloc_failure: wifi_check_failure: acExit(); ac_failure: if (R_FAILED(res)) { util_hang(res); } gfxExit(); return res; }
int main(int argc, const char* argv[]) { /* Sadly svchax crashes too much, so only allow install mode when running as a CIA // Trigger svchax so we can install CIAs if(argc > 0) { svchax_init(true); if(!__ctr_svchax || !__ctr_svchax_srv) { bSvcHaxAvailable = false; //printf("Failed to acquire kernel access. Install mode disabled.\n"); } } */ // argc is 0 when running as a CIA, and 1 when running as a 3dsx if (argc > 0) { bSvcHaxAvailable = false; } u32 *soc_sharedmem, soc_sharedmem_size = 0x100000; gfxInitDefault(); consoleInit(GFX_TOP, NULL); httpcInit(0); soc_sharedmem = (u32 *)memalign(0x1000, soc_sharedmem_size); socInit(soc_sharedmem, soc_sharedmem_size); sslcInit(0); hidInit(); acInit(); cfguInit(); if (bSvcHaxAvailable) { amInit(); AM_InitializeExternalTitleDatabase(false); } init_menu(GFX_TOP); // Make sure all CIAngel directories exists on the SD card mkpath("/CIAngel", 0777); mkpath("/CIAngel/tmp/", 0777); loadConfig(); // Set up the reading of json check_JSON(); load_JSON_data(); menu_main(); if (bSvcHaxAvailable) { amExit(); } cfguExit(); acExit(); gfxExit(); hidExit(); httpcExit(); socExit(); sslcExit(); }
STATIC mp_obj_t mod_citrus_ac_init(void) { INIT_ONCE(_mod_citrus_ac_is_init); return mp_obj_new_int(acInit()); }
int main(int argc, char **argv) { srvInit(); aptInit(); gfxInit(); acInit(); initCfgu(); ptmInit(); hidInit(NULL); irrstInit(NULL); fsInit(); hbInit(); Handle fileHandle; u64 size; u32 bytesRead; int restore; // Set main script char path[256]; if (argc > 0){ int latest_slash = 0; int i=5; while (argv[0][i] != '\0'){ if (argv[0][i] == '/'){ latest_slash = i; } i++; } strcpy(path,&argv[0][5]); path[latest_slash-5] = 0; strcpy(start_dir,path); strcpy(cur_dir,path); // Set current dir }else{ strcpy(start_dir,"/"); strcpy(cur_dir,"/"); // Set current dir for GW Mode } while(aptMainLoop()) { restore=0; char error[256]; errMsg = runScript((const char*)index_lua, true); if (errMsg != NULL); { // Fake error to force interpreter shutdown if (strstr(errMsg, "lpp_exit_04")){ break; } strcpy(error,"Error: "); strcat(error,errMsg); strcat(error,"\n\nPress A to restart\nPress B to exit"); } while (restore==0){ gspWaitForVBlank(); RefreshScreen(); ClearScreen(0); ClearScreen(1); DebugOutput(error); hidScanInput(); if(hidKeysDown() & KEY_A){ strcpy(cur_dir,start_dir); restore=1; }else if(hidKeysDown() & KEY_B){ restore=2; } gfxFlushBuffers(); gfxSwapBuffers(); } if (restore==2){ break; } } fsExit(); irrstExit(); hidExit(); ptmExit(); hbExit(); acExit(); exitCfgu(); gfxExit(); aptExit(); srvExit(); return 0; }
int main(void) { acInit(); gfxInitDefault(); gfxSetDoubleBuffering(GFX_TOP, false); gfxSetDoubleBuffering(GFX_BOTTOM, false); if(setjmp(exitJmp)) goto exit; preRenderKeyboard(); clearScreen(); drawString(10, 10, "Initing FS..."); gfxFlushBuffers(); gfxSwapBuffers(); fsInit(); clearScreen(); drawString(10, 10, "Initing SOC..."); gfxFlushBuffers(); gfxSwapBuffers(); SOC_Initialize((u32 *)memalign(0x1000, 0x100000), 0x100000); u32 wifiStatus = 0; ACU_GetWifiStatus(NULL, &wifiStatus); if(!wifiStatus) { hang("No WiFi! Is your wireless slider on?"); } clearScreen(); drawString(10, 10, "Reading settings..."); gfxFlushBuffers(); gfxSwapBuffers(); if(!readSettings()) { hang("Could not read 3DSController.ini!"); } clearScreen(); drawString(10, 10, "Connecting to %s on port %d...", settings.IPString, settings.port); gfxFlushBuffers(); gfxSwapBuffers(); openSocket(settings.port); sendConnectionRequest(); clearScreen(); gfxFlushBuffers(); gfxSwapBuffers(); disableBacklight(); while(aptMainLoop()) { hidScanInput(); irrstScanInput(); u32 kHeld = hidKeysHeld(); circlePosition circlePad; circlePosition cStick; hidCstickRead(&cStick); hidCircleRead(&circlePad); touchPosition touch; touchRead(&touch); clearScreen(); if((kHeld & KEY_L) && (kHeld & KEY_R) && (kHeld & KEY_X)) { if(keyboardToggle) { keyboardActive = !keyboardActive; keyboardToggle = false; if(keyboardActive) enableBacklight(); } } else keyboardToggle = true; if(keyboardActive) { drawKeyboard(); if(touch.px >= 1 && touch.px <= 312 && touch.py >= 78 && touch.py <= 208) { int x = (int)((float)touch.px * 12.0f / 320.0f); int y = (int)((float)(touch.py - 78) * 12.0f / 320.0f); int width = 24; int height = 24; if(keyboardChars[x + y * 12] == ' ') { while(keyboardChars[(x - 1) + y * 12] == ' ') x--; width = (int)(5.0f * 320.0f / 12.0f) - 1; } else if(keyboardChars[x + y * 12] == '\13') { while(keyboardChars[(x - 1) + y * 12] == '\13') x--; while(keyboardChars[x + (y - 1) * 12] == '\13') y--; width = (int)(2.0f * 320.0f / 12.0f) - 1; height = (int)(3.0f * 320.0f / 12.0f) - 1; } if(keyboardChars[x + y * 12]) drawBox((int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, width, height, 31, 31, 0); } } sendKeys(kHeld, circlePad, touch, cStick); //receiveBuffer(sizeof(struct packet)); if((kHeld & KEY_START) && (kHeld & KEY_SELECT)) longjmp(exitJmp, 1); gfxFlushBuffers(); gspWaitForVBlank(); gfxSwapBuffers(); } exit: enableBacklight(); SOC_Shutdown(); svcCloseHandle(fileHandle); fsExit(); gfxExit(); acExit(); return 0; }
int main(int argc, char **argv) { srvInit(); aptInit(); gfxInitDefault(); acInit(); cfguInit(); httpcInit(); ptmuInit(); hidInit(); irrstInit(); aptOpenSession(); Result ret=APT_SetAppCpuTimeLimit(30); aptCloseSession(); fsInit(); ftp_state = false; isTopLCDOn = true; isBottomLCDOn = true; Handle fileHandle; u64 size; u32 bytesRead; int restore; // Check user build and enables kernel access if (nsInit()==0){ CIA_MODE = true; nsExit(); }else CIA_MODE = false; isNinjhax2 = false; if (!hbInit()) khaxInit(); else isNinjhax2 = true; // Select Audio System (csnd:SND preferred) if (csndInit() == 0){ csndAccess = true; csndExit(); }else csndAccess = false; // Init Audio-Device int i = 0; for (i=0;i < 32; i++){ audioChannels[i] = false; if (!isNinjhax2 && (i < 0x08)) audioChannels[i] = true; else if (csndAccess && (i < 0x08)) audioChannels[i] = true; } // Set main script char path[256]; if (argc > 0){ int latest_slash = 0; int i=5; while (argv[0][i] != '\0'){ if (argv[0][i] == '/') latest_slash = i; i++; } strcpy(path,&argv[0][5]); path[latest_slash-5] = 0; strcpy(start_dir,path); strcpy(cur_dir,path); // Set current dir strcat(path,"/index.lua"); }else{ strcpy(start_dir,"/"); strcpy(cur_dir,"/"); // Set current dir for GW Mode strcpy(path,"/index.lua"); } while(aptMainLoop()) { restore=0; char error[2048]; // Load main script FS_Path filePath=fsMakePath(PATH_ASCII, path); FS_Archive script=(FS_Archive){ARCHIVE_SDMC, (FS_Path){PATH_EMPTY, 1, (u8*)""}}; Result ret = FSUSER_OpenFileDirectly(&fileHandle, script, filePath, FS_OPEN_READ, 0x00000000); if (!ret){ FSFILE_GetSize(fileHandle, &size); buffer = (unsigned char*)(malloc((size+1) * sizeof (char))); FSFILE_Read(fileHandle, &bytesRead, 0x0, buffer, size); buffer[size]=0; FSFILE_Close(fileHandle); svcCloseHandle(fileHandle); errMsg = runScript((const char*)buffer, true); free(buffer); }else errMsg = "index.lua file not found."; // Force LCDs power on if ((!isTopLCDOn) || (!isBottomLCDOn)){ gspLcdInit(); if (!isTopLCDOn) GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_TOP); if (!isBottomLCDOn) GSPLCD_PowerOnBacklight(GSPLCD_SCREEN_BOTTOM); gspLcdExit(); isTopLCDOn = true; isBottomLCDOn = true; } // Fake error to force interpreter shutdown if (strstr(errMsg, "lpp_exit_04")) break; if (ftp_state) ftp_exit(); ftp_state = false; int connfd; while (restore==0){ gspWaitForVBlank(); RefreshScreen(); ClearScreen(0); ClearScreen(1); strcpy(error,"Error: "); strcat(error,errMsg); if (ftp_state){ u32 ip=(u32)gethostid(); char ip_address[64]; strcat(error,"\n\nPress A to restart\nPress B to exit\nPress Y to enable FTP server\n\nFTP state: ON\nIP: "); sprintf(ip_address,"%lu.%lu.%lu.%lu", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF); strcat(error,ip_address); strcat(error,"\nPort: 5000"); if(connfd<0)connfd=ftp_getConnection(); else{ int ret=ftp_frame(connfd); if(ret==1) connfd=-1; } }else strcat(error,"\n\nPress A to restart\nPress B to exit\nPress Y to enable FTP server\n\nFTP state: OFF"); DebugOutput(error); hidScanInput(); if(hidKeysDown() & KEY_A){ strcpy(cur_dir,start_dir); restore=1; }else if(hidKeysDown() & KEY_B){ restore=2; }else if(hidKeysDown() & KEY_Y){ if (!ftp_state){ u32 wifiStatus; if ((u32)ACU_GetWifiStatus(&wifiStatus) != 0xE0A09D2E){ if (wifiStatus != 0){ ftp_init(); connfd = -1; ftp_state = true; } } } } gfxFlushBuffers(); gfxSwapBuffers(); } if (ftp_state) ftp_exit(); if (isCSND){ if (csndAccess) csndExit(); else ndspExit(); isCSND = false; } if (restore==2){ break; } }