示例#1
0
bool GuiTrigger::Down()
{
    u32 wiibtn = WPAD_BUTTON_DOWN;

    if((wpad.btns_d | wpad.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
            || (pad.btns_d | pad.btns_h) & PAD_BUTTON_DOWN
            || pad.stickY < -PADCAL
            || WPAD_Stick(0,1) < -PADCAL)
    {
        if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_DOWN)
                || pad.btns_d & PAD_BUTTON_DOWN)
        {
            scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
            return true;
        }
        else if(scrollDelay == 0)
        {
            scrollDelay = SCROLL_LOOP_DELAY;
            return true;
        }
        else
        {
            scrollDelay--;
        }
    }
    return false;
}
示例#2
0
bool GuiTrigger::Right()
{
    u32 wiibtn = WPAD_BUTTON_RIGHT;

    if((wpad.btns_d | wpad.btns_h) & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
            || (pad.btns_d | pad.btns_h) & PAD_BUTTON_RIGHT
            || pad.stickX > PADCAL
            || WPAD_Stick(0,0) > PADCAL)
    {
        if(wpad.btns_d & (wiibtn | WPAD_CLASSIC_BUTTON_RIGHT)
                || pad.btns_d & PAD_BUTTON_RIGHT)
        {
            scrollDelay = SCROLL_INITIAL_DELAY; // reset scroll delay.
            return true;
        }
        else if(scrollDelay == 0)
        {
            scrollDelay = SCROLL_LOOP_DELAY;
            return true;
        }
        else
        {
            scrollDelay--;
        }
    }
    return false;
}
示例#3
0
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);
	}
}
示例#4
0
s8 GuiTrigger::WPAD_StickY(u8 stick)
{
	return WPAD_Stick(stick, 1);
}
示例#5
0
s8 GuiTrigger::WPAD_StickX(u8 stick)
{
	return WPAD_Stick(stick, 0);
}
示例#6
0
u32 StandardMovement(unsigned short pad)
{
	u32 J = 0;
	signed char pad_x = PAD_StickX (pad);
	signed char pad_y = PAD_StickY (pad);
	#ifdef HW_RVL
	signed char wm_ax = WPAD_Stick ((u8)pad, 0, 0);
	signed char wm_ay = WPAD_Stick ((u8)pad, 0, 1);
	#endif
	/***
	Gamecube Joystick input, same as normal
	***/
	// Is XY inside the "zone"?
	if (pad_x * pad_x + pad_y * pad_y > PADCAL * PADCAL)
	{
		if (pad_x > 0 && pad_y == 0) J |= VBA_RIGHT;
		if (pad_x < 0 && pad_y == 0) J |= VBA_LEFT;
		if (pad_x == 0 && pad_y > 0) J |= VBA_UP;
		if (pad_x == 0 && pad_y < 0) J |= VBA_DOWN;

		if (pad_x != 0 && pad_y != 0)
		{
			if ((float)pad_y / pad_x >= -2.41421356237 && (float)pad_y / pad_x < 2.41421356237)
			{
				if (pad_x >= 0)
					J |= VBA_RIGHT;
				else
					J |= VBA_LEFT;
			}

			if ((float)pad_x / pad_y >= -2.41421356237 && (float)pad_x / pad_y < 2.41421356237)
			{
				if (pad_y >= 0)
					J |= VBA_UP;
				else
					J |= VBA_DOWN;
			}
		}
	}
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	// Is XY inside the "zone"?
	if (wm_ax * wm_ax + wm_ay * wm_ay > PADCAL * PADCAL)
	{
		/*** we don't want division by zero ***/
		if (wm_ax > 0 && wm_ay == 0)
			J |= VBA_RIGHT;
		if (wm_ax < 0 && wm_ay == 0)
			J |= VBA_LEFT;
		if (wm_ax == 0 && wm_ay > 0)
			J |= VBA_UP;
		if (wm_ax == 0 && wm_ay < 0)
			J |= VBA_DOWN;

		if (wm_ax != 0 && wm_ay != 0)
		{

			/*** Recalc left / right ***/
			float t;

			t = (float) wm_ay / wm_ax;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ax >= 0)
					J |= VBA_RIGHT;
				else
					J |= VBA_LEFT;
			}

			/*** Recalc up / down ***/
			t = (float) wm_ax / wm_ay;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ay >= 0)
					J |= VBA_UP;
				else
					J |= VBA_DOWN;
			}
		}
	}

	// Turbo feature, keyboard or gamecube only
	if(DownUsbKeys[KB_SPACE])
		J |= VBA_SPEED;
	// Capture feature
	if(DownUsbKeys[KB_PRTSC] | DownUsbKeys[KB_F12])
		J |= VBA_CAPTURE;
