コード例 #1
0
ファイル: menu_controls.cpp プロジェクト: CypherXG/UAE4Droid
static int key_controlsMenu(int *c)
{
	int end=0;
	static int delay=0;
	int left=0, right=0, up=0, down=0, hit0=0, hit1=0;
	SDL_Event event;
	delay ++;
	if (delay<5) return end;
	delay=0;

	while (SDL_PollEvent(&event) > 0)
	{
		if (event.type == SDL_KEYDOWN)
		{
			uae4all_play_click();
			switch(event.key.keysym.sym)
			{
				case SDLK_RIGHT: right=1; break;
				case SDLK_LEFT: left=1; break;
				case SDLK_UP: up=1; break;
				case SDLK_DOWN: down=1; break;
				case SDLK_PAGEDOWN: hit0=1; break;
				case SDLK_HOME: hit0=1; break;
				case SDLK_LALT: hit1=1; break;
				case SDLK_END: hit0=1; break;
				case SDLK_PAGEUP: hit0=1;
			}
		}
		if (hit0)
		{
			end = -1;
		}
		else if (hit1)
		{
			end = -1;
		}
		else if (up)
		{
			if (menuControls==7 && mainMenu_custom_dpad>0) menuControls=2;
			else if (menuControls==0) menuControls=12;
			else menuControls--;
		}
		else if (down)
		{
			if (menuControls==2 && mainMenu_custom_dpad>0) menuControls=7;
			else if (menuControls==12) menuControls=0;
			else menuControls++;
		}
		switch (menuControls)
		{
			
			case 1:
				if ((left)||(right))
						mainMenu_customControls = !mainMenu_customControls;
				break;
			case 2:
				if (left)
				{
					if (mainMenu_custom_dpad>0)
						mainMenu_custom_dpad--;
					else
						mainMenu_custom_dpad=2;
				}
				else if (right)
				{
					if (mainMenu_custom_dpad<2)
						mainMenu_custom_dpad++;
					else
						mainMenu_custom_dpad=0;
				}
				break;
			case 3:
				if (left)
				{
					if (mainMenu_custom_up>MIN_CUSTOM_ID)
						mainMenu_custom_up--;
					else
						mainMenu_custom_up=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_up<MAX_CUSTOM_ID)
						mainMenu_custom_up++;
					else
						mainMenu_custom_up=MIN_CUSTOM_ID;
				}
				break;
			case 4:
				if (left)
				{
					if (mainMenu_custom_down>MIN_CUSTOM_ID)
						mainMenu_custom_down--;
					else
						mainMenu_custom_down=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_down<MAX_CUSTOM_ID)
						mainMenu_custom_down++;
					else
						mainMenu_custom_down=MIN_CUSTOM_ID;
				}
				break;
			case 5:
				if (left)
				{
					if (mainMenu_custom_left>MIN_CUSTOM_ID)
						mainMenu_custom_left--;
					else
						mainMenu_custom_left=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_left<MAX_CUSTOM_ID)
						mainMenu_custom_left++;
					else
						mainMenu_custom_left=MIN_CUSTOM_ID;
				}
				break;
			case 6:
				if (left)
				{
					if (mainMenu_custom_right>MIN_CUSTOM_ID)
						mainMenu_custom_right--;
					else
						mainMenu_custom_right=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_right<MAX_CUSTOM_ID)
						mainMenu_custom_right++;
					else
						mainMenu_custom_right=MIN_CUSTOM_ID;
				}
				break;
			case 7:
				if (left)
				{
					if (mainMenu_custom_A>MIN_CUSTOM_ID)
						mainMenu_custom_A--;
					else
						mainMenu_custom_A=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_A<MAX_CUSTOM_ID)
						mainMenu_custom_A++;
					else
						mainMenu_custom_A=MIN_CUSTOM_ID;
				}
				break;
			case 8:
				if (left)
				{
					if (mainMenu_custom_B>MIN_CUSTOM_ID)
						mainMenu_custom_B--;
					else
						mainMenu_custom_B=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_B<MAX_CUSTOM_ID)
						mainMenu_custom_B++;
					else
						mainMenu_custom_B=MIN_CUSTOM_ID;
				}
				break;
			case 9:
				if (left)
				{
					if (mainMenu_custom_X>MIN_CUSTOM_ID)
						mainMenu_custom_X--;
					else
						mainMenu_custom_X=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_X<MAX_CUSTOM_ID)
						mainMenu_custom_X++;
					else
						mainMenu_custom_X=MIN_CUSTOM_ID;
				}
				break;
			case 10:
				if (left)
				{
					if (mainMenu_custom_Y>MIN_CUSTOM_ID)
						mainMenu_custom_Y--;
					else
						mainMenu_custom_Y=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_Y<MAX_CUSTOM_ID)
						mainMenu_custom_Y++;
					else
						mainMenu_custom_Y=MIN_CUSTOM_ID;
				}
				break;
			case 11:
				if (left)
				{
					if (mainMenu_custom_L>MIN_CUSTOM_ID)
						mainMenu_custom_L--;
					else
						mainMenu_custom_L=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_L<MAX_CUSTOM_ID)
						mainMenu_custom_L++;
					else
						mainMenu_custom_L=MIN_CUSTOM_ID;
				}
				break;
			case 12:
				if (left)
				{
					if (mainMenu_custom_R>MIN_CUSTOM_ID)
						mainMenu_custom_R--;
					else
						mainMenu_custom_R=MAX_CUSTOM_ID;
				}
				else if (right)
				{
					if (mainMenu_custom_R<MAX_CUSTOM_ID)
						mainMenu_custom_R++;
					else
						mainMenu_custom_R=MIN_CUSTOM_ID;
				}
				break;
		}
	}

	return end;
}
コード例 #2
0
ファイル: menu_load.cpp プロジェクト: CypherXG/UAE4Droid
static int menuLoadLoop(char *curr_path)
{
	char *ret = NULL, *fname = NULL;
	struct dirent **namelist;
	DIR *dir;
	int n, sel = 0;
	int sel_last = 0;
	unsigned long inp = 0;

	min_in_dir=0;
	max_in_dir=SHOW_MAX_FILES;

	// is this a dir or a full path?
	if ((dir = opendir(curr_path)))
		closedir(dir);
	else 
	{
		char *p;
		for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--);
		*p = 0;
		fname = p+1;
	}

