Ejemplo n.º 1
0
static void select_game(char *emu, char *game)
{
	extern int kiosk_mode;

	unsigned long keytimer=0;
	int keydirection=0, last_keydirection=0;

	/* No Selected game */
	strcpy(game,"builtinn");

	/* Clean screen */
	FE_DisplayScreen();

	gp2x_joystick_clear();	

	/* Wait until user selects a game */
	while(1)
	{
		game_list_view(&last_game_selected);
		FE_DisplayScreen();
       	gp2x_timer_delay(70000);

		while(1)
		{
            usleep(10000);
			gp2x_joystick_read();	

			last_keydirection=keydirection;
			keydirection=0;

			//Any keyboard key pressed?
			if(osd_is_sdlkey_pressed(pi_key[LEFT_1]) || osd_is_sdlkey_pressed(pi_key[RIGHT_1]) ||
			   osd_is_sdlkey_pressed(pi_key[UP_1]) || osd_is_sdlkey_pressed(pi_key[DOWN_1]) )
			{
				keydirection=1;
				break;
			}

			if(osd_is_sdlkey_pressed(pi_key[START_1]) || osd_is_sdlkey_pressed(pi_key[A_1]) ||
			   osd_is_sdlkey_pressed(pi_key[QUIT]) || osd_is_sdlkey_pressed(pi_key[SELECT_1]) )
			{
				break;
			}

			//Any stick direction?
			if(is_joy_axis_pressed (joyaxis_LR, 1, 0) || is_joy_axis_pressed (joyaxis_LR, 2, 0) ||
			   is_joy_axis_pressed (joyaxis_UD, 1, 0) || is_joy_axis_pressed (joyaxis_UD, 2, 0) )
			{
				keydirection=1;
				break;
			}

			//Any joy buttons pressed?
			if (ExKey1)
			{
				break;
			}

			//Used to delay the initial key press, but 
			//once pressed and held the delay will clear
			keytimer = gp2x_timer_read() + (TICKS_PER_SEC/2);

		}

		//Key delay
		if(keydirection && last_keydirection && gp2x_timer_read() < keytimer) {
			continue;
		}

		int updown=0;
		if(is_joy_axis_pressed (joyaxis_UD, 1, 0)) {last_game_selected--; updown=1;};
		if(is_joy_axis_pressed (joyaxis_UD, 2, 0)) {last_game_selected++; updown=1;};

		// Stop diagonals on game selection
		if(!updown) {
			if(is_joy_axis_pressed (joyaxis_LR, 1, 0)) last_game_selected-=21;
			if(is_joy_axis_pressed (joyaxis_LR, 2, 0)) last_game_selected+=21;
		}

		if (osd_is_sdlkey_pressed(pi_key[UP_1])) last_game_selected--;
		if (osd_is_sdlkey_pressed(pi_key[DOWN_1])) last_game_selected++;
		if (osd_is_sdlkey_pressed(pi_key[LEFT_1])) last_game_selected-=21;
		if (osd_is_sdlkey_pressed(pi_key[RIGHT_1])) last_game_selected+=21;

		if (!kiosk_mode)
		{
			if( osd_is_sdlkey_pressed(pi_key[QUIT]) || 
			    	(is_joy_button_pressed(pi_joy[START_1], ExKey1) && is_joy_button_pressed(pi_joy[SELECT_1], ExKey1)) ) {
				gp2x_exit();
			}
		}

		if (is_joy_button_pressed(pi_joy[A_1], ExKey1) || 
			osd_is_sdlkey_pressed(pi_key[A_1]) || 
			osd_is_sdlkey_pressed(pi_key[START_1]) )
		{
			/* Select the game */
			game_list_select(last_game_selected, game, emu);

			break;
		}

		if (is_joy_button_pressed(pi_joy[SELECT_1], ExKey1) || osd_is_sdlkey_pressed(pi_key[SELECT_1]) )
		{
           //Check if the game is already a favorite
            game_list_select(last_game_selected, game, emu);

            int foundfav=0;
            int counter=0;
            while(true) {
                if (favarray[counter][0] == '\0') break;    //Null is the array terminator
                if (strcasecmp(favarray[counter], game) == 0) {
                    foundfav=1;
                    break;
                }
                counter++;
            }

            if(foundfav) {
                favorites_remove(game);
            } else {
                favorites_add(game);
            }

			//Redraw and pause slightly
	        game_list_view(&last_game_selected);
			FE_DisplayScreen();
			usleep(300000);
			gp2x_joystick_clear();

		}
	}
}
Ejemplo n.º 2
0
static void select_game(char *emu, char *game)
{

	unsigned long ExKey=0;
    int keydelay=0;

	/* No Selected game */
	strcpy(game,"builtinn");

	/* Clean screen */
	gp2x_video_flip();

	if(!safe_render_path)
	   while(ExKey=gp2x_joystick_read(0)&0x8c0ff55){usleep(1000);};

	/* Wait until user selects a game */
	while(1)
	{
        
        if(local_manufacturer != global_manufacturer || local_clones != global_clones 
			|| local_filter != global_filter || local_category != global_category
            || local_year != global_year
            || local_game_list_num != game_list_num) {
            game_list_init();
            last_game_selected=0;
            local_manufacturer = global_manufacturer;
            local_clones = global_clones;
            local_filter = global_filter;
            local_category = global_category;
            local_year = global_year;
        }
        
		game_list_view(&last_game_selected);
		gp2x_video_flip();

        if(keydelay) {
            usleep(400000);
            keydelay=0;
        } 
        
        if(safe_render_path)
        {          
			if( (gp2x_joystick_read(0)&0x8c0ff55)) {
                usleep(100000);
            }
			while(!(ExKey=gp2x_joystick_read(0)&0x8c0ff55)
                  && local_manufacturer == global_manufacturer
				  && local_clones == global_clones
  			      && local_filter == global_filter
				  && local_category == global_category
                  && local_year == global_year
                  && local_game_list_num == game_list_num)
			{
                keydelay=1;
                usleep(1000);
			}
        }
        else
        {
            usleep(100000);
        	ExKey=gp2x_joystick_read(0);
        }
  
        
		if (ExKey & GP2X_UP) last_game_selected--;
		else if (ExKey & GP2X_DOWN) last_game_selected++;
		else if ((ExKey & GP2X_L) || ExKey & GP2X_LEFT) last_game_selected-=21;
		else if ((ExKey & GP2X_R) || ExKey & GP2X_RIGHT) last_game_selected+=21;
		//if ((ExKey & GP2X_L) && (ExKey & GP2X_R)) gp2x_exit();
        
        //Set or clear favorite setting for this game
        if (ExKey & GP2X_SELECT) {
            //Check if the game is already a favorite
            game_list_select(last_game_selected, game, emu);
            
            int foundfav=0;
            int counter=0;
            while(true) {
                if (favarray[counter][0] == '\0') break;	//Null is the array terminator
                if (strcasecmp(favarray[counter], game) == 0) {
                    foundfav=1;
                    break;
                }
                counter++;
            }     
            
            if(foundfav) {
                favorites_remove(game);
            } else {
                favorites_add(game);
            }
            
        }

		if (((ExKey & GP2X_A) || (ExKey & GP2X_B) || (ExKey & GP2X_PUSH) || (ExKey & GP2X_START)) && game_num_avail!=0)
		{
			/* Select the game */
			game_list_select(last_game_selected, game, emu);

			/* Emulation Options */
			//defaults!

			iOS_video_aspect=0;
			iOS_video_rotate=0;
			iOS_video_sync=0;
			iOS_frameskip=-1;
			iOS_cheat=0;
            iOS_waysStick = 8;

			if(!safe_render_path)
			{
				iOS_sound = global_sound;
				iOS_video_depth=8;
			}
			else
			{
				iOS_sound = global_sound;
				iOS_video_depth=16;
			}
			if(isIpad)
			{
				iOS_clock_cpu= 100;
				iOS_clock_sound= 100;
				iOS_buttons=2;
				iOS_sound=global_sound;
			}
			else
			{
				iOS_clock_cpu= 80;
				iOS_clock_sound= 80;
				iOS_buttons=2;
			}

			if(show_options(game))
			{
				break;
			}
            
            
		}
	}
}