#endif
	return J;
}
示例#7
0
/****************************************************************************
 * 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_Stick (0, 0, 0);
		wm_sx = WPAD_Stick (0, 1, 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;

				if(inSz && selection == 0) // inside a 7z, requesting to leave
				{
					if(method == METHOD_DVD)
					{
						// go to directory the 7z was in
						dvddir = filelist[0].offset;
						dvddirlength = filelist[0].length;
					}
					inSz = false;
					status = 1;
					SzClose();
				}
				else
				{
					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
			{
				// 7z file - let's open it up to select a file inside
				if(IsSz())
				{
					// we'll store the 7z filepath for extraction later
					if(!MakeROMPath(szpath, method))
					{
						WaitPrompt((char*) "Maximum filepath length reached!");
						return -1;
					}
					int szfiles = SzParse(szpath, method);
					if(szfiles)
					{
						maxfiles = szfiles;
						inSz = true;
					}
					else
						WaitPrompt((char*) "Error opening archive!");
				}
				else
				{
					// store the filename (w/o ext) - used for sram/freeze naming
					StripExt(ROMFilename, filelist[selection].filename);

					ShowAction ((char *)"Loading...");

					ROMLoaded = LoadVBAROM(method);
					inSz = false;

					if (ROMLoaded)
					{
						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;
}
示例#8
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_Stick (0, 0, 1);
			wm_sx = WPAD_Stick (0, 1, 0);
			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;
}
示例#9
0
u32 DecodeJoy(unsigned short pad)
{
	signed char pad_x = PAD_StickX (pad);
	signed char pad_y = PAD_StickY (pad);
	signed char gc_px = PAD_SubStickX (0);
	u32 jp = PAD_ButtonsHeld (pad);
	u32 J = 0;

	#ifdef HW_RVL
	signed char wm_ax = WPAD_Stick ((u8)pad, 0, 0);
	signed char wm_ay = WPAD_Stick ((u8)pad, 0, 1);
	u32 wp = WPAD_ButtonsHeld (pad);
	signed char wm_sx = WPAD_Stick (0,1,0); // CC right joystick

	u32 exp_type;
	if ( WPAD_Probe(pad, &exp_type) != 0 ) exp_type = WPAD_EXP_NONE;
	#endif

	/***
	Gamecube Joystick input
	***/
	// Is XY inside the "zone"?
	if (pad_x * pad_x + pad_y * pad_y > PADCAL * PADCAL)
	{
		if (pad_x > 0 && pad_y == 0) J |= VBA_RIGHT;
		if (pad_x < 0 && pad_y == 0) J |= VBA_LEFT;
		if (pad_x == 0 && pad_y > 0) J |= VBA_UP;
		if (pad_x == 0 && pad_y < 0) J |= VBA_DOWN;

		if (pad_x != 0 && pad_y != 0)
		{
			if ((float)pad_y / pad_x >= -2.41421356237 && (float)pad_y / pad_x < 2.41421356237)
			{
				if (pad_x >= 0)
					J |= VBA_RIGHT;
				else
					J |= VBA_LEFT;
			}

			if ((float)pad_x / pad_y >= -2.41421356237 && (float)pad_x / pad_y < 2.41421356237)
			{
				if (pad_y >= 0)
					J |= VBA_UP;
				else
					J |= VBA_DOWN;
			}
		}
	}
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	// Is XY inside the "zone"?
	if (wm_ax * wm_ax + wm_ay * wm_ay > PADCAL * PADCAL)
	{
		/*** we don't want division by zero ***/
		if (wm_ax > 0 && wm_ay == 0)
			J |= VBA_RIGHT;
		if (wm_ax < 0 && wm_ay == 0)
			J |= VBA_LEFT;
		if (wm_ax == 0 && wm_ay > 0)
			J |= VBA_UP;
		if (wm_ax == 0 && wm_ay < 0)
			J |= VBA_DOWN;

		if (wm_ax != 0 && wm_ay != 0)
		{

			/*** Recalc left / right ***/
			float t;

			t = (float) wm_ay / wm_ax;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ax >= 0)
					J |= VBA_RIGHT;
				else
					J |= VBA_LEFT;
			}

			/*** Recalc up / down ***/
			t = (float) wm_ax / wm_ay;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ay >= 0)
					J |= VBA_UP;
				else
					J |= VBA_DOWN;
			}
		}
	}
#endif

	// Turbo feature
	if(
	(gc_px > 70)
	#ifdef HW_RVL
	|| (wm_sx > 70)
	|| ((wp & WPAD_BUTTON_A) && (wp & WPAD_BUTTON_B))
	#endif
	)
		J |= VBA_SPEED;

	/*** Report pressed buttons (gamepads) ***/
	int i;

	for (i = 0; i < MAXJP; i++)
	{
		if ( (jp & gcpadmap[i])											// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & wmpadmap[i]) )	// wiimote
		|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) )	// classic controller
		|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) )	// nunchuk + wiimote
		#endif
		)
			J |= vbapadmap[i];
	}

	if ((J & 48) == 48)
		J &= ~16;
	if ((J & 192) == 192)
		J &= ~128;

	return J;
}