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; } }
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(); } }
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(); }
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; } }
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 ++; } } }
u32 StandardClassic(unsigned short pad) { u32 J = 0; #ifdef HW_RVL u32 wp = WPAD_ButtonsHeld(pad); if (wp & WPAD_CLASSIC_BUTTON_RIGHT) J |= VBA_RIGHT; if (wp & WPAD_CLASSIC_BUTTON_LEFT) J |= VBA_LEFT; if (wp & WPAD_CLASSIC_BUTTON_UP) J |= VBA_UP; if (wp & WPAD_CLASSIC_BUTTON_DOWN) J |= VBA_DOWN; if (wp & WPAD_CLASSIC_BUTTON_PLUS) J |= VBA_BUTTON_START; if (wp & WPAD_CLASSIC_BUTTON_MINUS) J |= VBA_BUTTON_SELECT; if (wp & WPAD_CLASSIC_BUTTON_FULL_L || wp & WPAD_CLASSIC_BUTTON_ZL) J |= VBA_BUTTON_L; if (wp & WPAD_CLASSIC_BUTTON_FULL_R || wp & WPAD_CLASSIC_BUTTON_ZR) J |= VBA_BUTTON_R; if (wp & WPAD_CLASSIC_BUTTON_A) J |= VBA_BUTTON_A; if (wp & WPAD_CLASSIC_BUTTON_B) J |= VBA_BUTTON_B; if (wp & WPAD_CLASSIC_BUTTON_Y || wp & WPAD_CLASSIC_BUTTON_X) J |= VBA_SPEED; #endif return J; }
/**************************************************************************** * Controller Configuration * * Snes9x 1.51 uses a cmd system to work out which button has been pressed. * Here, I simply move the designated value to the gcpadmaps array, which * saves on updating the cmd sequences. ***************************************************************************/ u32 GetInput (u16 ctrlr_type) { //u32 exp_type; u32 pressed; pressed=0; s8 gc_px = 0; while( PAD_ButtonsHeld(0) #ifdef HW_RVL | WPAD_ButtonsHeld(0) #endif ) VIDEO_WaitVSync(); // button 'debounce' while (pressed == 0) { VIDEO_WaitVSync(); // get input based on controller type if (ctrlr_type == CTRLR_GCPAD) { pressed = PAD_ButtonsHeld (0); gc_px = PAD_SubStickX (0); } #ifdef HW_RVL else { // if ( WPAD_Probe( 0, &exp_type) == 0) // check wiimote and expansion status (first if wiimote is connected & no errors) // { pressed = WPAD_ButtonsHeld (0); // if (ctrlr_type != CTRLR_WIIMOTE && exp_type != ctrlr_type+1) // if we need input from an expansion, and its not connected... // pressed = 0; // } } #endif /*** check for exit sequence (c-stick left OR home button) ***/ if ( (gc_px < -70) || (pressed & WPAD_BUTTON_HOME) || (pressed & WPAD_CLASSIC_BUTTON_HOME) ) return 0; } // end while while( pressed == (PAD_ButtonsHeld(0) #ifdef HW_RVL | WPAD_ButtonsHeld(0) #endif ) ) VIDEO_WaitVSync(); return pressed; } // end GetInput()
u32 InputDevices::GetPadButtonStatus(int channel) { u32 extensions; WPADData data; u32 buttons, gcbuttons; PAD2WPAD *p2w; joystick_t padjoy; // Check standard buttons buttons = WPAD_ButtonsHeld(channel); // Add GameCube buttons gcbuttons = PAD_ButtonsHeld(channel); p2w = pad2wpad; while( p2w->pad ) { if( gcbuttons & p2w->pad ) { buttons |= p2w->wpad; } p2w++; } // Key translations for default WiiMote buttons ProcessWPadButtons(channel, wpad_default); // Check extensions WPAD_Probe(channel, &extensions); if( extensions == WPAD_EXP_NUNCHUK ) { // Nunchuk stick WPAD_Expansion(channel, &data.exp); buttons |= GetJoystickDirection(&data.exp.nunchuk.js); // Nunchuck key translations ProcessWPadButtons(channel, wpad_nunchuk); } else if( extensions == WPAD_EXP_CLASSIC ) { // Both classic controller sticks WPAD_Expansion(channel, &data.exp); buttons |= GetJoystickDirection(&data.exp.classic.ljs); buttons |= GetJoystickDirection(&data.exp.classic.rjs); // Classic controller key translations ProcessWPadButtons(channel, wpad_classic); } // Scan GameCube sticks padjoy.min.x = 0; padjoy.min.y = 0; padjoy.max.x = 255; padjoy.max.y = 255; padjoy.center.x = 128; padjoy.center.y = 128; padjoy.pos.x = (int)PAD_StickX(channel) + 128; padjoy.pos.y = (int)PAD_StickY(channel) + 128; buttons |= GetJoystickDirection(&padjoy); padjoy.pos.x = (int)PAD_SubStickX(channel) + 128; padjoy.pos.y = (int)PAD_SubStickY(channel) + 128; buttons |= GetJoystickDirection(&padjoy); return buttons; }
/**************************************************************************** * NGCReportButtons * * Called on each rendered frame * Our way of putting controller input into Snes9x ***************************************************************************/ void NGCReportButtons () { s8 gc_px = PAD_SubStickX (0); s8 gc_py = PAD_SubStickY (0); u16 gc_pb = PAD_ButtonsHeld (0); #ifdef HW_RVL s8 wm_sx = WPAD_StickX (0,1); s8 wm_sy = WPAD_StickY (0,1); u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info #endif /*** Check for video zoom ***/ if (GCSettings.NGCZoom) { if (gc_py < -36 || gc_py > 36) zoom ((float) gc_py / -36); #ifdef HW_RVL if (wm_sy < -36 || wm_sy > 36) zoom ((float) wm_sy / -36); #endif } Settings.TurboMode = ( (gc_px > 70) #ifdef HW_RVL || (wm_sx > 70) #endif ); // RIGHT on c-stick and on classic ctrlr right joystick /*** Check for menu: CStick left OR "L+R+X+Y" (eg. Hombrew/Adapted SNES controllers) OR "Home" on the wiimote or classic controller OR LEFT on classic right analog stick***/ if ((gc_px < -70) || ((gc_pb & PAD_TRIGGER_L) && (gc_pb & PAD_TRIGGER_R ) && (gc_pb & PAD_BUTTON_X) && (gc_pb & PAD_BUTTON_Y )) #ifdef HW_RVL || (wm_pb & WPAD_BUTTON_HOME) || (wm_pb & WPAD_CLASSIC_BUTTON_HOME) || (wm_sx < -70) #endif ) { ConfigRequested = 1; // go to the menu } else { int j = (Settings.MultiPlayer5Master == true ? 4 : 2); for (int i = 0; i < j; i++) decodepad (i); } }
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)); }
void CMenu::ButtonsHeld() { gc_btnsHeld = 0; for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) { wii_btnsHeld[chan] = WPAD_ButtonsHeld(chan); gc_btnsHeld |= PAD_ButtonsHeld(chan); wupc_btnsHeld[chan] = WUPC_ButtonsHeld(chan); } }
/**************************************************************************** * Controller Configuration * * Snes9x 1.50 uses a cmd system to work out which button has been pressed. * Here, I simply move the designated value to the gcpadmaps array, which saves * on updating the cmd sequences. ****************************************************************************/ u32 GetInput (u16 ctrlr_type) { u32 exp_type, pressed; pressed=0; while( PAD_ButtonsHeld(0) #ifdef HW_RVL | WPAD_ButtonsHeld(0) #endif ) VIDEO_WaitVSync(); // button 'debounce' while (pressed == 0) { VIDEO_WaitVSync(); // get input based on controller type //if (ctrlr_type == CTRLR_GCPAD) //{ pressed = PAD_ButtonsHeld (0); //} #ifdef HW_RVL //else //{ // if ( WPAD_Probe( 0, &exp_type) == 0) // check wiimote and expansion status (first if wiimote is connected & no errors) // { pressed = WPAD_ButtonsHeld (0); // if (ctrlr_type != CTRLR_WIIMOTE && exp_type != ctrlr_type+1) // if we need input from an expansion, and its not connected... // pressed = 0; // } //} #endif } // end while while( pressed == (PAD_ButtonsHeld(0) #ifdef HW_RVL | WPAD_ButtonsHeld(0) #endif ) ) VIDEO_WaitVSync(); return pressed; } // end GetInput()
/**************************************************************************** * Controller Configuration ***************************************************************************/ u32 GetInput (u16 ctrlr_type) { //u32 exp_type; u32 pressed; pressed=0; s8 gc_px = 0; while( PAD_ButtonsHeld(0) #ifdef HW_RVL | WPAD_ButtonsHeld(0) #endif ) VIDEO_WaitVSync(); // button 'debounce' while (pressed == 0) { VIDEO_WaitVSync(); // get input based on controller type if (ctrlr_type == CTRLR_GCPAD) { pressed = PAD_ButtonsHeld (0); gc_px = PAD_SubStickX (0); } #ifdef HW_RVL else { pressed = WPAD_ButtonsHeld (0); } #endif /*** check for exit sequence (c-stick left OR home button) ***/ if ( (gc_px < -70) || (pressed & WPAD_BUTTON_HOME) || (pressed & WPAD_CLASSIC_BUTTON_HOME) ) return 0; } // end while while( pressed == (PAD_ButtonsHeld(0) #ifdef HW_RVL | WPAD_ButtonsHeld(0) #endif ) ) VIDEO_WaitVSync(); return pressed; } // end GetInput()
/* * Checks to see if any buttons are held * * joys The number of joysticks to check * return Whether any of the buttons are held */ BOOL wii_is_any_button_held( int joys ) { int i; for( i = 0; i < joys; i++ ) { if( WPAD_ButtonsHeld( i ) || PAD_ButtonsHeld( i ) ) { return TRUE; } } return FALSE; }
Uint8 *WPAD_SDL_GetKeyState(int *numkeys) { WPAD_ScanPads(); u32 held = WPAD_ButtonsHeld(0); wpad_keyboard_mapping[SDLK_SPACE] = ((held & WIIMOTE_BUTTON_ONE) || (held & WIIMOTE_BUTTON_TWO)) ? 1 : 0; // Wiimote is placed sideways to play - therefore, the positions have to be changed wpad_keyboard_mapping[SDLK_LEFT] = (held & WIIMOTE_BUTTON_UP) ? 1 : 0; wpad_keyboard_mapping[SDLK_RIGHT] = (held & WIIMOTE_BUTTON_DOWN) ? 1 : 0; wpad_keyboard_mapping[SDLK_DOWN] = (held & WIIMOTE_BUTTON_LEFT) ? 1 : 0; wpad_keyboard_mapping[SDLK_UP] = (held & WIIMOTE_BUTTON_RIGHT) ? 1 : 0; wpad_keyboard_mapping[SDLK_ESCAPE] = (held & WIIMOTE_BUTTON_HOME) ? 1 : 0; wpad_keyboard_mapping[SDLK_F1] = (held & WIIMOTE_BUTTON_PLUS) ? 1 : 0; wpad_keyboard_mapping[SDLK_BACKSPACE] = (held & WIIMOTE_BUTTON_MINUS) ? 1 : 0; // Check controller for P2 held = WPAD_ButtonsHeld(1); wpad_keyboard_mapping[SDLK_LSHIFT] = ((held & WIIMOTE_BUTTON_ONE) || (held & WIIMOTE_BUTTON_TWO)) ? 1 : 0; wpad_keyboard_mapping[SDLK_a] = (held & WIIMOTE_BUTTON_UP) ? 1 : 0; wpad_keyboard_mapping[SDLK_d] = (held & WIIMOTE_BUTTON_DOWN) ? 1 : 0; return wpad_keyboard_mapping; }
u32 ButtonsHold(void) { int i; u32 buttons = 0; WUPC_UpdateButtonStats(); WPAD_ScanPads(); PAD_ScanPads(); for (i = 3; i >= 0; i--) { buttons |= WUPC_ButtonsHeld(i); buttons |= PAD_ButtonsHeld(i); buttons |= WPAD_ButtonsHeld(i); } return buttons; }
u32 GetJoy(int pad) { pad = 0; s8 gc_px = PAD_SubStickX (0); s8 gc_py = PAD_SubStickY (0); #ifdef HW_RVL s8 wm_sx = WPAD_Stick (0,1,0); s8 wm_sy = WPAD_Stick (0,1,1); u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info #endif // Check for video zoom if (GCSettings.Zoom) { if (gc_py < -36 || gc_py > 36) zoom ((float) gc_py / -36); #ifdef HW_RVL if (wm_sy < -36 || wm_sy > 36) zoom ((float) wm_sy / -36); #endif } // request to go back to menu if ((gc_px < -70) #ifdef HW_RVL || (wm_pb & WPAD_BUTTON_HOME) || (wm_pb & WPAD_CLASSIC_BUTTON_HOME) || (wm_sx < -70) #endif ) { StopAudio(); ConfigRequested = 1; return 0; } else { return DecodeJoy(pad); } }
u32 StandardDPad(unsigned short pad) { u32 J = 0; u32 jp = PAD_ButtonsHeld(pad); #ifdef HW_RVL u32 exp_type; if ( WPAD_Probe(pad, &exp_type) != 0 ) exp_type = WPAD_EXP_NONE; u32 wp = WPAD_ButtonsHeld(pad); if (wp & WPAD_BUTTON_RIGHT) J |= VBA_RIGHT; if (wp & WPAD_BUTTON_LEFT) J |= VBA_LEFT; if (wp & WPAD_BUTTON_UP) J |= VBA_UP; if (wp & WPAD_BUTTON_DOWN) J |= VBA_DOWN; if (exp_type == WPAD_EXP_CLASSIC) { if (wp & WPAD_CLASSIC_BUTTON_UP) J |= VBA_UP; if (wp & WPAD_CLASSIC_BUTTON_DOWN) J |= VBA_DOWN; if (wp & WPAD_CLASSIC_BUTTON_LEFT) J |= VBA_LEFT; if (wp & WPAD_CLASSIC_BUTTON_RIGHT) J |= VBA_RIGHT; } #endif if (jp & PAD_BUTTON_UP) J |= VBA_UP; if (jp & PAD_BUTTON_DOWN) J |= VBA_DOWN; if (jp & PAD_BUTTON_LEFT) J |= VBA_LEFT; if (jp & PAD_BUTTON_RIGHT) J |= VBA_RIGHT; return J; }
u32 StandardSideways(unsigned short pad) { u32 J = 0; #ifdef HW_RVL u32 wp = WPAD_ButtonsHeld(pad); if (wp & WPAD_BUTTON_RIGHT) J |= VBA_UP; if (wp & WPAD_BUTTON_LEFT) J |= VBA_DOWN; if (wp & WPAD_BUTTON_UP) J |= VBA_LEFT; if (wp & WPAD_BUTTON_DOWN) J |= VBA_RIGHT; if (wp & WPAD_BUTTON_PLUS) J |= VBA_BUTTON_START; if (wp & WPAD_BUTTON_MINUS) J |= VBA_BUTTON_SELECT; if (wp & WPAD_BUTTON_1) J |= VBA_BUTTON_B; if (wp & WPAD_BUTTON_2) J |= VBA_BUTTON_A; if (cartridgeType == 2) { if (wp & WPAD_BUTTON_A) J |= VBA_BUTTON_R; if (wp & WPAD_BUTTON_B) J |= VBA_BUTTON_L; } else { if (wp & WPAD_BUTTON_B || wp & WPAD_BUTTON_A) J |= VBA_SPEED; } #endif return J; }
/**************************************************************************** * FileSelector * * Let user select a file from the listing ****************************************************************************/ int FileSelector (int method) { u32 p = 0; u32 wp = 0; u32 ph = 0; u32 wh = 0; signed char gc_ay = 0; signed char gc_sx = 0; signed char wm_ay = 0; signed char wm_sx = 0; int haverom = 0; int redraw = 1; int selectit = 0; int scroll_delay = 0; bool move_selection = 0; #define SCROLL_INITIAL_DELAY 15 #define SCROLL_LOOP_DELAY 2 while (haverom == 0) { if (redraw) ShowFiles (filelist, maxfiles, offset, selection); redraw = 0; VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads gc_ay = PAD_StickY (0); gc_sx = PAD_SubStickX (0); p = PAD_ButtonsDown (0); ph = PAD_ButtonsHeld (0); #ifdef HW_RVL wm_ay = WPAD_StickY (0, 0); wm_sx = WPAD_StickX (0, 1); wp = WPAD_ButtonsDown (0); wh = WPAD_ButtonsHeld (0); #endif /*** Check for exit combo ***/ if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) ) return 0; /*** Check buttons, perform actions ***/ if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) ) { if ( selectit ) selectit = 0; if (filelist[selection].flags) // This is directory { /* update current directory and set new entry list if directory has changed */ int status = UpdateDirName(method); if (status == 1) // ok, open directory { switch (method) { case METHOD_SD: case METHOD_USB: maxfiles = ParseFATdirectory(method); break; case METHOD_DVD: maxfiles = ParseDVDdirectory(); break; case METHOD_SMB: maxfiles = ParseSMBdirectory(); break; } if (!maxfiles) { WaitPrompt ((char*) "Error reading directory !"); haverom = 1; // quit menu } } else if (status == -1) // directory name too long { haverom = 1; // quit menu } } else // this is a file { // store the filename (w/o ext) - used for state saving StripExt(romFilename, filelist[selection].filename); ShowAction ((char *)"Loading..."); switch (method) { case METHOD_SD: case METHOD_USB: LoadFATFile (filelist[selection].filename, filelist[selection].length); break; case METHOD_DVD: dvddir = filelist[selection].offset; dvddirlength = filelist[selection].length; LoadDVDFile (nesromptr); break; case METHOD_SMB: LoadSMBFile (filelist[selection].filename, filelist[selection].length); break; } if (GCMemROM() >= 0) { //hasloaded = 1; // indicator for memmap.cpp //Memory.LoadROM ("BLANK.SMC"); //Memory.LoadSRAM ("BLANK"); //haverom = 1; return 1; } else { WaitPrompt((char*) "Error loading ROM!"); } } redraw = 1; } // End of A if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) ) { while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B) #ifdef HW_RVL || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) #endif ) VIDEO_WaitVSync(); if ( strcmp(filelist[0].filename,"..") == 0 ) { selection = 0; selectit = 1; } else if ( strcmp(filelist[1].filename,"..") == 0 ) { selection = selectit = 1; } else { return 0; } } // End of B if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (gc_ay < -PADCAL) || (wm_ay < -PADCAL) ) { if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/ scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay. move_selection = 1; //continue (move selection) } else if (scroll_delay == 0) { /*** Button is held ***/ scroll_delay = SCROLL_LOOP_DELAY; move_selection = 1; //continue (move selection) } else { scroll_delay--; // wait } if (move_selection) { selection++; if (selection == maxfiles) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; move_selection = 0; } } // End of down if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (gc_ay > PADCAL) || (wm_ay > PADCAL) ) { if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/ scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay. move_selection = 1; //continue (move selection) } else if (scroll_delay == 0) { /*** Button is held ***/ scroll_delay = SCROLL_LOOP_DELAY; move_selection = 1; //continue (move selection) } else { scroll_delay--; // wait } if (move_selection) { selection--; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; move_selection = 0; } } // End of Up if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) ) { /*** Go back a page ***/ selection -= PAGESIZE; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; } if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) ) { /*** Go forward a page ***/ selection += PAGESIZE; if (selection > maxfiles - 1) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; } } return 0; }
int main(int argc,char **argv) { f32 yscale,zt = 0; u32 xfbHeight; u32 fb = 0; f32 rquad = 0.0f; u32 first_frame = 1; GXTexObj texture; Mtx view; // view and perspective matrices Mtx model, modelview; Mtx44 perspective; void *gpfifo = NULL; GXColor background = {0, 0, 0, 0xff}; guVector cam = {0.0F, 0.0F, 0.0F}, up = {0.0F, 1.0F, 0.0F}, look = {0.0F, 0.0F, -1.0F}; TPLFile crateTPL; VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); // allocate the fifo buffer gpfifo = memalign(32,DEFAULT_FIFO_SIZE); memset(gpfifo,0,DEFAULT_FIFO_SIZE); // allocate 2 framebuffers for double buffering frameBuffer[0] = SYS_AllocateFramebuffer(rmode); frameBuffer[1] = SYS_AllocateFramebuffer(rmode); // configure video VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(frameBuffer[fb]); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); fb ^= 1; // init the flipper GX_Init(gpfifo,DEFAULT_FIFO_SIZE); // clears the bg to color and clears the z buffer GX_SetCopyClear(background, 0x00ffffff); // other gx setup GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1); yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight); GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight); GX_SetDispCopyDst(rmode->fbWidth,xfbHeight); GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter); GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE)); if (rmode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetCullMode(GX_CULL_NONE); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); // setup the vertex attribute table // describes the data // args: vat location 0-7, type of data, data format, size, scale // so for ex. in the first call we are sending position data with // 3 values X,Y,Z of size F32. scale sets the number of fractional // bits for non float data. GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGB8, 0); GX_InvVtxCache(); GX_InvalidateTexAll(); TPL_OpenTPLFromMemory(&crateTPL, (void *)crate_tpl,crate_tpl_size); TPL_GetTexture(&crateTPL,crate,&texture); // setup our camera at the origin // looking down the -z axis with y up guLookAt(view, &cam, &up, &look); // setup our projection matrix // this creates a perspective matrix with a view angle of 90, // and aspect ratio based on the display resolution f32 w = rmode->viWidth; f32 h = rmode->viHeight; guPerspective(perspective, 45, (f32)w/h, 0.1F, 300.0F); GX_LoadProjectionMtx(perspective, GX_PERSPECTIVE); guVector cubeAxis = {1,1,1}; while(1) { WPAD_ScanPads(); if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0); else if (WPAD_ButtonsHeld(0)&WPAD_BUTTON_UP) zt -= 0.25f; else if (WPAD_ButtonsHeld(0)&WPAD_BUTTON_DOWN) zt += 0.25f; // set number of rasterized color channels GX_SetNumChans(1); //set number of textures to generate GX_SetNumTexGens(1); // setup texture coordinate generation // args: texcoord slot 0-7, matrix type, source to generate texture coordinates from, matrix to use GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_LoadTexObj(&texture, GX_TEXMAP0); guMtxIdentity(model); guMtxRotAxisDeg(model, &cubeAxis, rquad); guMtxTransApply(model, model, 0.0f,0.0f,zt-7.0f); guMtxConcat(view,model,modelview); // load the modelview matrix into matrix memory GX_LoadPosMtxImm(modelview, GX_PNMTX3); GX_SetCurrentMtx(GX_PNMTX3); GX_Begin(GX_QUADS, GX_VTXFMT0, 24); // Draw a Cube GX_Position3f32(-1.0f, 1.0f, -1.0f); // Top Left of the quad (top) GX_Color3f32(0.0f,1.0f,0.0f); // Set The Color To Green GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f, 1.0f, 1.0f); // Top Right of the quad (top) GX_Color3f32(0.0f,1.0f,0.0f); // Set The Color To Green GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f, -1.0f, 1.0f); // Bottom Right of the quad (top) GX_Color3f32(0.0f,1.0f,0.0f); // Set The Color To Green GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(- 1.0f, -1.0f, -1.0f); // Bottom Left of the quad (top) GX_Color3f32(0.0f,1.0f,0.0f); // Set The Color To Green GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32( 1.0f,1.0f, -1.0f); // Top Left of the quad (bottom) GX_Color3f32(1.0f,0.5f,0.0f); // Set The Color To Orange GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f,-1.0f, -1.0f); // Top Right of the quad (bottom) GX_Color3f32(1.0f,0.5f,0.0f); // Set The Color To Orange GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,-1.0f,1.0f); // Bottom Right of the quad (bottom) GX_Color3f32(1.0f,0.5f,0.0f); // Set The Color To Orange GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32( 1.0f,1.0f,1.0f); // Bottom Left of the quad (bottom) GX_Color3f32(1.0f,0.5f,0.0f); // Set The Color To Orange GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32( -1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Front) GX_Color3f32(1.0f,0.0f,0.0f); // Set The Color To Red GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Front) GX_Color3f32(1.0f,0.0f,0.0f); // Set The Color To Red GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f,-1.0f, -1.0f); // Bottom Left Of The Quad (Front) GX_Color3f32(1.0f,0.0f,0.0f); // Set The Color To Red GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32( -1.0f,-1.0f, -1.0f); // Bottom Right Of The Quad (Front) GX_Color3f32(1.0f,0.0f,0.0f); // Set The Color To Red GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32( -1.0f,1.0f,1.0f); // Bottom Left Of The Quad (Back) GX_Color3f32(1.0f,1.0f,0.0f); // Set The Color To Yellow GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); // Bottom Right Of The Quad (Back) GX_Color3f32(1.0f,1.0f,0.0f); // Set The Color To Yellow GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Back) GX_Color3f32(1.0f,1.0f,0.0f); // Set The Color To Yellow GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32( 1.0f, 1.0f,1.0f); // Top Left Of The Quad (Back) GX_Color3f32(1.0f,1.0f,0.0f); // Set The Color To Yellow GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32(1.0f, -1.0f, -1.0f); // Top Right Of The Quad (Left) GX_Color3f32(0.0f,0.0f,1.0f); // Set The Color To Blue GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32(1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Left) GX_Color3f32(0.0f,0.0f,1.0f); // Set The Color To Blue GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32(-1.0f,1.0f,-1.0f); // Bottom Left Of The Quad (Left) GX_Color3f32(0.0f,0.0f,1.0f); // Set The Color To Blue GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32(-1.0f,-1.0f, -1.0f); // Bottom Right Of The Quad (Left) GX_Color3f32(0.0f,0.0f,1.0f); // Set The Color To Blue GX_TexCoord2f32(0.0f,1.0f); GX_Position3f32( 1.0f, -1.0f,1.0f); // Top Right Of The Quad (Right) GX_Color3f32(1.0f,0.0f,1.0f); // Set The Color To Violet GX_TexCoord2f32(0.0f,0.0f); GX_Position3f32( -1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Right) GX_Color3f32(1.0f,0.0f,1.0f); // Set The Color To Violet GX_TexCoord2f32(1.0f,0.0f); GX_Position3f32( -1.0f,1.0f, 1.0f); // Bottom Left Of The Quad (Right) GX_Color3f32(1.0f,0.0f,1.0f); // Set The Color To Violet GX_TexCoord2f32(1.0f,1.0f); GX_Position3f32( 1.0f,1.0f,1.0f); // Bottom Right Of The Quad (Right) GX_Color3f32(1.0f,0.0f,1.0f); // Set The Color To Violet GX_TexCoord2f32(0.0f,1.0f); GX_End(); // Done Drawing The Quad GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetColorUpdate(GX_TRUE); GX_CopyDisp(frameBuffer[fb],GX_TRUE); GX_DrawDone(); VIDEO_SetNextFramebuffer(frameBuffer[fb]); if(first_frame) { first_frame = 0; VIDEO_SetBlack(FALSE); } VIDEO_Flush(); VIDEO_WaitVSync(); fb ^= 1; rquad -= 0.15f; // Decrease The Rotation Variable For The Quad ( NEW ) } }
static s32 read_keys(u8 port, PadDataS* pad) { CHECK_POWER_BUTTONS(); u32 b; uint16_t pad_status = 0xFFFF; //bit pointless why is this done this way? pad_t *cpad = &pads[port]; u8 pad_port = cpad->num; #ifdef HW_RVL WPADData *data; if(pads[0].type != pads[1].type && (pads[0].type == GCPAD || pads[1].type == GCPAD)) { pad_port = 0; // If Wii Remote and GC pad, then we must read from 0 on both. } if(cpad->type != GCPAD) { data = WPAD_Data(pad_port); b = WPAD_ButtonsHeld(pad_port); } else #endif b = PAD_ButtonsHeld(pad_port); if (b & cpad->R2) { pad_status &= PSX_BUTTON_R2; //b &= ~(cpad->R2); } if (b & cpad->L2) { pad_status &= PSX_BUTTON_L2; //b &= ~(cpad->L2); } if (b & cpad->R1) { pad_status &= PSX_BUTTON_R1; //b &= ~(cpad->R1); } if (b & cpad->L1) { pad_status &= PSX_BUTTON_L1; //b &= ~(cpad->L1); } if (b & cpad->START) pad_status &= PSX_BUTTON_START; if (b & cpad->SELECT) pad_status &= PSX_BUTTON_SELECT; if (b & cpad->CROSS) pad_status &= PSX_BUTTON_CROSS; if (b & cpad->CIRCLE) pad_status &= PSX_BUTTON_CIRCLE; if (b & cpad->SQUARE) pad_status &= PSX_BUTTON_SQUARE; if (b & cpad->TRIANGLE) pad_status &= PSX_BUTTON_TRIANGLE; #ifdef HW_RVL if(data->exp.type == WPAD_EXP_NUNCHUK && cpad->analog == PAD_STANDARD) { if(data->exp.nunchuk.js.pos.y > 140) pad_status &= PSX_BUTTON_DUP; if(data->exp.nunchuk.js.pos.y < 110) pad_status &= PSX_BUTTON_DDOWN; if(data->exp.nunchuk.js.pos.x < 110) pad_status &= PSX_BUTTON_DLEFT; if(data->exp.nunchuk.js.pos.x > 140) pad_status &= PSX_BUTTON_DRIGHT; } else #endif { if (b & cpad->UP) pad_status &= PSX_BUTTON_DUP; if (b & cpad->DOWN) pad_status &= PSX_BUTTON_DDOWN; if (b & cpad->LEFT) pad_status &= PSX_BUTTON_DLEFT; if (b & cpad->RIGHT) pad_status &= PSX_BUTTON_DRIGHT; } if (b & cpad->MENU) { ClosePlugins(); SysRunGui(); } if(cpad->analog == PAD_ANALOG) { switch(cpad->type) { case GCPAD: pad->leftJoyX = (u8)(PAD_StickX(pad_port)+128); pad->leftJoyY = (u8)(PAD_StickY(pad_port)+128); pad->rightJoyX = (u8)(PAD_SubStickX(pad_port)+128); pad->rightJoyY = (u8)(PAD_SubStickY(pad_port)+128); break; #ifdef HW_RVL case NUNCHAK: // or Classic if(data->exp.type == WPAD_EXP_NUNCHUK) { //TODO: Check this gforce_t gforce; WPAD_GForce(pad_port, &gforce); pad->leftJoyX = data->exp.nunchuk.js.pos.x; pad->leftJoyY = data->exp.nunchuk.js.pos.y; pad->rightJoyX = gforce.x; pad->rightJoyY = gforce.y; } else { pad->leftJoyX = (u8)(data->exp.classic.ljs.pos.x+128); pad->leftJoyY = (u8)(data->exp.classic.ljs.pos.y+128); pad->rightJoyX = (u8)(data->exp.classic.rjs.pos.x+128); pad->rightJoyY = (u8)(data->exp.classic.rjs.pos.y+128); } break; #endif } } pad->controllerType = cpad->analog; pad->buttonStatus = pad_status; // Copy Buttons return PSE_PAD_ERR_SUCCESS; }
void mainmenu (int selectedMenu) { int quit = 0; int ret; // disable game-specific menu items if a ROM isn't loaded if ( ARAM_ROMSIZE == 0 ) menuitems[3][0] = '\0'; else sprintf (menuitems[3], "Game Menu"); VIDEO_WaitVSync (); while (quit == 0) { if(selectedMenu >= 0) { ret = selectedMenu; selectedMenu = -1; // default back to main menu } else { ret = RunMenu (menuitems, menucount, (char*)"Main Menu"); } switch (ret) { case 0: // Load ROM Menu quit = LoadManager (); break; case 1: // Configure Controllers ConfigureControllers (); break; case 2: // Preferences PreferencesMenu (); break; case 3: // Game Options quit = GameMenu (); break; case 4: // Credits Credits (); WaitButtonA (); break; case 5: // Reset the Gamecube/Wii Reboot(); break; case 6: // Exit to Loader #ifdef HW_RVL #ifdef WII_DVD DI_Close(); #endif exit(0); #else // gamecube if (psoid[0] == PSOSDLOADID) PSOReload (); #endif break; case -1: // Button B // Return to Game quit = 1; break; } } /*** Remove any still held buttons ***/ #ifdef HW_RVL while( PAD_ButtonsHeld(0) || WPAD_ButtonsHeld(0) ) VIDEO_WaitVSync(); #else while( PAD_ButtonsHeld(0) ) VIDEO_WaitVSync(); #endif }
int FileSelector () { u32 p, wp, ph, wh; signed char a, c; int haverom = 0; int redraw = 1; int selectit = 0; float mag = 0; float mag2 = 0; u16 ang = 0; u16 ang2 = 0; int scroll_delay = 0; bool move_selection = 0; #define SCROLL_INITIAL_DELAY 15 #define SCROLL_LOOP_DELAY 4 while (haverom == 0) { if (redraw) ShowFiles (offset, selection); redraw = 0; VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads p = PAD_ButtonsDown (0); ph = PAD_ButtonsHeld (0); #ifdef HW_RVL wp = WPAD_ButtonsDown (0); wh = WPAD_ButtonsHeld (0); wpad_get_analogues(0, &mag, &ang, &mag2, &ang2); // get joystick info from wii expansions #else wp = 0; wh = 0; #endif a = PAD_StickY (0); c = PAD_SubStickX (0); /*** Check for exit combo ***/ if ( (c < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) ) return 0; /*** Check buttons, perform actions ***/ if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) ) { if ( selectit ) selectit = 0; if (filelist[selection].flags) /*** This is directory ***/ { if (loadtype == LOAD_SDC || loadtype == LOAD_USB) { /* memorize last entries list, actual root directory and selection for next access */ if (loadtype == LOAD_SDC) haveSDdir = 1; else haveUSBdir = 1; /* update current directory and set new entry list if directory has changed */ int status = updateFATdirname(); if (status == 1) // ok, open directory { maxfiles = parseFATdirectory(); if (!maxfiles) { WaitPrompt ((char*) "Error reading directory !"); haverom = 1; // quit SD menu if (loadtype == LOAD_SDC) // reset everything at next access haveSDdir = 0; else haveUSBdir = 0; } } else if (status == -1) // directory name too long { haverom = 1; // quit SD menu if (loadtype == LOAD_SDC) // reset everything at next access haveSDdir = 0; else haveUSBdir = 0; } } else { if ( (strcmp (filelist[selection].filename, "..") == 0) && ((unsigned int)rootdir == filelist[selection].offset) ) return 0; else { rootdir = filelist[selection].offset; rootdirlength = filelist[selection].length; offset = selection = 0; maxfiles = parsedirectory (); } } } else // this is a file { rootdir = filelist[selection].offset; rootdirlength = filelist[selection].length; /*** store the filename (used for sram/freeze naming) ***/ strip_ext(filelist[selection].filename, Memory.ROMFilename); // store stripped filename in Memory.ROMFilename switch (loadtype) { case LOAD_DVD: /*** Now load the DVD file to it's offset ***/ ARAM_ROMSIZE = LoadDVDFile (Memory.ROM); break; case LOAD_SMB: /*** Load from SMB ***/ ARAM_ROMSIZE = LoadSMBFile (filelist[selection].filename, filelist[selection].length); break; case LOAD_USB: case LOAD_SDC: /*** Load from SD Card ***/ /* memorize last entries list, actual root directory and selection for next access */ haveSDdir = 1; ARAM_ROMSIZE = LoadSDFile (filelist[selection].filename, filelist[selection].length); break; } if (ARAM_ROMSIZE > 0) { hasloaded = 1; Memory.LoadROM ("BLANK.SMC"); Memory.LoadSRAM ("BLANK"); haverom = 1; return 1; } else { WaitPrompt((char*) "Error loading ROM!"); } } redraw = 1; } // End of A if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) ) { while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B) #ifdef HW_RVL || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) #endif ) VIDEO_WaitVSync(); //if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0)) if ( strcmp(filelist[0].filename,"..") == 0 ) { selection = 0; selectit = 1; } else if ( strcmp(filelist[1].filename,"..") == 0 ) { selection = selectit = 1; } else { return 0; } } // End of B if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -PADCAL) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) ) { if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/ scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay. move_selection = 1; //continue (move selection) } else if (scroll_delay == 0) { /*** Button is held ***/ scroll_delay = SCROLL_LOOP_DELAY; move_selection = 1; //continue (move selection) } else { scroll_delay--; // wait } if (move_selection) { selection++; if (selection == maxfiles) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; move_selection = 0; } } // End of down if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > PADCAL) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) ) { if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/ scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay. move_selection = 1; //continue (move selection) } else if (scroll_delay == 0) { /*** Button is held ***/ scroll_delay = SCROLL_LOOP_DELAY; move_selection = 1; //continue (move selection) } else { scroll_delay--; // wait } if (move_selection) { selection--; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; move_selection = 0; } } // End of Up if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) ) { /*** Go back a page ***/ selection -= PAGESIZE; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; } if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) ) { /*** Go forward a page ***/ selection += PAGESIZE; if (selection > maxfiles - 1) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; } } return 0; }
void CheatMenu() { int ret = -1; int oldmenu = menu; menu = 0; int selection = 0; int offset = 0; int redraw = 1; int selectit = 0; u32 p = 0; u32 wp = 0; u32 ph = 0; u32 wh = 0; signed char gc_ay = 0; signed char gc_sx = 0; signed char wm_ay = 0; signed char wm_sx = 0; int scroll_delay = 0; bool move_selection = 0; #define SCROLL_INITIAL_DELAY 15 #define SCROLL_LOOP_DELAY 2 if(Cheat.num_cheats > 0) { cheatmenuCount = Cheat.num_cheats + 1; for(uint16 i=0; i < Cheat.num_cheats; i++) sprintf (cheatmenu[i], "%s", Cheat.c[i].name); sprintf (cheatmenu[cheatmenuCount-1], "Back to Game Menu"); while(ret != cheatmenuCount-1) { if(ret >= 0) { if(Cheat.c[ret].enabled) S9xDisableCheat(ret); else S9xEnableCheat(ret); ret = -1; } for(uint16 i=0; i < Cheat.num_cheats; i++) sprintf (cheatmenuvalue[i], "%s", Cheat.c[i].enabled == true ? "ON" : "OFF"); if (redraw) ShowCheats (cheatmenu, cheatmenuvalue, cheatmenuCount, offset, selection); redraw = 0; VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads gc_ay = PAD_StickY (0); gc_sx = PAD_SubStickX (0); p = PAD_ButtonsDown (0); ph = PAD_ButtonsHeld (0); #ifdef HW_RVL wm_ay = WPAD_StickY (0, 0); wm_sx = WPAD_StickX (0, 1); wp = WPAD_ButtonsDown (0); wh = WPAD_ButtonsHeld (0); #endif /*** Check for exit combo ***/ if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) ) break; if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) ) break; /*** Check buttons, perform actions ***/ if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) ) { if ( selectit ) selectit = 0; redraw = 1; ret = selection; } // End of A if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (gc_ay < -PADCAL) || (wm_ay < -PADCAL) ) { if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/ scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay. move_selection = 1; //continue (move selection) } else if (scroll_delay == 0) { /*** Button is held ***/ scroll_delay = SCROLL_LOOP_DELAY; move_selection = 1; //continue (move selection) } else { scroll_delay--; // wait } if (move_selection) { selection++; if (selection == cheatmenuCount) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; move_selection = 0; } } // End of down if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (gc_ay > PADCAL) || (wm_ay > PADCAL) ) { if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/ scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay. move_selection = 1; //continue (move selection) } else if (scroll_delay == 0) { /*** Button is held ***/ scroll_delay = SCROLL_LOOP_DELAY; move_selection = 1; //continue (move selection) } else { scroll_delay--; // wait } if (move_selection) { selection--; if (selection < 0) { selection = cheatmenuCount - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; move_selection = 0; } } // End of Up if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) ) { /*** Go back a page ***/ selection -= PAGESIZE; if (selection < 0) { selection = cheatmenuCount - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; } if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) ) { /*** Go forward a page ***/ selection += PAGESIZE; if (selection > cheatmenuCount - 1) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; } } } else { WaitPrompt((char*)"No cheats found!"); } menu = oldmenu; }
void mainmenu () { int quit = 0; int ret; int *psoid = (int *) 0x80001800; void (*PSOReload) () = (void (*)()) 0x80001800; if ( isWii ) sprintf (menuitems[8],"Reset Wii"); else sprintf (menuitems[8],"Reset Gamecube"); VIDEO_WaitVSync (); while (quit == 0) { ret = RunMenu (menuitems, menucount, (char*)"Main Menu"); switch (ret) { case 0: /*** Load ROM Menu ***/ quit = LoadManager (); break; case 1: /*** SRAM Manager Menu ***/ if ( ARAM_ROMSIZE > 0 ) SaveManager (); else WaitPrompt((char*) "No ROM is loaded!"); break; case 2: /*** Do Freeze / Thaw Menu ***/ if ( ARAM_ROMSIZE > 0 ) quit = FreezeManager (); else WaitPrompt((char*) "No ROM is loaded!"); break; case 3: /*** Configure Controllers ***/ ConfigureControllers (); break; case 4: /*** Emulator Options ***/ EmulatorOptions (); break; case 5: /*** Soft reset ***/ S9xSoftReset (); quit = 1; break; case 6: /*** Turn off DVD motor ***/ dvd_motor_off(); break; case 7: /*** Exit to Loader ***/ #ifdef __wii__ exit(0); #else // gamecube if (psoid[0] == PSOSDLOADID) PSOReload (); #endif break; case 8: /*** Reset the Gamecube/Wii ***/ Reboot(); break; case -1: /*** Button B ***/ case 9: /*** Return to Game ***/ quit = 1; break; } } /*** Remove any still held buttons ***/ #ifdef HW_RVL while( PAD_ButtonsHeld(0) || WPAD_ButtonsHeld(0) ) VIDEO_WaitVSync(); #else while( PAD_ButtonsHeld(0) ) VIDEO_WaitVSync(); #endif }
int FileSelector () { int p, wp; signed char a; int haverom = 0; int redraw = 1; int selectit = 0; while (haverom == 0) { if (redraw) ShowFiles (offset, selection); redraw = 0; p = PAD_ButtonsDown (0); wp = WPAD_ButtonsDown (0); a = PAD_StickY (0); if ( (p & PAD_BUTTON_A) || (wp & WPAD_BUTTON_A) || selectit ) { if ( selectit ) selectit = 0; if (filelist[selection].flags) /*** This is directory ***/ { if (loadtype == LOAD_SDC) { /* memorize last entries list, actual root directory and selection for next access */ haveSDdir = 1; /* update current directory and set new entry list if directory has changed */ int status = updateSDdirname(); if (status == 1) // ok, open directory { maxfiles = parseSDdirectory(); if (!maxfiles) { WaitPrompt ((char*) "Error reading directory !"); haverom = 1; // quit SD menu haveSDdir = 0; // reset everything at next access } } else if (status == -1) // directory name too long { haverom = 1; // quit SD menu haveSDdir = 0; // reset everything at next access } } else { if ( (strcmp (filelist[selection].filename, "..") == 0) && ((unsigned int)rootdir == filelist[selection].offset) ) return 0; else { rootdir = filelist[selection].offset; rootdirlength = filelist[selection].length; offset = selection = 0; maxfiles = parsedirectory (); } } } else // this is a file { rootdir = filelist[selection].offset; rootdirlength = filelist[selection].length; switch (loadtype) { case LOAD_DVD: /*** Now load the DVD file to it's offset ***/ ARAM_ROMSIZE = LoadDVDFile (Memory.ROM); break; case LOAD_SMB: /*** Load from SMB ***/ ARAM_ROMSIZE = LoadSMBFile (filelist[selection].filename, filelist[selection].length); break; case LOAD_SDC: /*** Load from SD Card ***/ /* memorize last entries list, actual root directory and selection for next access */ haveSDdir = 1; ARAM_ROMSIZE = LoadSDFile (filelist[selection].filename, filelist[selection].length); break; } if (ARAM_ROMSIZE > 0) { hasloaded = 1; Memory.LoadROM ("BLANK.SMC"); Memory.LoadSRAM ("BLANK"); haverom = 1; return 1; } else { WaitPrompt((char*) "Error loading ROM!"); } } redraw = 1; } // End of A if ( (p & PAD_BUTTON_B) || (wp & WPAD_BUTTON_B) ) { while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B) || (PAD_ButtonsDown(0) & WPAD_BUTTON_B) ) VIDEO_WaitVSync(); //if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0)) if ( strcmp(filelist[0].filename,"..") == 0 ) { selection = 0; selectit = 1; } else if ( strcmp(filelist[1].filename,"..") == 0 ) { selection = selectit = 1; } else { return 0; } } // End of B if ( (p & PAD_BUTTON_DOWN) || (wp & WPAD_BUTTON_DOWN) || (a < -PADCAL) ) { selection++; if (selection == maxfiles) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; } // End of down if ( (p & PAD_BUTTON_UP) || (wp & WPAD_BUTTON_UP) || (a > PADCAL) ) { selection--; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; } // End of Up if ( (PAD_ButtonsHeld(0) & PAD_BUTTON_LEFT) || (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) ) { /*** Go back a page ***/ selection -= PAGESIZE; if (selection < 0) { selection = maxfiles - 1; offset = selection - PAGESIZE + 1; } if (selection < offset) offset -= PAGESIZE; if (offset < 0) offset = 0; redraw = 1; } if ( (PAD_ButtonsHeld(0) & PAD_BUTTON_RIGHT) || (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) ) { /*** Go forward a page ***/ selection += PAGESIZE; if (selection > maxfiles - 1) selection = offset = 0; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; redraw = 1; } } return 0; }
void MainMenu () { s8 ret; u8 quit = 0; menu = 0; #ifdef HW_RVL u8 count = 6; char items[6][20] = #else u8 count = 5; char items[5][20] = #endif { {"Play Game"}, {"Hard Reset"}, {"Load New Game"}, {"Emulator Options"}, #ifdef HW_RVL {"Return to Loader"}, #endif {"System Reboot"} }; /* 50 hz TV mode */ if (gc_pal) { VIDEO_Configure (vmode); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); } /* autosave (SRAM only) */ int temp = config.freeze_auto; config.freeze_auto = -1; memfile_autosave(); config.freeze_auto = temp; while (quit == 0) { strcpy (menutitle, "Version 1.04.2"); ret = DoMenu (&items[0], count); switch (ret) { case -1: /*** Button B ***/ case 0: /*** Play Game ***/ quit = 1; break; case 1: emu_reset(); quit = 1; break; case 2: /*** Load ROM Menu ***/ quit = loadmenu(); break; case 3: /*** Emulator Options */ Emu_options(); break; case 4: /*** SD/PSO/TP Reload ***/ memfile_autosave(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); #ifdef HW_RVL DI_Close(); exit(0); break; case 5: /*** Return to Wii System Menu ***/ memfile_autosave(); VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); DI_Close(); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else SYS_ResetSystem(SYS_HOTRESET,0,0); #endif break; } } /*** Remove any still held buttons ***/ while (PAD_ButtonsHeld(0)) PAD_ScanPads(); #ifdef HW_RVL while (WPAD_ButtonsHeld(0)) WPAD_ScanPads(); #endif /*** Restore fullscreen 50hz ***/ if (gc_pal) { extern GXRModeObj TV50hz_576i; GXRModeObj *rmode = &TV50hz_576i; Mtx p; rmode->xfbHeight = 574; rmode->viYOrigin = 0; rmode->viHeight = 574; VIDEO_Configure (rmode); VIDEO_ClearFrameBuffer(rmode, xfb[whichfb], COLOR_BLACK); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); /* reset rendering mode */ GX_SetViewport (0.0F, 0.0F, rmode->fbWidth, rmode->efbHeight, 0.0F, 1.0F); GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight); f32 yScale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight); u16 xfbHeight = GX_SetDispCopyYScale (yScale); GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight); GX_SetDispCopyDst (rmode->fbWidth, xfbHeight); GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, GX_TRUE, rmode->vfilter); GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 100, 1000); GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); } #ifndef HW_RVL /*** Stop the DVD from causing clicks while playing ***/ uselessinquiry (); #endif }
void MainMenu (int selectedMenu) { tb_t start,end; mftb(&start); int quit = 0; int ret; #ifdef HW_RVL // don't show dvd motor off on the wii menuitems[5][0] = 0; // rename reset/exit items sprintf (menuitems[6], "Return to Wii Menu"); sprintf (menuitems[7], "Return to Homebrew Channel"); #endif // disable game-specific menu items if a ROM isn't loaded if (!ROMLoaded) menuitems[3][0] = '\0'; else sprintf (menuitems[3], "Game Menu"); VIDEO_WaitVSync (); while (quit == 0) { if(selectedMenu >= 0) { ret = selectedMenu; selectedMenu = -1; // default back to main menu } else { ret = RunMenu (menuitems, menucount, (char*)"Main Menu"); } switch (ret) { case 0: // Load ROM Menu quit = LoadManager (); break; case 1: // Configure Controllers ConfigureControllers (); break; case 2: // Preferences PreferencesMenu (); break; case 3: // Game Options quit = GameMenu (); break; case 4: // Credits Credits (); WaitButtonA (); break; case 5: // turn the dvd motor off (GC only) #ifdef HW_DOL dvd_motor_off (); #endif case 6: // Reset the Gamecube/Wii Reboot(); break; case 7: ExitToLoader(); break; case -1: // Button B // Return to Game if(ROMLoaded) quit = 1; break; } } // Wait for buttons to be released int count = 0; // how long we've been waiting for the user to release the button while(count < 50 && ( PAD_ButtonsHeld(0) #ifdef HW_RVL || WPAD_ButtonsHeld(0) #endif )) { VIDEO_WaitVSync(); count++; } mftb(&end); loadtimeradjust += tb_diff_msec(&end, &start); }
/* * Updates the joystick state * * joyIndex The joystick index * keyboard_data The keyboard (controls) state */ static void wii_atari_update_joystick( int joyIndex, unsigned char keyboard_data[19] ) { // Check the state of the controllers u32 down = WPAD_ButtonsDown( joyIndex ); u32 held = WPAD_ButtonsHeld( joyIndex ); u32 gcDown = PAD_ButtonsDown( joyIndex ); u32 gcHeld = PAD_ButtonsHeld( joyIndex ); // Check to see if the lightgun is enabled (lightgun only works for // joystick index 0). bool lightgun = ( lightgun_enabled && ( joyIndex == 0 ) ); if( lightgun ) { // Determine the Y offset of the lightgun location int yoffset = ( cartridge_region == REGION_NTSC ? ( NTSC_ATARI_BLIT_TOP_Y ) : ( PAL_ATARI_BLIT_TOP_Y - 28 ) ); // The number of scanlines for the current cartridge int scanlines = ( cartridge_region == REGION_NTSC ? NTSC_ATARI_HEIGHT : PAL_ATARI_HEIGHT ); wii_dbg_scanlines = scanlines; // We track the first time the lightgun is fired due to the fact that // when a catridge is launched (via the Wii7800 menu) the state of the // fire button (down) is used to determine whether the console has a // joystick or lightgun plugged in. if( lightgun_first_fire ) { if( !( held & ( WPAD_BUTTON_B | WPAD_BUTTON_A ) ) ) { // The button is not down, enable lightgun firing. lightgun_first_fire = false; } keyboard_data[3] = true; } else { keyboard_data[3] = !( held & ( WPAD_BUTTON_B | WPAD_BUTTON_A ) ); } // // TODO: These values should be cached // float yratio = ( (float)scanlines / (float)WII_HEIGHT ); float xratio = ( (float)LG_CYCLES_PER_SCANLINE / (float)WII_WIDTH ); lightgun_scanline = ( ( (float)wii_ir_y * yratio ) + ( maria_visibleArea.top - maria_displayArea.top + 1 ) + yoffset ); lightgun_cycle = ( HBLANK_CYCLES + LG_CYCLES_INDENT + ( (float)wii_ir_x * xratio ) ); if( lightgun_cycle > CYCLES_PER_SCANLINE ) { lightgun_scanline++; lightgun_cycle -= CYCLES_PER_SCANLINE; } } else { expansion_t exp; WPAD_Expansion( joyIndex, &exp ); bool isClassic = ( exp.type == WPAD_EXP_CLASSIC ); float expX = wii_exp_analog_val( &exp, TRUE, FALSE ); float expY = wii_exp_analog_val( &exp, FALSE, FALSE ); s8 gcX = PAD_StickX( joyIndex ); s8 gcY = PAD_StickY( joyIndex ); float expRjsX = 0, expRjsY = 0; s8 gcRjsX = 0, gcRjsY = 0; // Dual analog support if( cartridge_dualanalog && joyIndex == 1 ) { expansion_t exp0; WPAD_Expansion( 0, &exp0 ); if( exp0.type == WPAD_EXP_CLASSIC ) { expRjsX = wii_exp_analog_val( &exp0, TRUE, TRUE ); expRjsY = wii_exp_analog_val( &exp0, FALSE, TRUE ); } gcRjsX = PAD_SubStickX( 0 ); gcRjsY = PAD_SubStickY( 0 ); } int offset = ( joyIndex == 0 ? 0 : 6 ); // | 00 06 | Joystick 1 2 | Right keyboard_data[0 + offset] = ( held & WII_BUTTON_ATARI_RIGHT || gcHeld & GC_BUTTON_ATARI_RIGHT || wii_analog_right( expX, gcX ) || wii_analog_right( expRjsX, gcRjsX ) ); // | 01 07 | Joystick 1 2 | Left keyboard_data[1 + offset] = ( held & ( WII_BUTTON_ATARI_LEFT | ( isClassic ? WII_CLASSIC_ATARI_LEFT : 0 ) ) || gcHeld & GC_BUTTON_ATARI_LEFT || wii_analog_left( expX, gcX ) || wii_analog_left( expRjsX, gcRjsX ) ); // | 02 08 | Joystick 1 2 | Down keyboard_data[2 + offset] = ( held & WII_BUTTON_ATARI_DOWN || gcHeld & GC_BUTTON_ATARI_DOWN || wii_analog_down( expY, gcY ) || wii_analog_down( expRjsY, gcRjsY ) ); // | 03 09 | Joystick 1 2 | Up keyboard_data[3 + offset] = ( held & ( WII_BUTTON_ATARI_UP | ( isClassic ? WII_CLASSIC_ATARI_UP : 0 ) ) || gcHeld & GC_BUTTON_ATARI_UP || wii_analog_up( expY, gcY ) || wii_analog_up( expRjsY, gcRjsY ) ); // | 04 10 | Joystick 1 2 | Button 1 keyboard_data[wii_swap_buttons ? 4 + offset : 5 + offset] = ( held & ( WII_BUTTON_ATARI_FIRE | ( isClassic ? WII_CLASSIC_ATARI_FIRE : WII_NUNCHECK_ATARI_FIRE ) ) || gcHeld & GC_BUTTON_ATARI_FIRE ); // | 05 11 | Joystick 1 2 | Button 2 keyboard_data[wii_swap_buttons ? 5 + offset : 4 + offset] = ( held & ( WII_BUTTON_ATARI_FIRE_2 | ( isClassic ? WII_CLASSIC_ATARI_FIRE_2 : WII_NUNCHECK_ATARI_FIRE_2 ) ) || gcHeld & GC_BUTTON_ATARI_FIRE_2 ); } if( joyIndex == 0 ) { // | 12 | Console | Reset keyboard_data[12] = ( held & WII_BUTTON_ATARI_RESET || gcHeld & GC_BUTTON_ATARI_RESET ); // | 13 | Console | Select keyboard_data[13] = ( held & WII_BUTTON_ATARI_SELECT || gcHeld & GC_BUTTON_ATARI_SELECT ); // | 14 | Console | Pause keyboard_data[14] = ( held & WII_BUTTON_ATARI_PAUSE || gcHeld & GC_BUTTON_ATARI_PAUSE ); if( wii_diff_switch_enabled ) { // | 15 | Console | Left Difficulty if( ( diff_wait_count == 0 ) && ( ( gcDown & GC_BUTTON_ATARI_DIFFICULTY_LEFT ) || ( ( !lightgun && ( down & WII_BUTTON_ATARI_DIFFICULTY_LEFT ) ) || ( lightgun && ( down & WII_BUTTON_ATARI_DIFFICULTY_LEFT_LG ) ) ) ) ) { if( !left_difficulty_down ) { keyboard_data[15] = !keyboard_data[15]; left_difficulty_down = true; diff_display_count = prosystem_frequency * DIFF_DISPLAY_LENGTH; } } else { left_difficulty_down = false; } // | 16 | Console | Right Difficulty if( ( diff_wait_count == 0 ) && ( ( gcDown & GC_BUTTON_ATARI_DIFFICULTY_RIGHT ) || ( ( !lightgun && ( down & WII_BUTTON_ATARI_DIFFICULTY_RIGHT ) ) || ( lightgun && ( down & WII_BUTTON_ATARI_DIFFICULTY_RIGHT_LG ) ) ) ) ) { if( !right_difficulty_down ) { keyboard_data[16] = !keyboard_data[16]; right_difficulty_down = true; diff_display_count = prosystem_frequency * DIFF_DISPLAY_LENGTH; } } else { right_difficulty_down = false; } } if( ( down & WII_BUTTON_HOME ) || ( gcDown & GC_BUTTON_HOME ) || wii_hw_button ) { wii_atari_pause( true ); } } }