#ifdef ANDROIDSDL
	n = scandir(curr_path, &namelist, scandir_filter, 0);
#else	
	n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);
#endif
	
	if (n < 0) 
	{
		// try root
#ifdef ANDROIDSDL
		n = scandir("/", &namelist, scandir_filter, 0);
#else
		n = scandir("/", &namelist, scandir_filter, scandir_cmp);
#endif
		if (n < 0) 
		{
			// oops, we failed
			printf("dir: "); printf(curr_path); printf("\n");
			perror("scandir");
			return 0;
		}
	}
	if (n<10) usleep(70*1024);
	else usleep(40*1024);
	// try to find sel
	if (fname != NULL) 
	{
		int i;
		for (i = 1; i < n; i++) 
		{
			if (strcmp(namelist[i]->d_name, fname) == 0) 
			{
				sel = i - 1;
				break;
			}
		}
	}

	int loaded=0;
	int delay=0;
	SDL_Event event;
	int left=0, right=0, up=0, down=0, hit0=0, hit1=0, hit2=0, hit3=0, hit4=0, hitL=0;
	while(hit0+hit1+hitL==0)
	{
		//unsigned long keys;
		draw_dirlist(curr_path, namelist, n, sel);
		delay ++;
		left=right=up=down=hit0=hit1=hit2=hit3=hit4=hitL=0;
		while (SDL_PollEvent(&event) > 0 && hit0+hit1+hitL==0)
		{
			if (event.type == SDL_KEYDOWN)
			{
				uae4all_play_click();
				switch(event.key.keysym.sym)
				{
					case SDLK_RIGHT: right=1; break;
					case SDLK_LEFT: left=1; break;
					case SDLK_UP: up=1; break;
					case SDLK_DOWN: down=1; break;
					case SDLK_PAGEDOWN: hit0=1; break;
					case SDLK_HOME: hit0=1; break;
					case SDLK_LALT: hit1=1; break;
					case SDLK_LCTRL: hit2=1; break;
					case SDLK_RSHIFT: hit3=1; break;
					case SDLK_RCTRL: hit4=1; break;
					case SDLK_END: hit0=1; break;
					case SDLK_PAGEUP: hit0=1; break;
					case SDLK_l: hitL=1;
				}
			}
			if(up)  { sel--;   if (sel < 0)   sel = n-2; /*usleep(10*1024);*/ }
			if(down)  { sel++;   if (sel > n-2) sel = 0;/*usleep(10*1024);*/}
			if(left)  { sel-=10; if (sel < 0)   sel = 0;/*usleep(10*1024);*/}
			if(hit3)     { sel-=24; if (sel < 0)   sel = 0;/*usleep(10*1024);*/}
			if(right) { sel+=10; if (sel > n-2) sel = n-2;/*usleep(10*1024);*/}
			if(hit4)     { sel+=24; if (sel > n-2) sel = n-2;/*usleep(10*1024);*/}
			if(hit2)     { run_menuFileinfo(namelist[sel+1]->d_name);}
			if(hit0 || hitL)
			{
				if (namelist[sel+1]->d_type == DT_REG) 
				{
					int df;
					int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;
					char *p; 
					char *filename;
					filename=(char*)malloc(newlen);
					strcpy(filename, curr_path);
					p = filename + strlen(filename) - 1;
					while (*p == '/' && p >= filename) *p-- = 0;
					strcat(filename, "/");
					strcat(filename, namelist[sel+1]->d_name);
					printf("Selecting file %s\n",filename);
					switch (menu_load_type)
					{
						case MENU_LOAD_FLOPPY:
							if (current_drive==0){strcpy(uae4all_image_file0,filename);extractFileName(uae4all_image_file0, filename0);df=0;}
							else if(current_drive==1) {strcpy(uae4all_image_file1,filename);extractFileName(uae4all_image_file1, filename1);df=1;}
							else if(current_drive==2) {strcpy(uae4all_image_file2,filename);extractFileName(uae4all_image_file2, filename2);df=2;}
							else if(current_drive==3) {strcpy(uae4all_image_file3,filename);extractFileName(uae4all_image_file3, filename3);df=3;}
							printf("DF0 %s\n",uae4all_image_file0);
							break;
						case MENU_LOAD_HDF:
							if (strstr(filename, ".hdf") == NULL)
								showWarning("HDF file must be selected");
							else
								strcpy(uae4all_hard_file, filename);
							break;
					}
					loaded=1;
					strcpy(currentDir,filename);
					free(filename);
					break;
				}
				else if (namelist[sel+1]->d_type == DT_DIR)
				{
					int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;
					char *p;
					char *newdir;
					/* Hard file dir is being selected ? (L-key is used to select dir) */
					if ((menu_load_type == MENU_LOAD_HD_DIR) && hitL)
					{
						strcpy(uae4all_hard_dir, curr_path);
						strcat(uae4all_hard_dir, "/");
						strcat(uae4all_hard_dir, namelist[sel+1]->d_name);
						loaded = 1;
						break;
					}
					else
					{
						newdir=(char*)malloc(newlen);
						if (strcmp(namelist[sel+1]->d_name, "..") == 0) 
						{
							char *start = curr_path;
							p = start + strlen(start) - 1;
							while (*p == '/' && p > start) p--;
							while (*p != '/' && p > start) p--;
							if (p <= start) strcpy(newdir, "/");
							else { strncpy(newdir, start, p-start); newdir[p-start] = 0; }
						} 
						else 
						{
							strcpy(newdir, curr_path);
							p = newdir + strlen(newdir) - 1;
							while (*p == '/' && p >= newdir) *p-- = 0;
							strcat(newdir, "/");
							strcat(newdir, namelist[sel+1]->d_name);
						}
						strcpy(currentDir,newdir);
						loaded = menuLoadLoop(newdir);
						free(newdir);
						break;
					}
				} 
			}
			if(hit1)
				break;
		}
	}
	if (n > 0) 
	{
		while(n--) free(namelist[n]);
		free(namelist);
	}

	return loaded;
}
コード例 #3
0
ファイル: menu_display.cpp プロジェクト: kerheol/uae4all
static int key_displayMenu(int *c)
{
	int end=0;
	static int delay=0;
	int left=0, right=0, up=0, down=0, hit0=0, hit1=0;
	delay ++;
	if (delay<5) return end;
	delay=0;

#if !defined(GCW0)
	SDL_Joystick *joy = uae4all_joy0 ;
	SDL_JoystickUpdate ();
#ifdef PANDORA
	if (     SDL_JoystickGetAxis(joy, 0) > 0) right=1;
	else if (SDL_JoystickGetAxis(joy, 0) < 0) left=1;
	else if (SDL_JoystickGetAxis(joy, 1) < 0) up=1;
	else if (SDL_JoystickGetAxis(joy, 1) > 0) down=1;
#else
	if (SDL_JoystickGetButton(joy, GP2X_BUTTON_RIGHT)) right=1;
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_LEFT)) left=1;
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_UP)) up=1;
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_DOWN)) down=1;
#endif
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_B)) hit0=1;
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_A)) hit0=1;
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_START)) {printf("Pressed Start\n");hit1=1;}
	else if (SDL_JoystickGetButton(joy, GP2X_BUTTON_X)) hit0=1;

