void waitA(){ printf("Press A to continue\n"); while (1){ PAD_ScanPads(); if (PAD_ButtonsDown(0) & PAD_BUTTON_A){ while (PAD_ButtonsHeld(0) & PAD_BUTTON_A){ PAD_ScanPads(); } break; } VIDEO_WaitVSync(); } }
/******************************* gamepad support *******************************/ static void pad_config(int num, int padtype) { int i,j,max; u16 p; u8 quit; char msg[30]; u32 pad = PAD_ScanPads() & (1<<num); if (!pad) { sprintf(msg, "PAD #%d is not connected !", num+1); WaitPrompt(msg); return; } /* configure keys */ max = (padtype == DEVICE_6BUTTON) ? MAX_KEYS : (MAX_KEYS - 3); for (i=0; i<max; i++) { /* remove any pending keys */ while (PAD_ButtonsHeld(num)) { VIDEO_WaitVSync(); PAD_ScanPads(); } ClearScreen(); sprintf(msg,"Press key for %s",keys_name[i]); WriteCentre(254, msg); SetScreen(); /* check buttons state */ quit = 0; while (quit == 0) { VIDEO_WaitVSync(); PAD_ScanPads(); p = PAD_ButtonsDown(num); for (j=0; j<8; j++) { if (p & pad_keys[j]) { config.pad_keymap[num][i] = pad_keys[j]; quit = 1; j = 9; /* exit loop */ } } } } }
bool UserYesNoStop() { u16 pDown; u16 GCpDown; while(1) { WPAD_ScanPads(); PAD_ScanPads(); pDown = WPAD_ButtonsDown(0); GCpDown = PAD_ButtonsDown(0); if (pDown & WPAD_BUTTON_A || GCpDown & PAD_BUTTON_A) { return true; } if (pDown & WPAD_BUTTON_B || GCpDown & PAD_BUTTON_B) { return false; } if (pDown & WPAD_BUTTON_HOME || GCpDown & PAD_BUTTON_START) { return false; } } //it should never get here, but to kill that silly warning... :) return false; }
void waitforbuttonpress(u32 *out, u32 *outGC) { u32 pressed = 0; u32 pressedGC = 0; while (true) { WPAD_ScanPads(); pressed = WPAD_ButtonsDown(0) | WPAD_ButtonsDown(1) | WPAD_ButtonsDown(2) | WPAD_ButtonsDown(3); PAD_ScanPads(); pressedGC = PAD_ButtonsDown(0) | PAD_ButtonsDown(1) | PAD_ButtonsDown(2) | PAD_ButtonsDown(3); if(pressed || pressedGC) { if (pressedGC) { // Without waiting you can't select anything usleep (20000); } if (out) *out = pressed; if (outGC) *outGC = pressedGC; return; } } }
void FPAD_Update( void ) { if (WPAD_ScanPads() > WPAD_ERR_NONE) { WPAD_Pressed = WPAD_ButtonsDown(0) | WPAD_ButtonsDown(1) | WPAD_ButtonsDown(2) | WPAD_ButtonsDown(3); WPAD_Pressed |= WPAD_ButtonsHeld(0) | WPAD_ButtonsHeld(1) | WPAD_ButtonsHeld(2) | WPAD_ButtonsHeld(3); } else { // No Wii remotes are connected WPAD_Pressed = 0; } if (PAD_ScanPads() > PAD_ERR_NONE) { PAD_Pressed = PAD_ButtonsDown(0) | PAD_ButtonsDown(1) | PAD_ButtonsDown(2) | PAD_ButtonsDown(3); PAD_Pressed |= PAD_ButtonsHeld(0) | PAD_ButtonsHeld(1) | PAD_ButtonsHeld(2) | PAD_ButtonsHeld(3); PAD_Stick_Y = PAD_StickY(0) | PAD_StickY(1) | PAD_StickY(2) | PAD_StickY(3); PAD_Stick_X = PAD_StickX(0) | PAD_StickX(1) | PAD_StickX(2) | PAD_StickX(3); } else { // No GC controllers are connected PAD_Pressed = 0; PAD_Stick_Y = 0; PAD_Stick_X = 0; } if( WPAD_Pressed == 0 && PAD_Pressed == 0 && ( PAD_Stick_Y < 25 && PAD_Stick_Y > -25 ) && ( PAD_Stick_X < 25 && PAD_Stick_X > -25 ) ) { SLock = false; SpeedX= DELAY_START; } }
void UpdatePads() { #ifdef HW_RVL WiiDRC_ScanPads(); WPAD_ScanPads(); #endif PAD_ScanPads(); for(int i=3; i >= 0; i--) { userInput[i].pad.btns_d = PAD_ButtonsDown(i); userInput[i].pad.btns_u = PAD_ButtonsUp(i); userInput[i].pad.btns_h = PAD_ButtonsHeld(i); userInput[i].pad.stickX = PAD_StickX(i); userInput[i].pad.stickY = PAD_StickY(i); userInput[i].pad.substickX = PAD_SubStickX(i); userInput[i].pad.substickY = PAD_SubStickY(i); userInput[i].pad.triggerL = PAD_TriggerL(i); userInput[i].pad.triggerR = PAD_TriggerR(i); } #ifdef HW_RVL if(WiiDRC_Inited() && WiiDRC_Connected()) { userInput[0].wiidrcdata.btns_d = WiiDRC_ButtonsDown(); userInput[0].wiidrcdata.btns_u = WiiDRC_ButtonsUp(); userInput[0].wiidrcdata.btns_h = WiiDRC_ButtonsHeld(); userInput[0].wiidrcdata.stickX = WiiDRC_lStickX(); userInput[0].wiidrcdata.stickY = WiiDRC_lStickY(); userInput[0].wiidrcdata.substickX = WiiDRC_rStickX(); userInput[0].wiidrcdata.substickY = WiiDRC_rStickY(); } #endif }
int backupNANDzestig() { printf("\nWould you like to backup your Wii's NAND Flash? Hit A for Yes, or B for no.\n"); while(1) { WPAD_ScanPads(); PAD_ScanPads(); u32 WPAD_Pressed = WPAD_ButtonsDown(0); WPAD_Pressed |= WPAD_ButtonsDown(1); WPAD_Pressed |= WPAD_ButtonsDown(2); WPAD_Pressed |= WPAD_ButtonsDown(3); u32 PAD_Pressed = PAD_ButtonsDown(0); PAD_Pressed |= PAD_ButtonsDown(1); PAD_Pressed |= PAD_ButtonsDown(2); PAD_Pressed |= PAD_ButtonsDown(3); if( (WPAD_Pressed & WPAD_BUTTON_A) || (PAD_Pressed & PAD_BUTTON_A) ) break; if( (WPAD_Pressed & WPAD_BUTTON_B) || (PAD_Pressed & PAD_BUTTON_B) ) return 0; } YAWND_Backup_Zestig(); // Thanks Redbird for releasing the YaWnD source code! return 0; }
bool WaitForAnyKey (void) { u32 wbtn, gcbtn; int i; bool pressed = false; char mask[80]; char buff[80]; strcpy (mask, "---------------------------------------------------------------------------"); for (i = 0; i <strlen (mask); i++) { strcpy (buff, mask); buff[i] = '*'; printf ("%s\r", buff); VIDEO_WaitVSync(); WPAD_ScanPads(); // Scan the Wiimotes wbtn = WPAD_ButtonsDown(0); PAD_ScanPads(); gcbtn = PAD_ButtonsDown(0); if (wbtn || gcbtn) { pressed = true; break; } usleep (10 * 1000); } printd ("---------------------------------------------------------------------------\n"); return pressed; }
void ogc_input__update(void) { int i; int num = 0; /* update inputs */ PAD_ScanPads(); #ifdef HW_RVL WPAD_ScanPads(); if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_HOME) { /* do additional check here to prevent bad controller configuration */ ConfigRequested = 1; return; } #endif for (i=0; i<MAX_DEVICES; i++) { input.pad[i] = 0; if (input.dev[i] != NO_DEVICE) { if (config.input[num].device == 0) pad_update(config.input[num].port, i); #ifdef HW_RVL else if (config.input[num].device > 0) wpad_update(config.input[num].port,i, config.input[num].device - 1); #endif num ++; } } }
void UpdatePads() { #ifdef HW_RVL WPAD_ScanPads(); #endif now = gettime(); if(!padsConnected && diff_sec(prev, now) < 2) return; prev = now; padsConnected = PAD_ScanPads(); if(!padsConnected) return; for(int i=3; i >= 0; i--) { userInput[i].pad.btns_d = PAD_ButtonsDown(i); userInput[i].pad.btns_u = PAD_ButtonsUp(i); userInput[i].pad.btns_h = PAD_ButtonsHeld(i); userInput[i].pad.stickX = PAD_StickX(i); userInput[i].pad.stickY = PAD_StickY(i); userInput[i].pad.substickX = PAD_SubStickX(i); userInput[i].pad.substickY = PAD_SubStickY(i); userInput[i].pad.triggerL = PAD_TriggerL(i); userInput[i].pad.triggerR = PAD_TriggerR(i); } }
/**************************************************************************** * UpdatePadsCB * * called by postRetraceCallback in InitGCVideo - scans gcpad and wpad ***************************************************************************/ static void UpdatePadsCB () { #ifdef HW_RVL WPAD_ScanPads(); #endif PAD_ScanPads(); for(int i=3; i >= 0; i--) { #ifdef HW_RVL memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); #endif userInput[i].chan = i; userInput[i].pad.btns_d = PAD_ButtonsDown(i); userInput[i].pad.btns_u = PAD_ButtonsUp(i); userInput[i].pad.btns_h = PAD_ButtonsHeld(i); userInput[i].pad.stickX = PAD_StickX(i); userInput[i].pad.stickY = PAD_StickY(i); userInput[i].pad.substickX = PAD_SubStickX(i); userInput[i].pad.substickY = PAD_SubStickY(i); userInput[i].pad.triggerL = PAD_TriggerL(i); userInput[i].pad.triggerR = PAD_TriggerR(i); } }
static void updatePAD(u32 retrace) { retraceCount = retrace; PAD_ScanPads(); #ifdef HW_RVL WPAD_ScanPads(); #endif }
static void show_console(int code) { u32 i, b; printf("ScummVM exited abnormally (%d).\n", code); gfx_frame_abort(); gfx_init(); if (!gfx_frame_start()) return; gfx_con_draw(); gfx_frame_end(); for (i = 0; i < 60 * 3; ++i) VIDEO_WaitVSync(); #ifdef DEBUG_WII_GDB printf("attach gdb now\n"); _break(); #endif printf("Press any key to continue.\n"); if (!gfx_frame_start()) return; gfx_con_draw(); gfx_frame_end(); VIDEO_WaitVSync(); while (true) { b = 0; if (PAD_ScanPads() & 1) b = PAD_ButtonsDown(0); #ifndef GAMECUBE WPAD_ScanPads(); if (WPAD_Probe(0, NULL) == WPAD_ERR_NONE) b |= WPAD_ButtonsDown(0); #endif if (b) break; VIDEO_WaitVSync(); } printf("\n\nExiting...\n"); if (!gfx_frame_start()) return; gfx_con_draw(); gfx_frame_end(); VIDEO_WaitVSync(); }
uint32_t PadSystem::scanPads(int controller) { #ifdef __WIISYSTEM__ WPAD_ScanPads(); return WPAD_ButtonsDown(controller); #else PAD_ScanPads(); return PAD_ButtonsDown(controller); #endif }
qboolean IN_GetGCPadCursorPos(incursorcoords_t* p) { PAD_ScanPads(); p->x = window_center_x + PAD_SubStickX(0); p->y = window_center_y + PAD_SubStickY(0); if((p->x != window_center_x)||(p->y != window_center_y)) return true; return false; }
u8 readKeys () { u8 bitmap; int pad; PAD_ScanPads(); WPAD_ScanPads(); bitmap = 0; for (pad=0;pad<4;pad++) { if (PAD_ButtonsDown(pad) & PAD_BUTTON_UP || WPAD_ButtonsDown(pad) & WPAD_BUTTON_UP) { bitmap |= KEY_UP; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_DOWN || WPAD_ButtonsDown(pad) & WPAD_BUTTON_DOWN) { bitmap |= KEY_DOWN; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_LEFT || WPAD_ButtonsDown(pad) & WPAD_BUTTON_LEFT) { bitmap |= KEY_LEFT; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_RIGHT || WPAD_ButtonsDown(pad) & WPAD_BUTTON_RIGHT) { bitmap |= KEY_RIGHT; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_X || WPAD_ButtonsDown(pad) & WPAD_BUTTON_PLUS) { bitmap |= KEY_PLUS; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_Y || WPAD_ButtonsDown(pad) & WPAD_BUTTON_MINUS) { bitmap |= KEY_MINUS; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_A || WPAD_ButtonsDown(pad) & WPAD_BUTTON_A) { bitmap |= KEY_A; } if (PAD_ButtonsDown(pad) & PAD_BUTTON_B || WPAD_ButtonsDown(pad) & WPAD_BUTTON_B) { bitmap |= KEY_B; } } return bitmap; }
static void refreshAvailable(void) { if(padNeedScan) { gc_connected = PAD_ScanPads(); padNeedScan = 0; } int i; for(i=0; i<4; ++i) controller_GC.available[i] = (gc_connected & (1<<i)); }
void end() { int columns = 0, rows = 0; CON_GetMetrics(&columns, &rows); printf("\x1b[%i;0H",rows); printf("File written... press Home/Start to exit."); while(1) { WPAD_ScanPads(); PAD_ScanPads(); if ((WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) || (PAD_ButtonsDown(0) & PAD_BUTTON_START)) exit(0); VIDEO_WaitVSync(); } }
/* * Waits until no buttons are pressed * * joys The number of joysticks */ void wii_wait_until_no_buttons( int joys ) { while( 1 ) { WPAD_ScanPads(); PAD_ScanPads(); if( !wii_is_any_button_held( joys ) ) { break; } VIDEO_WaitVSync(); } }
/* * Updates the Atari keys (controls) state * * keyboard_data The keyboard (controls) state */ static void wii_atari_update_keys( unsigned char keyboard_data[19] ) { WPAD_ScanPads(); PAD_ScanPads(); if( lightgun_enabled ) { wii_atari_update_wiimote_ir(); } wii_atari_update_joystick( 0, keyboard_data ); wii_atari_update_joystick( 1, keyboard_data ); }
void NeoGeoPocket::updateControls( bool isRapid ) { bool special = false; WPAD_ScanPads(); PAD_ScanPads(); int c = 0; READ_CONTROLS_STATE u16 result = 0; StandardDbEntry* entry = (StandardDbEntry*)getDbManager().getEntry(); StandardDatabaseManager& dbManager = (StandardDatabaseManager&)getDbManager(); for( int i = 0; i < dbManager.getMappableButtonCount( entry->profile ); i++ ) { BEGIN_IF_BUTTON_HELD(entry->profile) u32 val = NeoGeoPocketDbManager::NGP_BUTTONS[ i ].button; if( val == NGP_REWIND ) { special = true; if( !specialheld ) { specialheld = true; DNeedRewind = true; } } else if( !( val & BTN_RAPID ) || isRapid ) { result |= ( val & 0xFFFF ); } END_IF_BUTTON_HELD } IF_RIGHT result|=NGP_RIGHT; IF_LEFT result|=NGP_LEFT; IF_UP result|=NGP_UP; IF_DOWN result|=NGP_DOWN; m_padData[0] = result; if( !special ) { specialheld = false; DNeedRewind = false; } }
u32 Pad_GetButtons(void) { u32 buttons = 0, cnt; /* Scan pads */ PAD_ScanPads(); /* Get pressed buttons */ //for (cnt = 0; cnt < MAX_WIIMOTES; cnt++) for (cnt = 0; cnt < 4; cnt++) buttons |= PAD_ButtonsDown(cnt); return buttons; }
void getWiiJoyEvents() { WPAD_ScanPads(); PAD_ScanPads(); buttonsDown[0] = WPAD_ButtonsDown(WPAD_CHAN_0); buttonsDown[1] = WPAD_ButtonsDown(WPAD_CHAN_1); buttonsHeld[0] = WPAD_ButtonsHeld(WPAD_CHAN_0); buttonsHeld[1] = WPAD_ButtonsHeld(WPAD_CHAN_1); buttonsUp[0] = WPAD_ButtonsUp(WPAD_CHAN_0); buttonsUp[1] = WPAD_ButtonsUp(WPAD_CHAN_1); getGamecubePadInput(); getWiimoteAndNunchukPadInput(); getClassicControllerPadInput(); }
int EndingEvents() { static SDL_Event event; player_room = 0; current_boss = 3; boss_fight_mode = 4; MusicUpdate(); #ifdef HW_NINTENDO #ifdef HW_RVL WPAD_ScanPads(); //u32 WM_held = WPAD_ButtonsHeld(0); //u32 WM_up = WPAD_ButtonsUp(0); u32 WM_down = WPAD_ButtonsDown(0); #endif PAD_ScanPads(); //u16 PAD_ButtonsHeld(0); //u16 GC_up = PAD_ButtonsUp(0); u16 GC_down = PAD_ButtonsDown(0); if (GC_down & PAD_BUTTON_START #ifdef HW_RVL || WM_down & WPAD_BUTTON_HOME || WM_down & WPAD_CLASSIC_BUTTON_HOME #endif ) return 1; #endif while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) { switch (event.key.keysym.sym) { case SDLK_ESCAPE: return 1; break; default: break; } } if (event.type == SDL_QUIT) { return 1; } } return 0; }
int main() { float rot=0; float i; int circsize=150; char text[]="GRRLIB ROXX "; GRRLIB_Init(); PAD_Init(); GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font3d); GRRLIB_InitTileSet(tex_font, 64, 64, 32); GRRLIB_SetHandle (tex_font, tex_font->tilew/2, tex_font->tileh+circsize); GRRLIB_texImg *tex_screen; tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight); GRRLIB_Settings.antialias = true; while(1) { PAD_ScanPads(); if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0); // we say thant we will want to capture to a texture all the following GRRLIB_CompoStart(); for(i=0;i<360;i+=30) { // We draw some letters GRRLIB_DrawTile((rmode->fbWidth/2)-(tex_font->tilew/2), (rmode->efbHeight/2)-(tex_font->tileh+circsize), tex_font, rot+i, 1, 1, 0xFFFFFFFF, text[(int)(i/30)]-32); } // we say we want to capture now, (the buffer will be cleared after the capture) GRRLIB_CompoEnd(0, 0, tex_screen); rot-=0.6; // we now draw 3 times the captured buffer playing with color GRRLIB_DrawImg(0, 0, tex_screen, 0, 1, 1, 0xFF00FFFF); GRRLIB_DrawImg(50, 50, tex_screen, 0, 1, 1, 0xFFFF00FF); GRRLIB_DrawImg(100, 100, tex_screen, 0, 1, 1, 0xFFFFFFFF); GRRLIB_Render(); } GRRLIB_FreeTexture(tex_screen); GRRLIB_FreeTexture(tex_font); GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB exit(0); }
u32 ButtonsPressed(void) { int i; u32 buttons = 0; WUPC_UpdateButtonStats(); WPAD_ScanPads(); PAD_ScanPads(); for (i = 3; i >= 0; i--) { buttons |= WUPC_ButtonsDown(i); buttons |= PAD_ButtonsDown(i); buttons |= WPAD_ButtonsDown(i); } return buttons; }
void IN_GCPadMainStickMove (usercmd_t *cmd) { int gx; int gy; PAD_ScanPads(); gx = PAD_StickX(0); gy = PAD_StickY(0); if((gx > -in_gcpadmovmin->value)&&(gx < in_gcpadmovmin->value)) gx = 0; if((gy > -in_gcpadmovmin->value)&&(gy < in_gcpadmovmin->value)) gy = 0; if((gx == 0)&&(gy == 0)) return; cmd->sidemove += m_side->value * gx * in_gcpadmovscale->value; cmd->forwardmove += m_forward->value * gy * in_gcpadmovscale->value; }
void REV_preProcess() { WPAD_ScanPads(); PAD_ScanPads(); keyboardProcess(); //Update time updateTime(); HTCAMERA * htc = mainRoot->fstHTC; for(u8 i = 0; i < 4; i++) { wmData[i] = WPAD_Data(i); } update2D(); while(htc)//Update Head-Tracking cameras's point of view { htc->updateEye(); htc = htc->nextHTC; } }
int main() { #if GEKKO VIDEO_Init(); #if HW_RVL WPAD_Init(); #endif PAD_Init(); rmode = VIDEO_GetPreferredMode(nullptr); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); CON_Init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ); CON_EnableGecko(CARD_SLOTB, true); VIDEO_Configure(rmode); VIDEO_SetBlack(false); VIDEO_Flush(); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); athena::io::MemoryCopyReader test("sd:/test.dat"); while(true) { #if HW_RVL WPAD_ScanPads(); #endif PAD_ScanPads(); if (PAD_ButtonsDown(0) & PAD_BUTTON_START) break; #if HW_RVL if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break; #endif VIDEO_WaitVSync(); } #endif return 0; }
void save_options() { printf("\nWARNING: READ THE README FIRST!\nPress \x1b[32;1mA\x1b[39;0m to save or \x1b[31;1mB\x1b[39;0m to return to the Configuration.\n"); while(1) { WPAD_ScanPads(); PAD_ScanPads(); u32 WPAD_Pressed; u32 WPAD1_Pressed = WPAD_ButtonsDown(0); u32 WPAD2_Pressed = WPAD_ButtonsDown(1); u32 WPAD3_Pressed = WPAD_ButtonsDown(2); u32 WPAD4_Pressed = WPAD_ButtonsDown(3); u32 PAD_Pressed; u32 PAD1_Pressed = PAD_ButtonsDown(0); u32 PAD2_Pressed = PAD_ButtonsDown(1); u32 PAD3_Pressed = PAD_ButtonsDown(2); u32 PAD4_Pressed = PAD_ButtonsDown(3); WPAD_Pressed = WPAD1_Pressed | WPAD2_Pressed | WPAD3_Pressed | WPAD4_Pressed; PAD_Pressed = PAD1_Pressed | PAD2_Pressed | PAD3_Pressed | PAD4_Pressed ; if((WPAD_Pressed & WPAD_BUTTON_A) || (PAD_Pressed & PAD_BUTTON_A)) { if (country != sadr[0]){ memset(sadr, 0, SADR_LENGTH); sadr[0] = country; int ret = SYSCONF_Set("IPL.SADR", sadr, SADR_LENGTH); if (ret) { printf("SYSCONF_Set IPL.SADR %d", ret); sleep(5); return;} } SYSCONF_SaveChanges(); ClearScreen(); return; } if((WPAD_Pressed & WPAD_BUTTON_B) || (PAD_Pressed & PAD_BUTTON_B)) { ClearScreen(); return; } VIDEO_WaitVSync(); } }