int main() { xenos_init(VIDEO_MODE_VGA_640x480); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); fatInitDefault(); xenon_caps_init("uda:/video.avi"); xenon_caps_start(); int i = 20; while(i>0) { printf("I'm happy and you ?\n"); delay(1); printf("Kick Ass !!\n"); delay(1); printf("Real Time encoding !!!\n"); i--; } xenon_caps_end(); return 0; }
static void xenon360_input_poll(void *data) { (void)data; for (unsigned i = 0; i < MAX_PADS; i++) { struct controller_data_s pad; usb_do_poll(); get_controller_data(&pad, i); uint64_t *cur_state = &state[i]; *cur_state |= pad.b ? RETRO_DEVICE_ID_JOYPAD_A : 0; *cur_state |= pad.a ? RETRO_DEVICE_ID_JOYPAD_B : 0; *cur_state |= pad.y ? RETRO_DEVICE_ID_JOYPAD_X : 0; *cur_state |= pad.x ? RETRO_DEVICE_ID_JOYPAD_Y : 0; *cur_state |= pad.left ? RETRO_DEVICE_ID_JOYPAD_LEFT : 0; *cur_state |= pad.right ? RETRO_DEVICE_ID_JOYPAD_RIGHT : 0; *cur_state |= pad.up ? RETRO_DEVICE_ID_JOYPAD_UP : 0; *cur_state |= pad.down ? RETRO_DEVICE_ID_JOYPAD_DOWN : 0; *cur_state |= pad.start ? RETRO_DEVICE_ID_JOYPAD_START : 0; *cur_state |= pad.back ? RETRO_DEVICE_ID_JOYPAD_SELECT : 0; *cur_state |= pad.lt ? RETRO_DEVICE_ID_JOYPAD_L : 0; *cur_state |= pad.rt ? RETRO_DEVICE_ID_JOYPAD_R : 0; } }
int main(void) { xenos_init(VIDEO_MODE_AUTO); console_set_colors(0xD8444E00,0xFF96A300); console_init(); usb_init(); usb_do_poll(); printf("SFCX Init.\n"); flashconfig = sfcx_readreg(SFCX_CONFIG); sfcx_init(); if (sfc.initialized != SFCX_INITIALIZED) { printf(" ! Flashconfig: 0x%08X\n", flashconfig); printf(" ! sfcx initialization failure\n"); printf(" ! nand related features will not be available\n"); waitforexit(); } printf("Xenon_config_init.\n"); xenon_config_init(); prompt(MAIN_MENU); return 0; }
static void XenonInputUpdate() { for (int i = 0; i < MAX_INPUTS; i++) { old_ctrl[i] = ctrl[i]; usb_do_poll(); get_controller_data(&ctrl[i], i); } // update wpad for (int i = 0; i < MAX_INPUTS; i++) { wpad_xenon[i].btns_d = WPAD_ButtonsDown(i); wpad_xenon[i].btns_u = WPAD_ButtonsUp(i); wpad_xenon[i].btns_h = WPAD_ButtonsHeld(i); //float irx = (float)((float)PAD_StickX(i)/128.f); //float iry = (float)(-(float)PAD_StickY(i)/128.f)-0.5f; // float iry = 0.5f-((float)PAD_StickY(i)/128.f); float iry = 0.5f + ((float) -PAD_StickY(i) / 128.f); float irx = 0.5f + ((float) PAD_StickX(i) / 128.f); irx *= screenwidth; iry *= screenheight; wpad_xenon[i].ir.x = irx; wpad_xenon[i].ir.y = iry; wpad_xenon[i].ir.valid = 0; } }
int main() { mainInit(); console_clrscr(); printf( "Welcome to the beginning...\n\n" "A graphical interface coming\nsomewhere down the line.\n"); struct controller_data_s c; while(1) { if (get_controller_data(&c, 0)) { if(c.a) printf("A\n"); if(c.b) printf("B\n"); if(c.x) printf("X\n"); if(c.y) printf("Y\n"); if(c.logo) printf("Logo/Guide\n"); if(c.lb) printf("Left Bumper\n"); if(c.rb) printf("Right Bumper\n"); if(c.up) printf("Up\n"); if(c.down) printf("Down\n"); if(c.left) printf("Left\n"); if(c.right) printf("Right\n"); if(c.lt) printf("Left Tigger\n"); if(c.rt) printf("Right Trigger\n"); if(c.start) printf("Start\n"); if(c.back) printf("Back/Select\n"); if(c.s1_x) printf("Stick 1 X: %d\n",c.s1_x); } usb_do_poll(); } return 0; }
void update_input() { usb_do_poll(); unsigned char pad[4]; memset(pad, 0, sizeof (char) * 4); for (int dwUser = 0; dwUser < 2; dwUser++) { get_controller_data(&Gamepads[dwUser], dwUser); if (!FCEUI_EmulationPaused()) { if (Gamepads[dwUser].s1_y > 13107) pad[dwUser] |= JOY_B; if (Gamepads[dwUser].s1_y < -13107) pad[dwUser] |= JOY_UP; if (Gamepads[dwUser].s1_x > 13107) pad[dwUser] |= JOY_RIGHT; if (Gamepads[dwUser].s1_x < -13107) pad[dwUser] |= JOY_LEFT; if (Gamepads[dwUser].up) pad[dwUser] |= JOY_UP; if (Gamepads[dwUser].down) pad[dwUser] |= JOY_DOWN; if (Gamepads[dwUser].left) pad[dwUser] |= JOY_LEFT; if (Gamepads[dwUser].right) pad[dwUser] |= JOY_RIGHT; if (Gamepads[dwUser].a) pad[dwUser] |= JOY_A; if (Gamepads[dwUser].b) pad[dwUser] |= JOY_B; if (Gamepads[dwUser].x) pad[dwUser] |= JOY_A; if (Gamepads[dwUser].y) pad[dwUser] |= JOY_B; if (Gamepads[dwUser].start) pad[dwUser] |= JOY_START; if (Gamepads[dwUser].select) pad[dwUser] |= JOY_SELECT; } } //------------------------------------------------------------------------------------- // Set input from all the gamepads //------------------------------------------------------------------------------------- powerpadbuf = pad[0] | pad[1] << 8; //| pad[2] << 16 | pad[3] << 24;; }
void Hw::SystemPoll(){ if(init_flags & INIT_USB){ usb_do_poll(); } if(init_flags & INIT_NETWORK){ network_poll(); } }
static void xenon360_input_poll(void *data) { (void)data; for (unsigned i = 0; i < 4; i++) { usb_do_poll(); get_controller_data(&pad[i], i); } }
int main(){ mainInit(); usb_init(); fatInitDefault (); usb_do_poll(); debug("This will be logged to USB."); printf("This will be output to the console and UART."); }
BOOL Browser::Warning(const char *message) { display_warning = 1; unsigned int color = WARNING_COLOR; memset(&old_ctrl, 0, sizeof (struct controller_data_s)); memset(&ctrl, 0, sizeof (struct controller_data_s)); while (display_warning == 1) { // Begin to draw Begin(); // Draw bg RenderBg(); Draw::DrawColoredRect(-0.5f, -0.5f, 1.0f, 1.0f, color); m_font.Begin(); // need to fix that .. //m_font.DrawTextF("Error ?", SelectedColor, -0.55f, 0.3f); m_font.DrawTextF(message, SelectedColor, -0.55f, -0.5f); m_font.DrawTextF("Press X to continue", SelectedColor, -0.55f, 0.3f); m_font.DrawTextF("Press B to cancel", SelectedColor, 0.00f, 0.3f); m_font.End(); // Draw all text + form Render(); // Draw is finished End(); // Update code ... { usb_do_poll(); get_controller_data(&ctrl, 0); if (ctrl.b & !old_ctrl.b) { display_warning = 0; return FALSE; } if (ctrl.x & !old_ctrl.x) { display_warning = 0; return TRUE; } // Save the old value old_ctrl = ctrl; memset(&ctrl, 0, sizeof (struct controller_data_s)); } } return FALSE; }
void IN_Frame (void) { usb_do_poll(); // get ctrl data get_controller_data(&ctrl, 0); IN_JoyMove( ); // save for next loop old_ctrl = ctrl; }
BOOL MyConsole::Warning(const char *message) { unsigned int color = 0xFF6f641a; old_ctrl = ctrl; memset(&ctrl, 0, sizeof (struct controller_data_s)); old_ctrl1 = ctrl1; memset(&ctrl1, 0, sizeof (struct controller_data_s)); while (1) { // Begin to draw Begin(); Draw::DrawColoredRect(-0.5f, -0.5f, 1.0f, 1.0f, color); m_font.Begin(); m_font.DrawTextF(message, SelectedColor, -0.55f, -0.5f); m_font.DrawTextF("Press X to continue", SelectedColor, -0.55f, 0.3f); m_font.DrawTextF("Press B to cancel", SelectedColor, 0.00f, 0.3f); m_font.End(); // Draw all text + form Render(); // Draw is finished End(); // Update code ... usb_do_poll(); get_controller_data(&ctrl, 0); if (ctrl.b & !old_ctrl.b) { return FALSE; } if (ctrl.x & !old_ctrl.x) { return TRUE; } get_controller_data(&ctrl1, 1); if (ctrl1.b & !old_ctrl1.b) { return FALSE; } if (ctrl1.x & !old_ctrl1.x) { return TRUE; } // Save the old value old_ctrl = ctrl; memset(&ctrl, 0, sizeof (struct controller_data_s)); old_ctrl1 = ctrl1; memset(&ctrl1, 0, sizeof (struct controller_data_s)); } return FALSE; }
void mainInit() { //init xenos_init(VIDEO_MODE_AUTO); console_set_colors(CONSOLE_COLOR_BLUE,CONSOLE_COLOR_YELLOW); console_init(); usb_init(); usb_do_poll(); xenon_make_it_faster(XENON_SPEED_FULL); }
void main (int argc, char **argv) { // Init libxenon xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); #if 0 threading_init(); network_init_sys(); #endif usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); fatInitDefault(); #ifdef CAPS fatMountSimple("udb", &usb2mass_ops_1); printf("CAPTURE BUILD !!!\n"); #endif // Quake II char * newargv[] = { "uda:/q3.elf", //"+set", "game", "baseq2", "+set", "cddir", "uda:/baseq2/" "+set", "basedir" , "uda:/", "+set", "cddir", "uda:/baseq2/", "+set", "cl_maxfps", "400" }; int newargc = sizeof (newargv) / sizeof (char *); Qcommon_Init (newargc, newargv); console_close(); int time, oldtime, newtime; oldtime = Sys_Milliseconds(); while (1) { do { newtime = Sys_Milliseconds (); time = newtime - oldtime; } while (time < 1); Qcommon_Frame (time); oldtime = newtime; } }
static void frontend_xenon_init(void *data) { (void)data; xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); usb_init(); usb_do_poll(); xenon_ata_init(); #if 0 dvd_init(); #endif }
int main() { #ifdef LIBXENON usb_init(); usb_do_poll(); xenon_ata_init(); dvd_init(); xenon_smc_start_bootanim(); #endif cApp.Run(); while (1) { } return 0; }
int main(int argc, char *argv[]) { xenon_make_it_faster(XENON_SPEED_FULL); InitVideo(); usb_init(); usb_do_poll(); xenon_ata_init(); xenon_sound_init(); SetupPads(); mount_all_devices(); // Set defaults DefaultSettings(); // Initialize font system InitFreeType((u8*)font_ttf, font_ttf_size); browserList = (BROWSERENTRY *)malloc(sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE); while (1) // main loop { MainMenu(MENU_GAMESELECTION); EmuLaunch(); if(EmuRunning) MainMenu(MENU_GAME); else MainMenu(MENU_GAMESELECTION); if(EmuRunning) EmuResume(); else EmuLaunch(); if(EmuConfigRequested) { EmuConfigRequested = 0; break; } if(EmuResetRequested) { EmuResetRequested = 0; EmuReset(); } } return 0; }
void waitforexit(void) { printf("Press A to get back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } }
void Browser::Alert(const char *message) { display_alert = 1; unsigned int color = ALERT_COLOR; memset(&old_ctrl, 0, sizeof (struct controller_data_s)); memset(&ctrl, 0, sizeof (struct controller_data_s)); while (display_alert == 1) { // Begin to draw Begin(); RenderBg(); Draw::DrawColoredRect(-0.5f, -0.5f, 1.0f, 1.0f, color); m_font.Begin(); // need to fix that .. //m_font.DrawTextF("Error ?", SelectedColor, -0.55f, 0.3f); m_font.DrawTextF(message, SelectedColor, -0.55f, -0.5f); m_font.DrawTextF("Press B to continue", SelectedColor, -0.3f, 0.3f); m_font.End(); // Draw all text + form Render(); // Draw is finished End(); // Update code ... { usb_do_poll(); get_controller_data(&ctrl, 0); if (ctrl.b & !old_ctrl.b) { display_alert = 0; return; } // Save the old value old_ctrl = ctrl; memset(&ctrl, 0, sizeof (struct controller_data_s)); } } }
void Hw::SystemInit(int flags){ if(init_flags==0){ xenon_make_it_faster(XENON_SPEED_FULL); if(flags & INIT_SOUND){ } if(flags & INIT_VIDEO){ } if(flags & INIT_USB){ usb_init(); usb_do_poll(); } if(flags & INIT_NETWORK){ network_init(); } if(flags & INIT_ATA){ xenon_ata_init(); } if(flags & INIT_ATAPI){ xenon_atapi_init(); } if(flags & INIT_FILESYSTEM){ mount_all_devices(); findDevices(); } if(flags & INIT_SFCX){ sfcx_init(); } init_flags = flags; } }
void Sys_PlatformInit( void ) { // Init libxenon xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); http_output_start(); #if 0 threading_init(); network_init_sys(); #endif usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); // fatInitDefault(); // XTAFMount(); // fatInit(16, 1); fatMount ("uda", &usb2mass_ops_0, 0, 256, 64); ListDevices(); Sys_SetEnv("HOME", "uda:/"); console_close(); }
int main(int argc, char **argv) { #ifdef LIBXENON xenos_init(VIDEO_MODE_AUTO); Hw::SystemInit(INIT_USB|INIT_ATA|INIT_ATAPI|INIT_FILESYSTEM); usb_do_poll(); xenon_smc_start_bootanim(); #endif if(argc != 0 && argv[0]) { char *tmp = argv_GetFilepath(argv[0]); strcpy(rootpath,tmp); } else { strcpy(rootpath,"uda0:"); } cApp.Run(); while (1) { } return 0; }
void HardwareManager::InitializeXbox() { // Will only be instantiated once for the lifetime of the application static int initialized = 0; // Don't do anything if we've already initialized if(initialized == 1) return; // Make sure all CPU cores are at full speed xenon_make_it_faster(XENON_SPEED_FULL); // Initialize USB and scan for devices usb_init(); usb_do_poll(); // Initialize HDD's xenon_ata_init(); // Initialize DVD dvd_init(); // Make sure this only happens once initialized = 1; }
void getKeys(int Control, BUTTONS *Keys) { static struct controller_data_s cdata[4],*c; BUTTONS b; usb_do_poll(); get_controller_data(&cdata[Control], Control); c=&cdata[Control]; b.START_BUTTON=c->start; b.A_BUTTON=c->a; b.B_BUTTON=c->b; b.Z_TRIG=c->x || c->y || (c->rt>TRIGGER_THRESHOLD) || (c->lt>TRIGGER_THRESHOLD); b.L_TRIG=c->lb; b.R_TRIG=c->rb; switch(pad_mode) { case PADMODE_SDC: b.X_AXIS=handleStickDeadZone(c->s1_x)/256; b.Y_AXIS=handleStickDeadZone(c->s1_y)/256; b.U_DPAD=c->up; b.D_DPAD=c->down; b.L_DPAD=c->left; b.R_DPAD=c->right; b.U_CBUTTON=c->s2_y>STICK_THRESHOLD; b.D_CBUTTON=c->s2_y<-STICK_THRESHOLD; b.L_CBUTTON=c->s2_x<-STICK_THRESHOLD; b.R_CBUTTON=c->s2_x>STICK_THRESHOLD; break; case PADMODE_SCD: b.X_AXIS=handleStickDeadZone(c->s1_x)/256; b.Y_AXIS=handleStickDeadZone(c->s1_y)/256; b.U_CBUTTON=c->up; b.D_CBUTTON=c->down; b.L_CBUTTON=c->left; b.R_CBUTTON=c->right; b.U_DPAD=c->s2_y>STICK_THRESHOLD; b.D_DPAD=c->s2_y<-STICK_THRESHOLD; b.L_DPAD=c->s2_x<-STICK_THRESHOLD; b.R_DPAD=c->s2_x>STICK_THRESHOLD; break; case PADMODE_DSC: b.U_DPAD=c->s1_y>STICK_THRESHOLD; b.D_DPAD=c->s1_y<-STICK_THRESHOLD; b.L_DPAD=c->s1_x<-STICK_THRESHOLD; b.R_DPAD=c->s1_x>STICK_THRESHOLD; b.X_AXIS=(c->left?-128:0) + (c->right?127:0); b.Y_AXIS=(c->up?127:0) + (c->down?-128:0); b.U_CBUTTON=c->s2_y>STICK_THRESHOLD; b.D_CBUTTON=c->s2_y<-STICK_THRESHOLD; b.L_CBUTTON=c->s2_x<-STICK_THRESHOLD; b.R_CBUTTON=c->s2_x>STICK_THRESHOLD; break; case PADMODE_DCS: b.U_DPAD=c->s1_y>STICK_THRESHOLD; b.D_DPAD=c->s1_y<-STICK_THRESHOLD; b.L_DPAD=c->s1_x<-STICK_THRESHOLD; b.R_DPAD=c->s1_x>STICK_THRESHOLD; b.U_CBUTTON=c->up; b.D_CBUTTON=c->down; b.L_CBUTTON=c->left; b.R_CBUTTON=c->right; b.X_AXIS=handleStickDeadZone(c->s2_x)/256; b.Y_AXIS=handleStickDeadZone(c->s2_y)/256; break; case PADMODE_CDS: b.U_CBUTTON=c->s1_y>STICK_THRESHOLD; b.D_CBUTTON=c->s1_y<-STICK_THRESHOLD; b.L_CBUTTON=c->s1_x<-STICK_THRESHOLD; b.R_CBUTTON=c->s1_x>STICK_THRESHOLD; b.U_DPAD=c->up; b.D_DPAD=c->down; b.L_DPAD=c->left; b.R_DPAD=c->right; b.X_AXIS=handleStickDeadZone(c->s2_x)/256; b.Y_AXIS=handleStickDeadZone(c->s2_y)/256; break; case PADMODE_CSD: b.U_CBUTTON=c->s1_y>STICK_THRESHOLD; b.D_CBUTTON=c->s1_y<-STICK_THRESHOLD; b.L_CBUTTON=c->s1_x<-STICK_THRESHOLD; b.R_CBUTTON=c->s1_x>STICK_THRESHOLD; b.X_AXIS=(c->left?-128:0) + (c->right?127:0); b.Y_AXIS=(c->up?127:0) + (c->down?-128:0); b.U_DPAD=c->s2_y>STICK_THRESHOLD; b.D_DPAD=c->s2_y<-STICK_THRESHOLD; b.L_DPAD=c->s2_x<-STICK_THRESHOLD; b.R_DPAD=c->s2_x>STICK_THRESHOLD; break; } Keys->Value = b.Value; }
void prompt(int menu) { console_clrscr(); switch (menu) { case MAIN_MENU:{ printf("\n LibXenon NANDFlasher v%s \n",version); printf(" **************************\n\n"); printf("Flashconfig 0x%08X\n",flashconfig); printf("NAND-Size %i MB\n\n",sfc.size_mb); printf("Press A to save NAND to file on USB.\n"); printf("Press X to write file from USB to NAND.\n"); printf("Press B to analyze NAND.\n"); printf("Press Y to update XeLL.\n"); printf("Press START for DMA test.\n"); printf("Press GUIDE to return to XeLL.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) prompt(DUMP_SUBMENU); if((button.x)&&(!controller.x)) writeNand("uda:/updflash.bin"); if((button.b)&&(!controller.b)) prompt(ANALYZE_SUBMENU); if((button.y)&&(!controller.y)) updateXeLL("uda:/updxell.bin"); if((button.start)&&(!controller.start)) dmatest(); if((button.logo)&&(!controller.logo)) break; controller=button; } usb_do_poll(); } } case DUMP_SUBMENU:{ int nand_sz = sfc.size_bytes; if (nand_sz != NAND_SIZE_256MB && nand_sz != NAND_SIZE_512MB) readNand("uda:/flashdmp.bin", FULL_DUMP); printf("\n DUMP MENU \n"); printf(" **************************\n\n"); printf("Press A to dump whole NAND.\n"); printf("Press B to dump only flash-partition.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) readNand("uda:/flashdmp.bin", FULL_DUMP); if((button.b)&&(!controller.b)) readNand("uda:/flashdmp.bin", BB64MB_ONLY); if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } case ANALYZE_SUBMENU:{ printf("\n ANALYZE MENU \n"); printf(" **************************\n\n"); printf("Press A to analyze physical NAND.\n"); printf("Press B to analyze file updflash.bin.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) prompt(ANALYZE_PHYS_SUBMENU); if((button.b)&&(!controller.b)) prompt(ANALYZE_FILE_SUBMENU); if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } case ANALYZE_PHYS_SUBMENU:{ int nand_sz = sfc.size_bytes; int blocks = sfc.size_blocks; if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB) blocks = 0x200; printf("\n ANALYZE NAND \n"); printf(" **************************\n\n"); printf("Press A to scan for Bad Blocks.\n"); printf("Press B to scan for Bad Blocks and EDC errors.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)){ analyzeNand(0,blocks,0); printReport(BBMnand); waitforexit(); } if((button.b)&&(!controller.b)){ analyzeNand(0,blocks,1); printReport(BBMnand); waitforexit(); } if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } case ANALYZE_FILE_SUBMENU:{ int nand_sz = sfc.size_bytes; int blocks = sfc.size_blocks; if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB) blocks = 0x200; printf("\n ANALYZE FILE \n"); printf(" **************************\n\n"); printf("Press A to scan for Bad Blocks.\n"); printf("Press B to scan for Bad Blocks and EDC errors.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)){ analyzeFile("uda:/updflash.bin",0,blocks, 0); printReport(BBMfile); waitforexit(); } if((button.b)&&(!controller.b)){ analyzeFile("uda:/updflash.bin",0,blocks, 1); printReport(BBMfile); waitforexit(); } if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } } return 0; }
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) { static int prev_buttons[4] = {0}; static Sint16 nX = 0, nY = 0; static Sint16 nXR = 0, nYR = 0; unsigned long b=0; int hat=0, changed=0; /* Theres a bug with the current libXenon controller implementation that sometimes causes analog values to 'stick' and retain the same x/y values after release back to origin. */ usb_do_poll(); get_controller_data(&joystick->hwdata->curpad, joystick->index); if (joystick->hwdata->curpad.a) { if (!joystick->buttons[0]) SDL_PrivateJoystickButton(joystick, (Uint8)0, SDL_PRESSED); } else { if (joystick->buttons[0]) SDL_PrivateJoystickButton(joystick, (Uint8)0, SDL_RELEASED); } if (joystick->hwdata->curpad.b) { if (!joystick->buttons[1]) SDL_PrivateJoystickButton(joystick, (Uint8)1, SDL_PRESSED); } else { if (joystick->buttons[1]) SDL_PrivateJoystickButton(joystick, (Uint8)1, SDL_RELEASED); } if (joystick->hwdata->curpad.x) { if (!joystick->buttons[2]) SDL_PrivateJoystickButton(joystick, (Uint8)2, SDL_PRESSED); } else { if (joystick->buttons[2]) SDL_PrivateJoystickButton(joystick, (Uint8)2, SDL_RELEASED); } if (joystick->hwdata->curpad.y) { if (!joystick->buttons[3]) SDL_PrivateJoystickButton(joystick, (Uint8)3, SDL_PRESSED); } else { if (joystick->buttons[3]) SDL_PrivateJoystickButton(joystick, (Uint8)3, SDL_RELEASED); } if (joystick->hwdata->curpad.lb) { if (!joystick->buttons[4]) SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_PRESSED); } else { if (joystick->buttons[4]) SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_RELEASED); } if (joystick->hwdata->curpad.rb) { if (!joystick->buttons[5]) SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_PRESSED); } else { if (joystick->buttons[5]) SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_RELEASED); } if (joystick->hwdata->curpad.s1_z) { if (!joystick->buttons[6]) SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_PRESSED); } else { if (joystick->buttons[6]) SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_RELEASED); } if (joystick->hwdata->curpad.s2_z) { if (!joystick->buttons[7]) SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_PRESSED); } else { if (joystick->buttons[7]) SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_RELEASED); } if (joystick->hwdata->curpad.start) { if (!joystick->buttons[8]) SDL_PrivateJoystickButton(joystick, (Uint8)8, SDL_PRESSED); } else { if (joystick->buttons[8]) SDL_PrivateJoystickButton(joystick, (Uint8)8, SDL_RELEASED); } if (joystick->hwdata->curpad.back) { if (!joystick->buttons[9]) SDL_PrivateJoystickButton(joystick, (Uint8)9, SDL_PRESSED); } else { if (joystick->buttons[9]) SDL_PrivateJoystickButton(joystick, (Uint8)9, SDL_RELEASED); } if (joystick->hwdata->curpad.lt > 200) { if (!joystick->buttons[10]) SDL_PrivateJoystickButton(joystick, (Uint8)10, SDL_PRESSED); } else { if (joystick->buttons[10]) SDL_PrivateJoystickButton(joystick, (Uint8)10, SDL_RELEASED); } if (joystick->hwdata->curpad.rt > 200) { if (!joystick->buttons[11]) SDL_PrivateJoystickButton(joystick, (Uint8)11, SDL_PRESSED); } else { if (joystick->buttons[11]) SDL_PrivateJoystickButton(joystick, (Uint8)11, SDL_RELEASED); } // do the HATS baby hat = SDL_HAT_CENTERED; if (joystick->hwdata->curpad.down) hat|=SDL_HAT_DOWN; if (joystick->hwdata->curpad.up) hat|=SDL_HAT_UP; if (joystick->hwdata->curpad.left) hat|=SDL_HAT_LEFT; if (joystick->hwdata->curpad.right) hat|=SDL_HAT_RIGHT; changed = hat^prev_buttons[joystick->index]; if ( changed ) { SDL_PrivateJoystickHat(joystick, 0, hat); } prev_buttons[joystick->index] = hat; // Axis - LStick if ((joystick->hwdata->curpad.s1_x <= -14000) || (joystick->hwdata->curpad.s1_x >= 14000)) { if (joystick->hwdata->curpad.s1_x < 0) joystick->hwdata->curpad.s1_x++; nX = ((Sint16)joystick->hwdata->curpad.s1_x); } else nX = 0; if ( nX != joystick->axes[0] ) SDL_PrivateJoystickAxis(joystick, (Uint8)0, (Sint16)nX); if ((joystick->hwdata->curpad.s1_y <= -14000) || (joystick->hwdata->curpad.s1_y >= 14000)) { if (joystick->hwdata->curpad.s1_y < 0) joystick->hwdata->curpad.s1_y++; nY = -((Sint16)(joystick->hwdata->curpad.s1_y)); } else nY = 0; if ( nY != joystick->axes[1] ) SDL_PrivateJoystickAxis(joystick, (Uint8)1, (Sint16)nY); // Axis - RStick if ((joystick->hwdata->curpad.s2_x <= -14000) || (joystick->hwdata->curpad.s2_x >= 14000)) { if (joystick->hwdata->curpad.s2_x < 0) joystick->hwdata->curpad.s2_x++; nXR = ((Sint16)joystick->hwdata->curpad.s2_x); } else nXR = 0; if ( nXR != joystick->axes[2] ) SDL_PrivateJoystickAxis(joystick, (Uint8)2, (Sint16)nXR); if ((joystick->hwdata->curpad.s2_y <= -14000) || (joystick->hwdata->curpad.s2_y >= 14000)) { if (joystick->hwdata->curpad.s2_y < 0) joystick->hwdata->curpad.s2_y++; nYR = -((Sint16)joystick->hwdata->curpad.s2_y); } else nYR = 0; if ( nYR != joystick->axes[3] ) SDL_PrivateJoystickAxis(joystick, (Uint8)3, (Sint16)nYR); }
void MyConsole::Update() { usb_do_poll(); get_controller_data(&ctrl, 0); if (ctrl.up) { P1.setDirection(u); } else if (ctrl.down) { P1.setDirection(d); } else if (ctrl.left) { P1.setDirection(l); } else if (ctrl.right) { P1.setDirection(r); } else if (ctrl.s1_x > STICK_THRESHOLD) { P1.setDirection(r); } else if (ctrl.s1_x < -STICK_THRESHOLD) { P1.setDirection(l); } else if (ctrl.s1_y > STICK_THRESHOLD) { P1.setDirection(u); } else if (ctrl.s1_y < -STICK_THRESHOLD) { P1.setDirection(d); } if (ctrl.a && !old_ctrl.a) { P1.shoot(); } if (ctrl.x && !old_ctrl.x) { if (Warning("Reset Game stats?")) { P1.setTexture(bg); P2.setTexture(bg); } } get_controller_data(&ctrl1, 1); if (ctrl1.up) { P2.setDirection(u); } else if (ctrl1.down) { P2.setDirection(d); } else if (ctrl1.left) { P2.setDirection(l); } else if (ctrl1.right) { P2.setDirection(r); } else if (ctrl1.s1_x > STICK_THRESHOLD) { P2.setDirection(r); } else if (ctrl1.s1_x < -STICK_THRESHOLD) { P2.setDirection(l); } else if (ctrl1.s1_y > STICK_THRESHOLD) { P2.setDirection(u); } else if (ctrl1.s1_y < -STICK_THRESHOLD) { P2.setDirection(d); } if (ctrl1.a && !old_ctrl.a) { P2.shoot(); } if (ctrl1.x && !old_ctrl1.x) { if (Warning("Reset Game stats?")) { P1.setTexture(bg); P1.spawn(P1.sPoint[P1.sCount].x, P1.sPoint[P1.sCount].y, P1.sPoint[P1.sCount].direction); P2.setTexture(bg); P2.sCount = rand()%4; while (P1.sCount == P2.sCount) { P2.sCount = rand()%4; } P2.spawn(P2.sPoint[P2.sCount].x, P2.sPoint[P2.sCount].y, P2.sPoint[P2.sCount].direction); } } old_ctrl = ctrl; old_ctrl1 = ctrl1; memset(&ctrl, 0, sizeof(struct controller_data_s)); memset(&ctrl1, 0, sizeof(struct controller_data_s)); }
int main(){ const char * s; char path[256]; int handle; struct controller_data_s pad; int pos=0,ppos=-1,start,count,i; xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_make_it_faster(XENON_SPEED_FULL); usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); fatInitDefault(); handle=-1; handle=bdev_enum(handle,&s); if(handle<0) return 0; strcpy(path,s); strcat(path,":/"); load_dir(path); for(;;){ usb_do_poll(); get_controller_data(&pad, 0); if (pad.s1_y>STICK_THRESHOLD) --pos; if (pad.s1_y<-STICK_THRESHOLD) ++pos; if (entrycount && (pos<0 || pos>=entrycount)){ pos=ppos; continue; } if (pad.logo) return 0; if (pad.a){ if(entries[pos].d_type&DT_DIR){ append_dir_to_path(path,entries[pos].d_name); load_dir(path); ppos=-1; pos=0; }else{ char fn[256]; strcpy(fn,path); strcat(fn,entries[pos].d_name); printf("%s\n",fn); if (strstr(entries[pos].d_name,".elf") || strstr(entries[pos].d_name,".elf32")) { // ugly elf_runFromDisk(fn); }else{ FILE * f=fopen(fn,"rb"); if(f){ int size=1024*1024; int totred=0,red; void * buf=malloc(size); u64 beg=mftb(); do{ red=fread(buf,1,size,f); totred+=red; console_putch('.'); }while(red==size); printf("\n%d bytes, %f KB/s\n",totred, (float)(totred/1024.0)/((float)(mftb()-beg)/PPC_TIMEBASE_FREQ)); free(buf); fclose(f); } } } } if(pad.back){ append_dir_to_path(path,".."); load_dir(path); ppos=-1; pos=0; } if(pad.b){ do{ handle=bdev_enum(handle,&s); }while(handle<0); strcpy(path,s); strcat(path,":/"); load_dir(path); ppos=-1; pos=0; } if (ppos==pos) continue; memset(&pad,0,sizeof(struct controller_data_s)); console_set_colors(BG_COL,FG_COL); console_clrscr(); printf("A: select, B: change disk, Back: parent dir, Logo: reload Xell\n\n%s\n\n",path); start=MAX(0,pos-MAX_DISPLAYED_ENTRIES/2); count=MIN(MAX_DISPLAYED_ENTRIES,entrycount-start); for(i=start;i<start+count;++i){ struct dirent *de = &entries[i]; if (i==pos){ console_set_colors(FG_COL,BG_COL); }else{ console_set_colors(BG_COL,FG_COL); } if (de->d_type&DT_DIR) console_putch('['); s=de->d_name; while(*s) console_putch(*s++); if (de->d_type&DT_DIR) console_putch(']'); console_putch('\r'); console_putch('\n'); } ppos=pos; do{ usb_do_poll(); get_controller_data(&pad, 0); }while(pad.a || pad.b || pad.back || pad.s1_y>STICK_THRESHOLD || pad.s1_y<-STICK_THRESHOLD); } return 0; }
int main() { xenon_make_it_faster(XENON_SPEED_FULL); xenos_init(VIDEO_MODE_AUTO); console_init(); xenon_sound_init(); pAudioStart = pAudioBuffer = (uint16_t*) malloc(48000 * sizeof (uint16_t)); memset(pAudioBuffer, 0, 48000 * sizeof (uint16_t)); usb_init(); usb_do_poll(); SYSVideoInit(); // Allocates and initializes memory. Should only be called once, before // any calls to other FCEU functions. FCEUI_Initialize(); //------------------------------------------------------------------------------------- // Set some setting //------------------------------------------------------------------------------------- // Specifies the base FCE Ultra directory. This should be called // immediately after FCEUI_Initialize() and any time afterwards. std::string base = "uda:/"; //FCEUI_SetBaseDirectory(base); // doesn't work ? newlib bug ? FCEUI_SetVidSystem(0); //Apply settings FCEUI_Sound(48000); FCEUI_SetSoundVolume(50); FCEUI_SetLowPass(0); if (FCEUI_LoadGame("uda:/Super Mario Bros. (Europe) (Rev 0A).zip", 0) != NULL) { FCEUI_SetInput(0, SI_GAMEPAD, (void*) &powerpadbuf, 0); FCEUI_SetInput(1, SI_GAMEPAD, (void*) &powerpadbuf, 0); //set to ntsc extern FCEUGI * GameInfo; GameInfo->vidsys = GIV_NTSC; } int32 * snd = NULL; int32 sndsize; // Copy contents of XBuf over to video memory(or whatever needs to be // done to make the contents of XBuf visible on screen). // Each line is 256 pixels(and bytes) in width, and there can be 240 // lines. The pitch for each line is 272 bytes. // XBuf will be 0 if the symbol FRAMESKIP is defined and this frame // was skipped. uint8 * bitmap; while (1) { FCEUI_Emulate(&bitmap, &snd, &sndsize, 0); for (int i = 0; i < (256 * 240); i++) { //Make an ARGB bitmap nesBitmap[i] = ((pcpalette[bitmap[i]].r) << 16) | ((pcpalette[bitmap[i]].g) << 8) | (pcpalette[bitmap[i]].b) | (0xFF << 24); } SYSVideoUpdate(); // Add Sound update_sound(snd,sndsize); // Add Input update_input(); } return 0; }
int main() { printf("main\n"); xenos_init(VIDEO_MODE_HDMI_720P); xenon_make_it_faster(XENON_SPEED_FULL); xenon_sound_init(); //xenos_init(VIDEO_MODE_YUV_720P); //console_init(); usb_init(); usb_do_poll(); xenon_ata_init(); xenon_atapi_init(); //fatInitDefault(); //char mount[10]; //sprintf(mount, "uda0"); //fatMount(mount, &usb2mass_ops_0, 0, 2, 64); ntfs_md *mounts; //ntfsMountAll (&mounts, NTFS_READ_ONLY); XTAFMount(); findDevices(); init_miss(); time_t rawtime; time ( &rawtime ); printf ( "The current local time is: %s", ctime (&rawtime) ); /* */ memset(&Config, 0, sizeof (PcsxConfig)); // network_init(); // network_print_config(); //console_close(); xenon_smc_start_bootanim(); // tell me that telnet or http are ready // telnet_console_init(); // mdelay(5000); //httpd_start(); // uart speed patch 115200 - jtag/freeboot // *(volatile uint32_t*)(0xea001000+0x1c) = 0xe6010000; //memset(&Config, 0, sizeof (PcsxConfig)); strcpy(Config.Net, "Disabled"); strcpy(Config.Cdr, "CDR"); strcpy(Config.Gpu, "GPU"); strcpy(Config.Spu, "SPU"); strcpy(Config.Pad1, "PAD1"); strcpy(Config.Pad2, "PAD2"); strcpy(Config.Bios, "SCPH1001.BIN"); // Use actual BIOS //strcpy(Config.Bios, "scph7502.bin"); // Use actual BIOS //strcpy(Config.Bios, "HLE"); // Use HLE strcpy(Config.BiosDir, "sda0:/devkit/pcsxr/bios"); strcpy(Config.PatchesDir, "sda0:/devkit/pcsxr/patches_/"); Config.PsxAuto = 1; // autodetect system Config.Cpu = CPU_DYNAREC; //Config.Cpu = CPU_INTERPRETER; strcpy(Config.Mcd1, "sda0:/devkit/pcsxr/memcards/card1.mcd"); strcpy(Config.Mcd2, "sda0:/devkit/pcsxr/memcards/card2.mcd"); // useSoftGpu(); /* strcpy(Config.Mcd1, "sda:/hdd1/xenon/memcards/card1.mcd"); strcpy(Config.Mcd2, "sda:/hdd1/xenon/memcards/card2.mcd"); */ //InitVideo(); SetIso(cdfile); if (LoadPlugins() == 0) { if (OpenPlugins() == 0) { if (SysInit() == -1) { printf("SysInit() Error!\n"); return -1; } SysReset(); // Check for hle ... if (Config.HLE == 1) { printf("Can't continue ... bios not found ...\r\n"); //exit(0); } CheckCdrom(); LoadCdrom(); psxCpu->Execute(); } } printf("Pcsx exit ...\r\n"); return 0; }