#else

	SDL_Event event;

	while (SDL_PollEvent(&event) > 0)
	{
		printf("event.type %d\n", event.type);
		printf("event.jbutton.button %d\n", event.jbutton.button);
		if (event.type == SDL_JOYBUTTONDOWN)
		{
			switch (event.jbutton.button)
			{

			case GP2X_BUTTON_RIGHT: right=1; break;
			case GP2X_BUTTON_LEFT: left=1; break;
			case GP2X_BUTTON_UP: up=1; break;
			case GP2X_BUTTON_DOWN: down=1; break;
			case GP2X_BUTTON_B: hit0=1; break;
			case GP2X_BUTTON_START: hit1=1; break;
			case GP2X_BUTTON_X: hit0=1; break;
			case GP2X_BUTTON_A: hit0=1; break;
			}
		}
		else{
			if (event.type == SDL_KEYDOWN)
			{
				uae4all_play_click();
				switch(event.key.keysym.sym)
				{
				case SDLK_RIGHT: right=1; break;
				case SDLK_LEFT: left=1; break;
				case SDLK_UP: up=1; break;
				case SDLK_DOWN: down=1; break;
				case SDLK_RETURN:
				case SDLK_LCTRL: hit0=1; break;
				case SDLK_LALT: hit1=1; break;
				}
			}
		}
	}

