// Routine to wait for a button from either the Wiimote or a gamecube
// controller. The return value will mimic the WPAD buttons to minimize
// the amount of changes to the original code, that is expecting only
// Wiimote button presses. Note that the "HOME" button on the Wiimote
// is mapped to the "SELECT" button on the Gamecube Ctrl. (wiiNinja 5/15/2009)
u32 WaitButtons(void)
{
	u32 buttons = 0;
    u32 buttonsGC = 0;

	/* Wait for button pressing */
	while (!buttons && !buttonsGC)
    {
        // GC buttons
        buttonsGC = Pad_GetButtons ();

        // Wii buttons
		buttons = Wpad_GetButtons();

		VIDEO_WaitVSync();
	}

    if (buttonsGC)
    {
        if(buttonsGC & PAD_BUTTON_A)
        {
            //printf ("Button A on the GC controller\n");
            buttons |= WPAD_BUTTON_A;
        }
        else if(buttonsGC & PAD_BUTTON_B)
        {
            //printf ("Button B on the GC controller\n");
            buttons |= WPAD_BUTTON_B;
        }
        else if(buttonsGC & PAD_BUTTON_LEFT)
        {
            //printf ("Button LEFT on the GC controller\n");
            buttons |= WPAD_BUTTON_LEFT;
        }
        else if(buttonsGC & PAD_BUTTON_RIGHT)
        {
            //printf ("Button RIGHT on the GC controller\n");
            buttons |= WPAD_BUTTON_RIGHT;
        }
        else if(buttonsGC & PAD_BUTTON_DOWN)
        {
            //printf ("Button DOWN on the GC controller\n");
            buttons |= WPAD_BUTTON_DOWN;
        }
        else if(buttonsGC & PAD_BUTTON_UP)
        {
            //printf ("Button UP on the GC controller\n");
            buttons |= WPAD_BUTTON_UP;
        }
        else if(buttonsGC & PAD_BUTTON_START)
        {
            //printf ("Button START on the GC controller\n");
            buttons |= WPAD_BUTTON_HOME;
        }
    }

	return buttons;
} // WaitButtons
Beispiel #2
0
void Menu_Unlock() {
	u32 buttons;
	static long long t_start;
	long long t_now;
	unsigned ms_diff = 0;
	int i = 0;
	char buf[16];
	bool unlocked = false;
	memset(buf, 0, sizeof(buf));

	//init the previous settings
	if (unlock_init) {
		disable_options = CFG.disable_options;
		confirm_start = CFG.confirm_start;
		unlock_init = false;
	}
	
	Con_Clear();
	printf(gt("Configurable Loader %s"), CFG_VERSION);
	printf("\n\n");

	if (CFG.admin_mode_locked) {
		printf(gt("Enter Code: "));
		t_start = gettime();
		
		while (ms_diff < 30000 && !unlocked) {
			buttons = Wpad_GetButtons();
			if (buttons) {
				printf("*");
				buf[i] = get_unlock_buttons(buttons);
				i++;
				if (stricmp(buf, CFG.unlock_password) == 0) {
					unlocked = true;
				}
				if (i >= 10) break;
			}
			VIDEO_WaitVSync();
			t_now = gettime();
			ms_diff = diff_msec(t_start, t_now);
		}
	}
	if (unlocked) {
		//save existing settings
		disable_options = CFG.disable_options;
		confirm_start = CFG.confirm_start;

		//enable all "admin-type" screens
		CFG.disable_options = 0;
		CFG.confirm_start = 1;
		CFG.admin_mode_locked = 0;
		printf("\n\n");
		printf(gt("SUCCESS!"));
		sleep(1);
		//show the hidden games
		__Menu_GetEntries();
	} else {
		//set the lock back on
		CFG.disable_options = disable_options;
		CFG.confirm_start = confirm_start;
		CFG.admin_mode_locked = 1;
		printf("\n\n");
		printf(gt("LOCKED!"));
		sleep(1);
		//reset the hidden games
		__Menu_GetEntries();
	}
}
Beispiel #3
0
void __Menu_Controls(void)
{
	if (CFG.gui == CFG_GUI_START) {
		go_gui = true;
		goto gui_mode;
	}

	//u32 buttons = Wpad_WaitButtons();
	u32 buttons = Wpad_WaitButtonsRpt();

	/* UP/DOWN buttons */
	if (buttons & WPAD_BUTTON_UP)
		__Menu_MoveList(-1);

	if (buttons & WPAD_BUTTON_DOWN)
		__Menu_MoveList(1);

	/* LEFT/RIGHT buttons */
	if (buttons & WPAD_BUTTON_LEFT) {
		//__Menu_MoveList(-ENTRIES_PER_PAGE);
		if (CFG.cursor_jump) {
			__Menu_MoveList(-CFG.cursor_jump);
		} else {
			__Menu_MoveList((gameSelected-gameStart == 0) ? -ENTRIES_PER_PAGE : -(gameSelected-gameStart));
		}
	}

	if (buttons & WPAD_BUTTON_RIGHT) {
		//__Menu_MoveList(ENTRIES_PER_PAGE);
		if (CFG.cursor_jump) {
			__Menu_MoveList(CFG.cursor_jump);
		} else {
			__Menu_MoveList((gameSelected-gameStart == (ENTRIES_PER_PAGE - 1)) ? ENTRIES_PER_PAGE : ENTRIES_PER_PAGE - (gameSelected-gameStart) - 1);
		}
	}

	check_buttons:


	if (CFG.admin_lock) {
		if (buttons & CFG.button_other.mask) {

			static long long t_start;
			long long t_now;
			unsigned ms_diff = 0;
			bool display_unlock = false;

			Con_Clear();
			t_start = gettime();
			while (!display_unlock && (Wpad_Held(0) & CFG.button_other.mask)) {
				buttons = Wpad_GetButtons();
				VIDEO_WaitVSync();
				t_now = gettime();
				ms_diff = diff_msec(t_start, t_now);
				if (ms_diff > 5000)
					display_unlock = true;
			}
			if (display_unlock)
				Menu_Unlock();
			else
				buttons = buttonmap[MASTER][CFG.button_other.num];
		}
	}

	/* A button */
	//if (buttons & CFG.button_confirm.mask)
	//	Menu_Boot(0);

	int i;
	for (i = 4; i < MAX_BUTTONS; i++) {
			if (buttons & buttonmap[MASTER][i]) 
				DoAction(*(&CFG.button_M + (i - 4)));
	}
		
	//if (buttons & CFG.button_cancel.mask)
	//	DoAction(CFG.button_B);

	///* HOME button */
	//if (buttons & CFG.button_exit.mask) {
	//	DoAction(CFG.button_H);
	//	//Handle_Home(1);
	//}

	///* PLUS (+) button */
	//if (buttons & WPAD_BUTTON_PLUS)
	//	DoAction(CFG.button_P);
	////	Menu_Install();

	///* MINUS (-) button */
	//if (buttons & WPAD_BUTTON_MINUS)
	//	DoAction(CFG.button_M);
	////	Menu_Views();
	////	Menu_Remove();

	//if (buttons & WPAD_BUTTON_2)
	//	DoAction(CFG.button_2);

	//if (buttons & CFG.button_other.mask)
	//	DoAction(CFG.button_1);

	//if (buttons & WPAD_BUTTON_X)
	//	DoAction(CFG.button_X);

	//if (buttons & WPAD_BUTTON_Y)
	//	DoAction(CFG.button_Y);

	//if (buttons & WPAD_BUTTON_Z)
	//	DoAction(CFG.button_Z);

	//if (buttons & WPAD_BUTTON_C)
	//	DoAction(CFG.button_C);

	//if (buttons & WPAD_BUTTON_L)
	//	DoAction(CFG.button_L);

	//if (buttons & WPAD_BUTTON_R)
	//	DoAction(CFG.button_R);

	//// button 2 - switch favorites
	//if (buttons & CFG.button_save.mask) {
	//	extern void reset_sort_default();
	//	reset_sort_default();
	//	Switch_Favorites(!enable_favorite);
	//}


	//if (CFG.gui) {
	//	if (CFG.buttons == CFG_BTN_OPTIONS_1) {
	//		if (buttons & CFG.button_cancel.mask) go_gui = true;
	//	} else if (CFG.buttons == CFG_BTN_OPTIONS_B) {
	//		if (buttons & CFG.button_other.mask) go_gui = true;
	//	}
	//}
	//if (!CFG.disable_options) {
	//	if (CFG.buttons == CFG_BTN_OPTIONS_1) {
	//		if (buttons & CFG.button_other.mask) Menu_Options();
	//	} else if (CFG.buttons == CFG_BTN_OPTIONS_B) {
	//		if (buttons & CFG.button_cancel.mask) Menu_Options();
	//	} else { 
	//		/* ONE (1) button */
	//		if (buttons & CFG.button_other.mask) {
	//			//Menu_Device();
	//			Menu_Options();
	//		}
	//	}
	//}
	
	if (go_gui) {
		gui_mode:;
		int prev_sel = gameSelected;
		CFG.gui = 1; // disable auto start
		buttons = Gui_Mode();
		if (prev_sel != gameSelected) {
			// List scrolling
			__Menu_ScrollStartList();
		}
		// if only returning to con mode, clear button status
		/*if (CFG.buttons == CFG_BTN_OPTIONS_1) {
			if (buttons & CFG.button_cancel.mask) buttons = 0;
		} else if (CFG.buttons == CFG_BTN_OPTIONS_B) {
			if (buttons & CFG.button_other.mask) buttons = 0;
		}
		*/
		// if action started from gui, process it then return to gui
		//if (buttons) {
		//	go_gui = true;
		goto check_buttons;
		//}
	}
}