static void wpad_config(u8 num) { int i,j; int max = MAX_KEYS; u8 quit; char msg[30]; u32 current = 255; /* check wiimote status */ if (WPAD_Probe(num, ¤t) != WPAD_ERR_NONE) { WaitPrompt("Wiimote is not connected !"); return; } /* index for wpad_keymap */ u8 index = current + (num * 3); /* loop on each mapped keys */ for (i=0; i<max; i++) { /* remove any pending buttons */ while (WPAD_ButtonsHeld(num)) { WPAD_ScanPads(); VIDEO_WaitVSync(); } /* user information */ ClearScreen(); sprintf(msg,"Press key for %s",keys_name[i]); WriteCentre(254, msg); SetScreen(); /* wait for input */ quit = 0; while (quit == 0) { WPAD_ScanPads(); /* get buttons */ for (j=0; j<20; j++) { if (WPAD_ButtonsDown(num) & wpad_keys[j]) { wpad_keymap[index][i] = wpad_keys[j]; quit = 1; j = 20; /* leave loop */ } } } /* wait for input */ } /* loop for all keys */ /* removed any pending buttons */ while (WPAD_ButtonsHeld(num)) { WPAD_ScanPads(); VIDEO_WaitVSync(); } }
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 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 CMenu::error(const wstringEx &msg) { s32 padsState; WPADData *wd; WPAD_Rumble(WPAD_CHAN_0, 0); _hideAbout(); _hideCode(); _hideConfig(); _hideConfig2(); _hideConfigAdv(); _hideDownload(); _hideGame(); _hideMain(); _hideWBFS(); _hideGameSettings(); m_btnMgr.setText(m_errorLblMessage, msg, true); _showError(); do { WPAD_ScanPads(); padsState = WPAD_ButtonsDown(0); wd = WPAD_Data(0); _mainLoopCommon(wd); } while ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_A | WPAD_BUTTON_B)) == 0); WPAD_Rumble(WPAD_CHAN_0, 0); _hideError(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; } } }
// rulez nyan scene int main(int argc, char **argv) { bool nyaning = true; // self explain nyan(); MP3Player_PlayBuffer(nyannyannyan_mp3, nyannyannyan_mp3_size, NULL); VIDEO_SetBlack(FALSE); while(nyaning) { u64 cticks = ticks_to_millisecs(gettime()); // Loop the sound if ended if(!MP3Player_IsPlaying()) MP3Player_PlayBuffer(nyannyannyan_mp3, nyannyannyan_mp3_size, NULL); //Check wiimote input WPAD_ScanPads(); u32 pressed = WPAD_ButtonsDown(0); if (pressed & WPAD_BUTTON_HOME) nyaning = false; // blackscreen until 3,8s like the youtube video (not extreme precison ;)) if(cticks < startTime+3900) continue; // bkg frame counter (tick each 100ms) if(cticks > bkgTimeCounter+100) { bkgTimeCounter = cticks; currentBkgStep = (currentBkgStep+1) % BKG_STEP; } // nyan frame counter (tick each 60ms) if(cticks > nyanTimeCounter+60) { nyanTimeCounter = cticks; currentNyanStep = (currentNyanStep+1) % NYAN_STEP; } // Set the 2d matrix guMtxIdentity(GXmodelView2D); GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0); // nyan f32 move = delta % BKG_SIZE; f32 x = -move; while(x < rmode->fbWidth) { drawBkgSprite(x, currentBkgStep); x += BKG_SIZE; } // nyan nyan drawNyan(-5, 240 - ((NYAN_HEIGHT*8)/2), currentNyanStep); // Copy & switch fb GX_DrawDone(); GX_CopyDisp(xfb[wichFb], GX_TRUE); VIDEO_SetNextFramebuffer(xfb[wichFb]); VIDEO_Flush(); VIDEO_WaitVSync(); wichFb ^= 1; delta += 8; } return 0; }
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; }
/**************************************************************************** * 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); } }
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 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); } }
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 }
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 rvlInitFat() { // temporary init video, pad, console VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); CON_Init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); // loop until either Home has been pressed, or an SD card has been found while(!fatInitDefault()) { WPAD_ScanPads(); printf("\x1b[2;0HFAT initialization error!"); printf("\x1b[3;0HPlease insert a SD card to continue or press Home to exit!"); u32 pressed = WPAD_ButtonsDown(0); if(pressed & WPAD_BUTTON_HOME) { printf("\x1b[5;0HExiting..."); exit(0); } VIDEO_WaitVSync(); } printf("\x1b[2;0H"); // set the app path strcpy(program.apppath, "sd:/apps/wii_azunyan8"); }
static void updatePAD(u32 retrace) { retraceCount = retrace; PAD_ScanPads(); #ifdef HW_RVL WPAD_ScanPads(); #endif }
void wiimenu_dip_cfg() { int refresh = 1; int col = 0; int row = 0; int go = 1; while(go) { if(time_to_leave) break; VIDEO_WaitVSync(); WPAD_ScanPads(); u32 WPAD_Pressed = WPAD_ButtonsDown(0); WPAD_Pressed |= WPAD_ButtonsDown(1); WPAD_Pressed |= WPAD_ButtonsDown(2); WPAD_Pressed |= WPAD_ButtonsDown(3); if(WPAD_Pressed & WPAD_BUTTON_DOWN) { row += 1; row %= 3; refresh = 1; } if(WPAD_Pressed & WPAD_BUTTON_UP) { row -= 1; if(row < 0) row = 2; refresh = 1; } if(WPAD_Pressed & WPAD_BUTTON_RIGHT) { col += 1; col %= 8; refresh = 1; } if(WPAD_Pressed & WPAD_BUTTON_LEFT) { col -= 1; if(col < 0) col = 7; refresh = 1; } if(WPAD_Pressed & WPAD_BUTTON_A) { np2cfg.dipsw[row] ^= 1 << col; refresh = 1; } if(WPAD_Pressed & WPAD_BUTTON_B) { go = 0; } if(refresh) { PrintMenuHead(); printf(" DIP Switches:\n"); printf(" 1 2 3 4 5 6 7 8 \n"); printf(" Switch array 1: "); PrintSwitches(np2cfg.dipsw[0], (row == 0) ? col : 9001); printf("\n Switch array 2: "); PrintSwitches(np2cfg.dipsw[1], (row == 1) ? col : 9001); printf("\n Switch array 3: "); PrintSwitches(np2cfg.dipsw[2], (row == 2) ? col : 9001); BorderOverlay(); } } }
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 }
void TProfanationGame::updateInputController() { struct expansion_t stick; bool sleft=false,sright=false,sup=false,sdown=false,nun_C=false,nun_Z=false; WPAD_ScanPads(); WPAD_Expansion(WPAD_CHAN_0, &stick); u16 buttonsHeld = WPAD_ButtonsHeld(0); u16 buttonsDown = WPAD_ButtonsDown(0); if(stick.type == WPAD_EXP_NUNCHUK) { float diffx = stick.nunchuk.js.pos.x - stick.nunchuk.js.center.x; float diffy = stick.nunchuk.js.pos.y - stick.nunchuk.js.center.y; if(fabs(diffx)>SENSIBILITY) { sright = (stick.nunchuk.js.pos.x > stick.nunchuk.js.center.x); sleft = (stick.nunchuk.js.pos.x < stick.nunchuk.js.center.x); } if(fabs(diffy)>SENSIBILITY) { sup = (stick.nunchuk.js.pos.y > stick.nunchuk.js.center.y); sdown = (stick.nunchuk.js.pos.y < stick.nunchuk.js.center.y); } nun_C = stick.nunchuk.btns_held & NUNCHUK_BUTTON_C; nun_Z = stick.nunchuk.btns_held & NUNCHUK_BUTTON_Z; inputController.setStatus(GKEY_LEFT, sleft || (buttonsHeld & WPAD_BUTTON_LEFT)); inputController.setStatus(GKEY_RIGHT,sright || (buttonsHeld & WPAD_BUTTON_RIGHT)); inputController.setStatus(GKEY_UP, sup || (buttonsHeld & WPAD_BUTTON_UP)); inputController.setStatus(GKEY_DOWN, sdown || (buttonsHeld & WPAD_BUTTON_DOWN)); inputController.setStatus(GKEY_LONG_JUMP, nun_C || (buttonsDown & WPAD_BUTTON_1)); inputController.setStatus(GKEY_SHORT_JUMP, nun_Z || (buttonsDown & WPAD_BUTTON_2)); } else { inputController.setStatus(GKEY_LEFT, (buttonsHeld & WPAD_BUTTON_UP)); inputController.setStatus(GKEY_RIGHT,(buttonsHeld & WPAD_BUTTON_DOWN)); inputController.setStatus(GKEY_UP, (buttonsHeld & WPAD_BUTTON_RIGHT)); inputController.setStatus(GKEY_DOWN, (buttonsHeld & WPAD_BUTTON_LEFT)); inputController.setStatus(GKEY_LONG_JUMP, (buttonsDown & WPAD_BUTTON_1)); inputController.setStatus(GKEY_SHORT_JUMP,(buttonsDown & WPAD_BUTTON_2)); } inputController.setStatus(GKEY_SELECT,(buttonsDown & WPAD_BUTTON_A)); inputController.setStatus(GKEY_ABORT,(buttonsDown & WPAD_BUTTON_HOME)); inputController.setStatus(GKEY_SCR_PLUS,(buttonsDown & WPAD_BUTTON_PLUS)); inputController.setStatus(GKEY_SCR_MINUS,(buttonsDown & WPAD_BUTTON_MINUS)); }
// Wait for any button void pressAnyButton() { u32 pressed = false; printf("\nPress any button to continue...\n"); do { WPAD_ScanPads(); pressed = WPAD_ButtonsDown(0); } while (!pressed); }
void console_pause() { while(1) { VIDEO_WaitVSync(); WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)exit(0); } }
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; }
void Game::run(const string& initialLevel) { this->changeLevel(initialLevel); int frameCount = 0; char framePerSecond[32] = ""; while (!this->levels.empty()) { WPAD_ScanPads(); Level* level = this->levels.top(); level->nextStep(); level->render(); if (this->debugDrawEnabled) level->world->DrawDebugData(); if (this->console.isEnabled()) this->console.render(); // Render FPS GRRLIB_PrintfTTF(570, 32, this->font, framePerSecond, 16, GRRLIB_RED); GRRLIB_Render(); // Render the frame buffer to the screen // If level is finished, resume the previous one if (level->isFinished()) { Console::log(LOG_INFO, "Game::run() - resume previous level"); this->levels.pop(); delete level; if (this->levels.top()) this->levels.top()->loadGraphics(); } // WPAD_ButtonsDown tells us which buttons were pressed in this loop // this is a "one shot" state which will not fire again until the button has been released u32 pressed = WPAD_ButtonsDown(WPAD_CHAN_0); // We return to the launcher application via exit if (pressed & WPAD_BUTTON_HOME) return; if (pressed & WPAD_BUTTON_PLUS) this->console.enable(!this->console.isEnabled()); if (pressed & WPAD_BUTTON_MINUS) this->debugDrawEnabled = !this->debugDrawEnabled; // Count FPS frameCount++; if (this->fpsTimer.isExpired()) { sprintf(framePerSecond, "%2d FPS", frameCount); frameCount = 0; } } }
/* * 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 ); }
/* * 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(); } }
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(); } }
static int _GetKeys(int Control, BUTTONS * Keys, controller_config_t* config, int (*available)(int), unsigned int (*getButtons)(WPADData*)) { if(wpadNeedScan){ WPAD_ScanPads(); wpadNeedScan = 0; } WPADData* wpad = WPAD_Data(Control); BUTTONS* c = Keys; memset(c, 0, sizeof(BUTTONS)); //Reset buttons & sticks c->btns.All = 0xFFFF; c->leftStickX = c->leftStickY = c->rightStickX = c->rightStickY = 128; // Only use a connected nunchuck controller if(!available(Control)) return 0; unsigned int b = getButtons(wpad); inline int isHeld(button_tp button){ return (b & button->mask) == button->mask ? 0 : 1; } c->btns.SQUARE_BUTTON = isHeld(config->SQU); c->btns.CROSS_BUTTON = isHeld(config->CRO); c->btns.CIRCLE_BUTTON = isHeld(config->CIR); c->btns.TRIANGLE_BUTTON = isHeld(config->TRI); c->btns.R1_BUTTON = isHeld(config->R1); c->btns.L1_BUTTON = isHeld(config->L1); c->btns.R2_BUTTON = isHeld(config->R2); c->btns.L2_BUTTON = isHeld(config->L2); c->btns.L_DPAD = isHeld(config->DL); c->btns.R_DPAD = isHeld(config->DR); c->btns.U_DPAD = isHeld(config->DU); c->btns.D_DPAD = isHeld(config->DD); c->btns.START_BUTTON = isHeld(config->START); c->btns.R3_BUTTON = isHeld(config->R3); c->btns.L3_BUTTON = isHeld(config->L3); c->btns.SELECT_BUTTON = isHeld(config->SELECT); //adjust values by 128 cause PSX sticks range 0-255 with a 128 center pos s8 stickX = 0; s8 stickY = 0; if(config->analogL->mask == NUNCHUK_AS_ANALOG){ stickX = getStickValue(&wpad->exp.nunchuk.js, STICK_X, 127); stickY = getStickValue(&wpad->exp.nunchuk.js, STICK_Y, 127); } else if(config->analogL->mask == IR_AS_ANALOG){ if(wpad->ir.smooth_valid){ stickX = ((short)(wpad->ir.sx - 512)) >> 2; stickY = -(signed char)((wpad->ir.sy - 384) / 3); } else {
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; } }
void fail(int val) { if (LANG_GER) printf("Fehler: %i\nMit HOME zurueck zum Loader.", val); else printf("Error: %i\nGet back to the Loader by pressing the HOME-Button.", val); while (1) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) { end(); } } }
void press_button_to_reboot() { s32 pressed = 0; while (1) { WPAD_ScanPads(); pressed = WPAD_ButtonsDown(0); if (pressed) { release_storage(); SYS_ResetSystem(SYS_RESTART,0,0); } } }
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(); }