#endif

		if (hit0)
		{
			end = -1;
		}
		else if (hit1)
		{
			end = -1;
		}
		else if (up)
		{
			if (menuDisplay==0) menuDisplay=8;
			else menuDisplay--;
		}
		else if (down)
		{
			if (menuDisplay==8) menuDisplay=0;
			else menuDisplay++;
		}
		switch (menuDisplay)
		{
			case 1:
				if (left)
				{
					switch(presetModeId)
					{
						case 0:
							presetModeId=7;
							strcpy(presetMode, "320x200 fullscreen");
							mainMenu_displayedLines=200;
							screenWidth = 800;
							break;
						case 1:
							presetModeId=0;
							strcpy(presetMode, "320x200 upscaled");
							mainMenu_displayedLines=200;
							screenWidth = 768;
							break;
						case 2:
							presetModeId=1;
							strcpy(presetMode, "320x216 upscaled");
							mainMenu_displayedLines=216;
							screenWidth = 716;
							break;
						case 3:
							presetModeId=2;
							strcpy(presetMode, "320x240 upscaled");
							mainMenu_displayedLines=240;
							screenWidth = 640;
							break;
						case 4:
							presetModeId=3;
							strcpy(presetMode, "320x256 upscaled");
							mainMenu_displayedLines=256;
							screenWidth = 600;
							break;
						case 5:
							presetModeId=4;
							strcpy(presetMode, "320x262 upscaled");
							mainMenu_displayedLines=262;
							screenWidth = 588;
							break;
						case 6:
							presetModeId=5;
							strcpy(presetMode, "320x270 upscaled");
							mainMenu_displayedLines=270;
							screenWidth = 570;
							break;
						case 7:
							presetModeId=6;
							strcpy(presetMode, "320x200 NTSC");
							mainMenu_displayedLines=200;
							screenWidth = 640;
							break;
					}
					update_display();
				}
				else if (right)
				{
					switch(presetModeId)
					{
						case 0:
							presetModeId=1;
							strcpy(presetMode, "320x216 upscaled");
							mainMenu_displayedLines=216;
							screenWidth = 716;
							break;
						case 1:
							presetModeId=2;
							strcpy(presetMode, "320x240 upscaled");
							mainMenu_displayedLines=240;
							screenWidth = 640;
							break;
						case 2:
							presetModeId=3;
							strcpy(presetMode, "320x256 upscaled");
							mainMenu_displayedLines=256;
							screenWidth = 600;
							break;
						case 3:
							presetModeId=4;
							strcpy(presetMode, "320x262 upscaled");
							mainMenu_displayedLines=262;
							screenWidth = 588;
							break;
						case 4:
							presetModeId=5;
							strcpy(presetMode, "320x270 upscaled");
							mainMenu_displayedLines=270;
							screenWidth = 570;
							break;
						case 5:
							presetModeId=6;
							strcpy(presetMode, "320x200 NTSC");
							mainMenu_displayedLines=200;
							screenWidth = 640;
							break;
						case 6:
							presetModeId=7;
							strcpy(presetMode, "320x200 fullscreen");
							mainMenu_displayedLines=200;
							screenWidth = 800;
							break;
						case 7:
							presetModeId=0;
							strcpy(presetMode, "320x200 upscaled");
							mainMenu_displayedLines=200;
							screenWidth = 768;
							break;
					}
					update_display();
				}
				break;
			case 2:
				if (left)
				{
					if (mainMenu_displayedLines>100)
						mainMenu_displayedLines--;
					update_display();
				}
				else if (right)
				{
					if (mainMenu_displayedLines<270)
						mainMenu_displayedLines++;
					update_display();
				}
				break;
			case 3:
				if (left)
				{
					screenWidth-=10;
					if (screenWidth<200)
						screenWidth=200;
					update_display();
				}
				else if (right)
				{
					screenWidth+=10;
					if (screenWidth>800)
						screenWidth=800;
					update_display();
				}
				break;
			case 4:
				if (left)
				{
					if (moveY>-42)
						moveY--;
				}
				else if (right)
				{
					if (moveY<50)
						moveY++;
				}
				break;
			case 5:
				if (left)
				{
					if (mainMenu_cutLeft>0)
						mainMenu_cutLeft--;
					update_display();
				}
				else if (right)
				{
					if (mainMenu_cutLeft<100)
						mainMenu_cutLeft++;
					update_display();
				}
				break;
			case 6:
				if (left)
				{
					if (mainMenu_cutRight>0)
						mainMenu_cutRight--;
					update_display();
				}
				else if (right)
				{
					if (mainMenu_cutRight<100)
						mainMenu_cutRight++;
					update_display();
				}
				break;
			case 7:
				if ((left)||(right))
						mainMenu_frameskip = !mainMenu_frameskip;
				break;
			case 8:
				if ((left)||(right))
						mainMenu_ntsc = !mainMenu_ntsc;
				break;
		}
	//}

	return end;
}
コード例 #4
0
ファイル: menu_load.cpp プロジェクト: kerheol/uae4all
static int key_loadMenu(int *c)
{
	int end=0;
	int left=0, right=0, up=0, down=0, hit0=0, hit1=0, hit2=0;
	SDL_Event event;

	while (SDL_PollEvent(&event) > 0)
	{
		if (event.type == SDL_QUIT)
			end=-1;
		else
		if (event.type == SDL_KEYDOWN)
		{
			uae4all_play_click();
			switch(event.key.keysym.sym)
			{
				case SDLK_d:
				case SDLK_RIGHT: right=1; break;
				case SDLK_a:
				case SDLK_LEFT: left=1; break;
				case SDLK_w:
				case SDLK_UP: up=1; break;
				case SDLK_s:
				case SDLK_DOWN: down=1; break;
				case SDLK_x:
				case SDLK_SPACE:
				case SDLK_c:
				case SDLK_LSHIFT: hit2=1; break;
				case SDLK_z:
				case SDLK_RETURN:
				case SDLK_e:
				case SDLK_LCTRL: hit0=1; break;
				case SDLK_q:
				case SDLK_LALT: hit1=1; break;
				case SDLK_1:
				case SDLK_TAB:
						if (text_dir_num_files)
							text_dir_num_files_index=text_dir_num_files-1;
						break;
				case SDLK_2:
				case SDLK_BACKSPACE:
						text_dir_num_files_index=0;
						break;

			}
			if ((hit0)||(hit2))
			{
				if ((text_dir_files[text_dir_num_files_index].d_type==4)||(!strcmp((char *)&text_dir_files[text_dir_num_files_index].d_name,"."))||(!strcmp((char *)&text_dir_files[text_dir_num_files_index].d_name,"..")))
				{
					char *tmp=(char *)calloc(1,512);
					strcpy(tmp,text_dir_files[text_dir_num_files_index].d_name);
					if (getFiles(tmp))
						end=-1;
					free(tmp);
				}
				else
				{
					if (hit0)
						copyCompleteName(uae4all_image_file,text_dir_num_files_index);
					else
						copyCompleteName(uae4all_image_file2,text_dir_num_files_index);
					end=1;
				}
			}
			else if (hit2)
			{
			}
			else if (hit1)
				end=-1;
			else if ((up)&&(text_dir_num_files_index>0))
				text_dir_num_files_index--;
			else if ((down)&&(text_dir_num_files_index+1!=text_dir_num_files))
				text_dir_num_files_index++;
			else if (left)
			{
				text_dir_num_files_index-=SHOW_MAX_FILES;
				if (text_dir_num_files_index<0)
					text_dir_num_files_index=0;
			}
			else if (right)
			{
				text_dir_num_files_index+=SHOW_MAX_FILES;
				if (text_dir_num_files_index+1>=text_dir_num_files)
					text_dir_num_files_index=text_dir_num_files-1;
			}
		}
	}

	return end;
}
コード例 #5
0
ファイル: menu_main.cpp プロジェクト: zear/uae4all
static enum MainMenuEntry key_mainMenu(enum MainMenuEntry *sel)
{
	SDL_Event event;

