int main(void){ DisableInterrupts(); //////////////////////// perhipheral initialization //////////////////////// // init PLL to 80Mhz PLL_Init(); // init screen, use white as text color Output_Init(); Output_Color(ST7735_WHITE); //Output_Clear(); // init usb uart, generate interrupts when data received via usb USB_UART_Init(); USB_UART_Enable_Interrupt(); // init systick to generate an interrupt every 1ms (every 80000 cycles) //SysTick_Init(80000); // init and enable PWM // PWM0A_Init(40000, 20000); // PWM0A_Enable(); // init debug LEDs DEBUG_Init(); // global enable interrupts EnableInterrupts(); //////////////////////// main loop //////////////////////// while(1){ WaitForInterrupt(); /* if (updateScreen){ updateScreen = false; // screen stuff here } */ if (USB_BufferReady){ USB_BufferReady = false; //INTER_HandleBuffer(); loopcount++; dd++; // experimental test comment } } }
//--------------------------------------------------------------------------------- // main! //--------------------------------------------------------------------------------- int main(int argc, char **argv) { #ifdef PLATFORM_IS_WII try { // Setup the remote debugger if possible... DEBUG_Init(GDBSTUB_DEVICE_USB, 1); // Initialize filesystem to load from SD Card - This should change to NAND for official releases ... fatInitDefault(); for(int i = 0; i < 100; i++) { usleep(100); } //setupTrace("//Map.csv"); srand ( time(NULL) ); AUDIO_Init(NULL); ASND_Init(); ASND_Pause(0); //setupUnitTesting(); RunGameMain(); ASND_Pause(1); ASND_End(); //MemTrack::TrackListMemoryUsage(); //shutDownTrace(); } catch(int ex) { printf("\x1b[2;0H");printf("Exception Triggered, Executing Breakpoint!\n"); ASSERT(false); _break(); } #endif #ifdef PLATFORM_IS_WIN runUnitTests(); #endif return 0; }
int main(int argc, char *argv[]) { /* INITIALIZE */ #ifdef HW_RVL DI_UseCache(false); if (!__di_check_ahbprot()) { s32 preferred = IOS_GetPreferredVersion(); if (preferred == 58 || preferred == 61) IOS_ReloadIOS(preferred); else DI_LoadDVDX(true); } DI_Init(); // first #endif loadSettings(argc, argv); MenuContext *menu = new MenuContext(vmode); VIDEO_SetPostRetraceCallback (ScanPADSandReset); #ifndef WII DVD_Init(); #endif #ifdef DEBUGON //DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828 DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif control_info_init(); //Perform controller auto assignment at least once at startup. // Start up AESND (inited here because its used in SPU and CD) AESND_Init(); #ifdef HW_RVL // Initialize the network if the user has specified something in their SMB settings if(strlen(&smbShareName[0]) && strlen(&smbIpAddr[0])) { init_network_thread(); } #endif while (menu->isRunning()) {} // Shut down AESND AESND_Reset(); delete menu; return 0; }
int main(int argc, char *argv[]) { __exception_setreload(20); #ifdef GDB_DEBUG DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif InitVideo(); if(StartUpProcess::Run(argc, argv)) { Application::Instance()->init(); Application::Instance()->show(); Application::Instance()->exec(); } //! Return to the Wii system menu if not from HBC if(!IsFromHBC()) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); return 0; }
static void frontend_gx_init(void *data) { (void)data; #ifdef HW_RVL IOS_ReloadIOS(IOS_GetVersion()); L2Enhance(); #ifndef IS_SALAMANDER gx_init_mem2(); #endif #endif #ifdef USBGECKO DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif #if defined(DEBUG) && defined(IS_SALAMANDER) VIInit(); GXRModeObj *rmode = VIDEO_GetPreferredMode(NULL); void *xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ); VIConfigure(rmode); VISetNextFramebuffer(xfb); VISetBlack(FALSE); VIFlush(); VIWaitForRetrace(); VIWaitForRetrace(); #endif #ifndef DEBUG __exception_setreload(8); #endif fatInitDefault(); #ifdef HAVE_LOGGER devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_net; #elif defined(HAVE_FILE_LOGGER) && !defined(IS_SALAMANDER) devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; dotab_stdout.write_r = gx_logger_file; #endif #if defined(HW_RVL) && !defined(IS_SALAMANDER) gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple( gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface); gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage; gx_devices[GX_DEVICE_USB].name = "usb"; gx_devices[GX_DEVICE_USB].mounted = fatMountSimple( gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface); gx_device_cond_mutex = slock_new(); gx_device_cond = scond_new(); gx_device_mutex = slock_new(); gx_device_thread = sthread_create(gx_devthread, NULL); #endif }
int main(int argc, char *argv[]) { s32 res; #if defined(USE_WII_DI) && !defined(GAMECUBE) DI_Init(); #endif VIDEO_Init(); PAD_Init(); DSP_Init(); AUDIO_Init(NULL); gfx_video_init(NULL); gfx_init(); gfx_con_init(NULL); #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif printf("startup as "); if (argc > 0) printf("'%s'\n", argv[0]); else printf("<unknown>\n"); SYS_RegisterResetFunc(&resetinfo); SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); #endif if (!fatInitDefault()) { printf("fatInitDefault failed\n"); } else { // set the default path if libfat couldnt set it // this allows loading over tcp/usbgecko char cwd[MAXPATHLEN]; if (getcwd(cwd, MAXPATHLEN)) { size_t len = strlen(cwd); if (len > 2 && (cwd[len - 1] == ':' || cwd[len - 2] == ':')) { printf("chdir to default\n"); chdir("/apps/scummvm"); } } } g_system = new OSystem_Wii(); assert(g_system); #ifdef DYNAMIC_MODULES PluginManager::instance().addPluginProvider(new WiiPluginProvider()); #endif res = scummvm_main(argc, argv); g_system->quit(); printf("shutdown\n"); SYS_UnregisterResetFunc(&resetinfo); fatUnmountDefault(); if (res) show_console(res); if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } printf("reloading\n"); gfx_con_deinit(); gfx_deinit(); gfx_video_deinit(); return res; }
void XBoxStartup() { const char *logdir = NULL; myargc = -1; myargv = NULL; #else #ifdef FORCESDLMAIN FUNCNORETURN int SDL_main(int argc, char **argv) #else FUNCNORETURN int main(int argc, char **argv) #endif { const char *logdir = NULL; myargc = argc; myargv = argv; /// \todo pull out path to exe from this string #endif #ifdef HAVE_TTF #ifdef _PS3 // apparently there is a bug in SDL_PSL1GHT which needs this to be set to work around SDL_setenv("SDL_VIDEODRIVER", "psl1ght", 1); I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE|SDL_DOUBLEBUF); #elif defined(_WIN32) I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE); #else I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE); #endif #endif #ifdef _PS3 // initialise controllers. //ioPadInit(7); #endif // init Wii-specific stuff #ifdef _WII // Start network if_config(localip, netmask, gateway, TRUE); #ifdef REMOTE_DEBUGGING #if REMOTE_DEBUGGING == 0 DEBUG_Init(GDBSTUB_DEVICE_TCP, GDBSTUB_DEF_TCPPORT); // Port 2828 #elif REMOTE_DEBUGGING > 2 DEBUG_Init(GDBSTUB_DEVICE_TCP, REMOTE_DEBUGGING); // Custom Port #elif REMOTE_DEBUGGING < 0 DEBUG_Init(GDBSTUB_DEVICE_USB, GDBSTUB_DEF_CHANNEL); // Slot 1 #else DEBUG_Init(GDBSTUB_DEVICE_USB, REMOTE_DEBUGGING-1); // Custom Slot #endif #endif // Start FAT filesystem fatInitDefault(); if (getcwd(wiicwd, PATH_MAX)) I_PutEnv(va("HOME=%ssrb2wii", wiicwd)); #endif logdir = D_Home(); #ifdef LOGMESSAGES #if defined(_WIN32_WCE) || defined(GP2X) logstream = fopen(va("%s.log",argv[0]), "wt"); #elif defined (_WII) logstream = fopen(va("%s/log.txt",logdir), "wt"); #elif defined (DEFAULTDIR) if (logdir) logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt"); else #endif logstream = fopen("./log.txt", "wt"); #endif //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); #if defined (_WIN32) && !defined (_XBOX) #ifndef _WIN32_WCE { p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) #ifdef BUGTRAP && !InitBugTrap() #endif ) { LoadLibraryA("exchndl.dll"); } } #endif prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo); #ifndef _WIN32_WCE MakeCodeWritable(); #endif #endif // startup SRB2 CONS_Printf("Setting up SRB2...\n"); D_SRB2Main(); CONS_Printf("Entering main game loop...\n"); // never return D_SRB2Loop(); #ifdef BUGTRAP // This is safe even if BT didn't start. ShutdownBugTrap(); #endif // return to OS #ifndef __GNUC__ return 0; #endif }
int main(int argc, char* argv[]){ /* INITIALIZE */ #ifdef HW_RVL DI_Init(); // first #endif #ifdef DEBUGON //DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828 DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif Initialise(); // Stock OGC initialization // vmode = VIDEO_GetPreferredMode(NULL); MenuContext *menu = new MenuContext(vmode); VIDEO_SetPostRetraceCallback (ScanPADSandReset); #ifndef WII DVD_Init(); #endif // menuInit(); #ifdef DEBUGON //DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828 // DEBUG_Init(GDBSTUB_DEVICE_USB, 1); // _break(); #endif // Default Settings audioEnabled = 1; // Audio #ifdef RELEASE showFPSonScreen = 0; // Show FPS on Screen #else showFPSonScreen = 1; // Show FPS on Screen #endif printToScreen = 1; // Show DEBUG text on screen printToSD = 0; // Disable SD logging Timers.limitVIs = 0; // Sync to Audio saveEnabled = 0; // Don't save game nativeSaveDevice = 0; // SD saveStateDevice = 0; // SD autoSave = 1; // Auto Save Game creditsScrolling = 0; // Normal menu for now dynacore = 1; // Dynarec screenMode = 0; // Stretch FB horizontally padAutoAssign = PADAUTOASSIGN_AUTOMATIC; padType[0] = PADTYPE_NONE; padType[1] = PADTYPE_NONE; padType[2] = PADTYPE_NONE; padType[3] = PADTYPE_NONE; padAssign[0] = PADASSIGN_INPUT0; padAssign[1] = PADASSIGN_INPUT1; padAssign[2] = PADASSIGN_INPUT2; padAssign[3] = PADASSIGN_INPUT3; pakMode[0] = PAKMODE_MEMPAK; // memPak plugged into controller 1 pakMode[1] = PAKMODE_MEMPAK; pakMode[2] = PAKMODE_MEMPAK; pakMode[3] = PAKMODE_MEMPAK; loadButtonSlot = LOADBUTTON_DEFAULT; #ifdef GLN64_GX // glN64 specific settings glN64_useFrameBufferTextures = 0; // Disable FrameBuffer textures glN64_use2xSaiTextures = 0; // Disable 2xSai textures renderCpuFramebuffer = 0; // Disable CPU Framebuffer Rendering #endif //GLN64_GX menuActive = 1; //config stuff fileBrowser_file* configFile_file; int (*configFile_init)(fileBrowser_file*) = fileBrowser_libfat_init; #ifdef HW_RVL if(argv[0][0] == 'u') { //assume USB configFile_file = &saveDir_libfat_USB; if(configFile_init(configFile_file)) { //only if device initialized ok FILE* f = fopen( "usb:/wii64/settings.cfg", "r" ); //attempt to open file if(f) { //open ok, read it readConfig(f); fclose(f); } f = fopen( "usb:/wii64/controlG.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_GC); //write out GC controller mappings fclose(f); } #ifdef HW_RVL f = fopen( "usb:/wii64/controlC.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Classic); //write out Classic controller mappings fclose(f); } f = fopen( "usb:/wii64/controlN.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_WiimoteNunchuk); //write out WM+NC controller mappings fclose(f); } f = fopen( "usb:/wii64/controlW.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Wiimote); //write out Wiimote controller mappings fclose(f); } #endif //HW_RVL } } else /*if((argv[0][0]=='s') || (argv[0][0]=='/'))*/ #endif { //assume SD configFile_file = &saveDir_libfat_Default; if(configFile_init(configFile_file)) { //only if device initialized ok FILE* f = fopen( "sd:/wii64/settings.cfg", "r" ); //attempt to open file if(f) { //open ok, read it readConfig(f); fclose(f); } f = fopen( "sd:/wii64/controlG.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_GC); //write out GC controller mappings fclose(f); } #ifdef HW_RVL f = fopen( "sd:/wii64/controlC.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Classic); //write out Classic controller mappings fclose(f); } f = fopen( "sd:/wii64/controlN.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_WiimoteNunchuk); //write out WM+NC controller mappings fclose(f); } f = fopen( "sd:/wii64/controlW.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Wiimote); //write out Wiimote controller mappings fclose(f); } #endif //HW_RVL } } #ifdef HW_RVL // Handle options passed in through arguments int i; for(i=1; i<argc; ++i){ handleConfigPair(argv[i]); } #endif while (menu->isRunning()) {} delete menu; return 0; }
int main(int argc, char *argv[]) { s32 res; #ifdef USE_WII_DI DI_Init(); #endif VIDEO_Init(); PAD_Init(); AUDIO_Init(NULL); #ifdef DEBUG_WII_USBGECKO CON_EnableGecko(1, false); #endif #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif printf("startup as "); if (argc > 0) printf("'%s'\n", argv[0]); else printf("<unknown>\n"); SYS_SetResetCallback(reset_cb); #ifndef GAMECUBE SYS_SetPowerCallback(power_cb); #endif #ifdef USE_WII_DI // initial async mount for the browser, see wii-fs.cpp DI_Mount(); #endif if (!fatInitDefault()) { printf("fatInitDefault failed\n"); } else { // set the default path if libfat couldnt set it // this allows loading over tcp/usbgecko char cwd[MAXPATHLEN]; if (getcwd(cwd, MAXPATHLEN)) { size_t len = strlen(cwd); if (len > 2 && (cwd[len - 1] == ':' || cwd[len - 2] == ':')) { printf("chdir to default\n"); chdir("/apps/scummvm"); } } } g_system = new OSystem_Wii(); assert(g_system); res = scummvm_main(argc, argv); g_system->quit(); printf("shutdown\n"); fatUnmountDefault(); #ifdef USE_WII_DI DI_Close(); #endif if (power_btn_pressed) { printf("shutting down\n"); SYS_ResetSystem(SYS_POWEROFF, 0, 0); } printf("reloading\n"); return res; }
/**************************************************************************** Function: int main(void) Summary: main function Description: main function Precondition: None Parameters: None Return Values: int - exit code for main function Remarks: None ***************************************************************************/ int main(void) { DWORD size = 0; BOOL responseNeeded; BYTE mode = 0; BYTE wasMode = 0; BYTE pushButtonValues = 0xFF; BYTE potPercentage = 0xFF; BOOL buttonsNeedUpdate = FALSE; BOOL potNeedsUpdate = FALSE; BOOL motorON = FALSE; BOOL readyToRead = TRUE; BOOL writeInProgress = FALSE; BYTE tempValue = 0xFF; BYTE errorCode; ACCESSORY_APP_PACKET* command_packet = NULL; CLKDIV = 0; /* set for default clock operations Fcyc = 4MHz */ AD1PCFGL = 0xffff; AD1PCFGH = 0x0003; BOOL connected_to_app = FALSE; BOOL need_to_disconnect_from_app = FALSE; #if defined(__PIC32MX__) InitPIC32(); #endif #if defined(__dsPIC33EP512MU810__) || defined (__PIC24EP512GU810__) // Configure the device PLL to obtain 60 MIPS operation. The crystal // frequency is 8MHz. Divide 8MHz by 2, multiply by 60 and divide by // 2. This results in Fosc of 120MHz. The CPU clock frequency is // Fcy = Fosc/2 = 60MHz. Wait for the Primary PLL to lock and then // configure the auxilliary PLL to provide 48MHz needed for USB // Operation. PLLFBD = 38; /* M = 60 */ CLKDIVbits.PLLPOST = 0; /* N1 = 2 */ CLKDIVbits.PLLPRE = 0; /* N2 = 2 */ OSCTUN = 0; /* Initiate Clock Switch to Primary * Oscillator with PLL (NOSC= 0x3)*/ __builtin_write_OSCCONH(0x03); __builtin_write_OSCCONL(0x01); while (OSCCONbits.COSC != 0x3); // Configuring the auxiliary PLL, since the primary // oscillator provides the source clock to the auxiliary // PLL, the auxiliary oscillator is disabled. Note that // the AUX PLL is enabled. The input 8MHz clock is divided // by 2, multiplied by 24 and then divided by 2. Wait till // the AUX PLL locks. ACLKCON3 = 0x24C1; ACLKDIV3 = 0x7; ACLKCON3bits.ENAPLL = 1; while(ACLKCON3bits.APLLCK != 1); TRISBbits.TRISB5 = 0; LATBbits.LATB5 = 1; #endif USBInitialize(0); AndroidAppStart(&myDeviceInfo); responseNeeded = FALSE; mInitPOT(); InitializeTimer2For_PWM(); PwmInit(); //InitMOTOR(); DEBUG_Init(0); InitAllLEDs(); while(1) { //Keep the USB stack running USBTasks(); //If the device isn't attached yet, if(device_attached == FALSE || mode == 1) { buttonsNeedUpdate = TRUE; potNeedsUpdate = TRUE; need_to_disconnect_from_app = FALSE; connected_to_app = FALSE; size = 0; /**/ BYTE curPush = GetPushbuttons(); if ((curPush == 0x8) || (mode == 1)) { LED0_On(); mode = 1; if (wasMode == 0) { pot2LEDs(); PwmInit(); } tempValue = ReadPOT(); wasMode = 1; //If it is different than the last time we read the pot, then we need // to send it to the Android device if(tempValue != potPercentage) { potNeedsUpdate = TRUE; //setRPM(tempValue); setPWM(); } } if ((curPush == 0x4) || (mode == 0)) { mode = 0; //LED0_Off(); if (wasMode == 1) { SetLEDs(0b00000000); wasMode = 0; setRPM(0); } //Reset the accessory state variables InitAllLEDs(); //Continue to the top of the while loop to start the check over again. continue; } /* //Reset the accessory state variables InitAllLEDs(); //Continue to the top of the while loop to start the check over again. continue; }*/ //} } //If the accessory is ready, then this is where we run all of the demo code if(readyToRead == TRUE && mode == 0) { errorCode = AndroidAppRead(device_handle, (BYTE*)&read_buffer, (DWORD)sizeof(read_buffer)); //If the device is attached, then lets wait for a command from the application if( errorCode != USB_SUCCESS) { //Error DEBUG_PrintString("Error trying to start read"); } else { readyToRead = FALSE; } } size = 0; if(AndroidAppIsReadComplete(device_handle, &errorCode, &size) == TRUE) { //We've received a command over the USB from the Android device. if(errorCode == USB_SUCCESS) { //Maybe process the data here. Maybe process it somewhere else. command_packet = (ACCESSORY_APP_PACKET*)&read_buffer[0]; } else { //Error DEBUG_PrintString("Error trying to complete read request"); } } while(size > 0) { if(connected_to_app == FALSE) { if(command_packet->command == COMMAND_APP_CONNECT) { connected_to_app = TRUE; need_to_disconnect_from_app = FALSE; } } else { switch(command_packet->command) { case COMMAND_SET_LEDS: SetLEDs(command_packet->data); break; case COMMAND_APP_DISCONNECT: need_to_disconnect_from_app = TRUE; break; case COMMAND_SET_PWM: setRPM(command_packet->data); break; default: //Error, unknown command DEBUG_PrintString("Error: unknown command received"); break; } } //All commands in this example are two bytes, so remove that from the queue size -= 2; //And move the pointer to the next packet (this works because // all command packets are 2 bytes. If variable packet size // then need to handle moving the pointer by the size of the // command type that arrived. command_packet++; if(need_to_disconnect_from_app == TRUE) { break; } } if(size == 0) { readyToRead = TRUE; } //Get the current pushbutton settings tempValue = GetPushbuttons(); //If the current button settings are different than the last time // we read the button values, then we need to send an update to the // attached Android device if(tempValue != pushButtonValues) { buttonsNeedUpdate = TRUE; pushButtonValues = tempValue; } //Get the current potentiometer setting tempValue = ReadPOT(); //If it is different than the last time we read the pot, then we need // to send it to the Android device if(tempValue != potPercentage) { potNeedsUpdate = TRUE; potPercentage = tempValue; } //If there is a write already in progress, we need to check its status if( writeInProgress == TRUE ) { if(AndroidAppIsWriteComplete(device_handle, &errorCode, &size) == TRUE) { writeInProgress = FALSE; if(need_to_disconnect_from_app == TRUE) { connected_to_app = FALSE; need_to_disconnect_from_app = FALSE; } if(errorCode != USB_SUCCESS) { //Error DEBUG_PrintString("Error trying to complete write"); } } } if((need_to_disconnect_from_app == TRUE) && (writeInProgress == FALSE)) { outgoing_packet.command = COMMAND_APP_DISCONNECT; outgoing_packet.data = 0; writeInProgress = TRUE; errorCode = AndroidAppWrite(device_handle,(BYTE*)&outgoing_packet, 2); if( errorCode != USB_SUCCESS ) { DEBUG_PrintString("Error trying to send button update"); } } if(connected_to_app == FALSE) { //If the app hasn't told us to start sending data, let's not do anything else. continue; } //If we need up update the button status on the Android device and we aren't // already busy in a write, then we can send the new button data. if((buttonsNeedUpdate == TRUE) && (writeInProgress == FALSE)) { outgoing_packet.command = COMMAND_UPDATE_PUSHBUTTONS; outgoing_packet.data = pushButtonValues; errorCode = AndroidAppWrite(device_handle,(BYTE*)&outgoing_packet, 2); if( errorCode != USB_SUCCESS ) { DEBUG_PrintString("Error trying to send button update"); } buttonsNeedUpdate = FALSE; writeInProgress = TRUE; } //If we need up update the pot status on the Android device and we aren't // already busy in a write, then we can send the new pot data. if((potNeedsUpdate == TRUE) && (writeInProgress == FALSE)) { outgoing_packet.command = COMMAND_UPDATE_POT; outgoing_packet.data = potPercentage; errorCode = AndroidAppWrite(device_handle,(BYTE*)&outgoing_packet, 2); if( errorCode != USB_SUCCESS ) { DEBUG_PrintString("Error trying to send pot update"); } potNeedsUpdate = FALSE; writeInProgress = TRUE; } } //while(1) main loop }
int main(int argc, char* argv[]){ /* INITIALIZE */ #ifdef DEBUGON //DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828 DEBUG_Init(GDBSTUB_DEVICE_USB, 1); _break(); #endif Initialise(); // Stock OGC initialization // vmode = VIDEO_GetPreferredMode(NULL); #ifndef WII DVD_Init(); #endif // menuInit(); #ifdef DEBUGON //DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828 // DEBUG_Init(GDBSTUB_DEVICE_USB, 1); // _break(); #endif // Default Settings audioEnabled = 1; // Audio scalePitch = 1; #ifdef RELEASE showFPSonScreen = 0; // Show FPS on Screen #else showFPSonScreen = 1; // Show FPS on Screen #endif printToScreen = 1; // Show DEBUG text on screen printToSD = 0; // Disable SD logging Timers.limitVIs = 1; autoSave = 1; // Auto Save Game dynacore = 1; // Dynarec #ifndef HW_RVL screenMode = 0; // Stretch FB horizontally #else screenMode = CONF_GetAspectRatio() == CONF_ASPECT_16_9 ? SCREENMODE_16x9_PILLARBOX : SCREENMODE_4x3; #endif videoMode = VIDEOMODE_AUTO; trapFilter = TRAPFILTER_DISABLE; padAutoAssign = PADAUTOASSIGN_AUTOMATIC; padType[0] = PADTYPE_NONE; padType[1] = PADTYPE_NONE; padType[2] = PADTYPE_NONE; padType[3] = PADTYPE_NONE; padAssign[0] = PADASSIGN_INPUT0; padAssign[1] = PADASSIGN_INPUT1; padAssign[2] = PADASSIGN_INPUT2; padAssign[3] = PADASSIGN_INPUT3; pakMode[0] = PAKMODE_MEMPAK; // memPak plugged into controller 1 pakMode[1] = PAKMODE_MEMPAK; pakMode[2] = PAKMODE_MEMPAK; pakMode[3] = PAKMODE_MEMPAK; loadButtonSlot = LOADBUTTON_DEFAULT; #ifdef GLN64_GX // glN64 specific settings glN64_useFrameBufferTextures = 0; // Disable FrameBuffer textures glN64_use2xSaiTextures = 0; // Disable 2xSai textures renderCpuFramebuffer = 0; // Disable CPU Framebuffer Rendering #endif //GLN64_GX menuActive = 1; //config stuff fileBrowser_file* configFile_file; int (*configFile_init)(fileBrowser_file*) = fileBrowser_libfat_init; #ifdef HW_RVL if(argc > 0 && argv[0][0] == 'u') { //assume USB nativeSaveDevice = NATIVESAVEDEVICE_USB; saveStateDevice = SAVESTATEDEVICE_USB; configFile_file = &saveDir_libfat_USB; if(configFile_init(configFile_file)) { //only if device initialized ok FILE* f = fopen( "usb:/not64/settings.cfg", "r" ); //attempt to open file if(f) { //open ok, read it readConfig(f); fclose(f); } f = fopen( "usb:/not64/controlG.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_GC); //write out GC controller mappings fclose(f); } #ifdef HW_RVL f = fopen( "usb:/not64/controlC.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Classic); //write out Classic controller mappings fclose(f); } f = fopen( "usb:/not64/controlN.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_WiimoteNunchuk); //write out WM+NC controller mappings fclose(f); } f = fopen( "usb:/not64/controlW.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Wiimote); //write out Wiimote controller mappings fclose(f); } #endif //HW_RVL } } else /*if((argv[0][0]=='s') || (argv[0][0]=='/'))*/ #endif { //assume SD nativeSaveDevice = NATIVESAVEDEVICE_SD; saveStateDevice = SAVESTATEDEVICE_SD; configFile_file = &saveDir_libfat_Default; if(configFile_init(configFile_file)) { //only if device initialized ok FILE* f = fopen( "sd:/not64/settings.cfg", "r" ); //attempt to open file if(f) { //open ok, read it readConfig(f); fclose(f); } f = fopen( "sd:/not64/controlG.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_GC); //write out GC controller mappings fclose(f); } #ifdef HW_RVL f = fopen( "sd:/not64/controlC.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Classic); //write out Classic controller mappings fclose(f); } f = fopen( "sd:/not64/controlN.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_WiimoteNunchuk); //write out WM+NC controller mappings fclose(f); } f = fopen( "sd:/not64/controlW.cfg", "r" ); //attempt to open file if(f) { load_configurations(f, &controller_Wiimote); //write out Wiimote controller mappings fclose(f); } #endif //HW_RVL } } // Handle options passed in through arguments int i; for(i=1; i<argc; ++i){ handleConfigPair(argv[i]); } MenuContext *menu = new MenuContext(vmode); // Initialize the network if the user has specified something in their SMB settings if(strlen(&smbShareName[0]) && strlen(&smbIpAddr[0])) { init_network_thread(); } while (menu->isRunning()) {} delete menu; return 0; }