	while (SDL_PollEvent(&event) > 0)
	{
		int left = 0, right = 0, up = 0, down = 0,
		    activate = 0, cancel = 0, reset = 0, load = 0, toStates = 0;
		if (event.type == SDL_QUIT)
			return MAIN_MENU_ENTRY_EXIT_UAE;
		else if (event.type == SDL_KEYDOWN)
		{
			uae4all_play_click();
			switch(event.key.keysym.sym)
			{
				case SDLK_d:
				case SDLK_RIGHT: right = 1; break;
				case SDLK_a:
				case SDLK_LEFT: left = 1; break;
				case SDLK_w:
				case SDLK_UP: up = 1; break;
				case SDLK_s:
				case SDLK_DOWN: down = 1; break;
#ifdef DREAMCAST
				case SDLK_c:
				case SDLK_LSHIFT: load = 1; break;
				case SDLK_x:
				case SDLK_SPACE: toStates = 1; break;
				case SDLK_2:
				case SDLK_TAB: reset = 1; break;
#elif defined(GCW0)
				case SDLK_c:
				case SDLK_SPACE: toStates = 1; break;
				case SDLK_x:
				case SDLK_LSHIFT: load = 1; break;
				case SDLK_1:
				case SDLK_BACKSPACE: reset = 1; break;
#else
				case SDLK_c:
				case SDLK_LSHIFT: toStates = 1; break;
				case SDLK_x:
				case SDLK_SPACE: load = 1; break;
				case SDLK_1:
				case SDLK_BACKSPACE: reset = 1; break;
#endif
				case SDLK_z:
				case SDLK_RETURN:
				case SDLK_e:
				case SDLK_LCTRL: activate = 1; break;
				case SDLK_q:
				case SDLK_LALT: cancel = 1; break;
			}
			if (cancel && emulating)
				return MAIN_MENU_ENTRY_RETURN_TO_EMULATION;
			else if (reset)
				return MAIN_MENU_ENTRY_RESET_EMULATION;
			else if (load)
				return MAIN_MENU_ENTRY_LOAD;
			else if (toStates && emulating)
				return MAIN_MENU_ENTRY_SAVED_STATES;
			else if (up)
			{
				if (*sel > 0) *sel = (enum MainMenuEntry) ((*sel - 1) % MAIN_MENU_ENTRY_COUNT);
				else *sel = (enum MainMenuEntry) (MAIN_MENU_ENTRY_COUNT - 1);

				if(!emulating && (*sel == MAIN_MENU_ENTRY_SAVED_STATES || *sel == MAIN_MENU_ENTRY_RETURN_TO_EMULATION))
				{
					if (*sel > 0) *sel = (enum MainMenuEntry) ((*sel - 1) % MAIN_MENU_ENTRY_COUNT);
					else *sel = (enum MainMenuEntry) (MAIN_MENU_ENTRY_COUNT - 1);
				}
			}
			else if (down)
			{
				*sel = (enum MainMenuEntry) ((*sel + 1) % MAIN_MENU_ENTRY_COUNT);

				if(!emulating && (*sel == MAIN_MENU_ENTRY_SAVED_STATES || *sel == MAIN_MENU_ENTRY_RETURN_TO_EMULATION))
				{
					*sel = (enum MainMenuEntry) ((*sel + 1) % MAIN_MENU_ENTRY_COUNT);
				}
			}
			else
			{
				switch (*sel)
				{
					case MAIN_MENU_ENTRY_THROTTLE:
						if (left)
							mainMenu_throttle = (mainMenu_throttle > 0)
								? mainMenu_throttle - 1
								: 5;
						else if (right)
							mainMenu_throttle = (mainMenu_throttle + 1) % 6;
						break;
					case MAIN_MENU_ENTRY_FRAMESKIP:
						if (left)
							mainMenu_frameskip = (mainMenu_frameskip > -1)
								? mainMenu_frameskip - 1
								: 5;
						else if (right)
							mainMenu_frameskip = (mainMenu_frameskip < 5)
								? mainMenu_frameskip + 1
								: -1;
						break;
					case MAIN_MENU_ENTRY_SCREEN_POSITION:
						if (left)
							mainMenu_vpos = (mainMenu_vpos > 0)
								? mainMenu_vpos - 1
								: 5;
						else if (right)
							mainMenu_vpos = (mainMenu_vpos + 1) % 6;
						break;
					case MAIN_MENU_ENTRY_SOUND:
						if (left || right)
							mainMenu_sound = ~mainMenu_sound;
						break;
					case MAIN_MENU_ENTRY_SAVE_DISKS:
						if (left || right)
							mainMenu_autosave = ~mainMenu_autosave;
						break;
					case MAIN_MENU_ENTRY_USE_JOY:
						if (left || right)
							mainMenu_usejoy = ~mainMenu_usejoy;
						break;
					case MAIN_MENU_ENTRY_LOAD:
					case MAIN_MENU_ENTRY_SAVED_STATES:
					case MAIN_MENU_ENTRY_RESET_EMULATION:
					case MAIN_MENU_ENTRY_RETURN_TO_EMULATION:
					case MAIN_MENU_ENTRY_EXIT_UAE:
						if (activate)
							return *sel;
						break;
				}
			}
		}
	}

	return MAIN_MENU_ENTRY_NONE;
}