Example #1
0
void saverpy_input_event(EventType type, int state, void *arg) {
	if(type == E_CursorLeft)
		menu_event(E_CursorUp, state, arg);
	else if(type == E_CursorRight)
		menu_event(E_CursorDown, state, arg);
	else
		menu_event(type, state, arg);
}
Example #2
0
int event_process( int e ) {
	switch( focus_has() ) {
		case FOCUS_MENU:
			menu_event( e );
			break;
		case FOCUS_SUBMENU:
			submenu_event( e );
			break;
		case FOCUS_GAMESEL:
			game_sel_event( e );
			break;
		default:
			fprintf( stderr, "Error: Unknown focus %d\n", focus_has() );
			return -1;
			break;
	}
	return 0;
}
Example #3
0
File: sdl_env.c Project: Horsell/42
void			menu_loop(t_env *e)
{
	int		start;

	start = 0;
	while (start != 1)
	{
		while (SDL_PollEvent(&e->event))
		{
			SDL_GetWindowSize(e->win_sdl, &e->w, &e->h);
			start = menu_event(e);
			menu(e);
		}
	}
	if (e->texture)
		SDL_DestroyTexture(e->texture);
	if (e->sprite)
		SDL_FreeSurface(e->sprite);
	load_image(e, GUN);
}
Example #4
0
File: menu.c Project: AEUG/400plus
void menu_event_down()   { menu_event(MENU_EVENT_DOWN);    };
Example #5
0
static enum runloop_state runloop_check_state(
      settings_t *settings,
      uint64_t current_input,
      uint64_t old_input,
      unsigned *sleep_ms)
{
   static bool old_focus            = true;
#ifdef HAVE_OVERLAY
   static char prev_overlay_restore = false;
   bool osk_enable                  = input_driver_is_onscreen_keyboard_enabled();
#endif
#ifdef HAVE_NETWORKING
   bool tmp                         = false;
#endif
   bool focused                     = true;
   uint64_t trigger_input           = current_input & ~old_input;
   bool pause_pressed               = runloop_cmd_triggered(trigger_input, RARCH_PAUSE_TOGGLE);

   if (input_driver_is_flushing_input())
   {
      input_driver_unset_flushing_input();
      if (current_input)
      {
         current_input = 0;

         /* If core was paused before entering menu, evoke
          * pause toggle to wake it up. */
         if (runloop_paused)
            BIT64_SET(current_input, RARCH_PAUSE_TOGGLE);
         input_driver_set_flushing_input();
      }
   }

   if (runloop_cmd_triggered(trigger_input, RARCH_OVERLAY_NEXT))
      command_event(CMD_EVENT_OVERLAY_NEXT, NULL);

   if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
   {
      bool fullscreen_toggled = !runloop_paused;
#ifdef HAVE_MENU
      fullscreen_toggled = fullscreen_toggled ||
         menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
#endif

      if (fullscreen_toggled)
         command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
   }

   if (runloop_cmd_triggered(trigger_input, RARCH_GRAB_MOUSE_TOGGLE))
      command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);


#ifdef HAVE_OVERLAY
   if (osk_enable && !input_keyboard_ctl(
            RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
   {
      input_driver_unset_onscreen_keyboard_enabled();
      prev_overlay_restore  = true;
      command_event(CMD_EVENT_OVERLAY_DEINIT, NULL);
   }
   else if (!osk_enable && input_keyboard_ctl(
            RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
   {
      input_driver_set_onscreen_keyboard_enabled();
      prev_overlay_restore  = false;
      command_event(CMD_EVENT_OVERLAY_INIT, NULL);
   }
   else if (prev_overlay_restore)
   {
      if (!settings->input.overlay_hide_in_menu)
         command_event(CMD_EVENT_OVERLAY_INIT, NULL);
      prev_overlay_restore = false;
   }
#endif

   if (runloop_iterate_time_to_exit(
            runloop_cmd_press(current_input, RARCH_QUIT_KEY)) != 1)
      return RUNLOOP_STATE_QUIT;

#ifdef HAVE_MENU
   if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
   {
      menu_ctx_iterate_t iter;
      bool skip = false;
#ifdef HAVE_OVERLAY
      skip = osk_enable && input_keyboard_return_pressed();
#endif

      if (!skip)
      {
         enum menu_action action = (enum menu_action)menu_event(current_input, trigger_input);
         bool focused            = settings->pause_nonactive ? video_driver_is_focused() : true;

         focused                 = focused && !ui_companion_is_on_foreground();

         iter.action             = action;

         if (!menu_driver_ctl(RARCH_MENU_CTL_ITERATE, &iter))
            rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);

         if (focused || !runloop_idle)
            menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL);

         if (!focused)
            return RUNLOOP_STATE_SLEEP;

         if (action == MENU_ACTION_QUIT)
            return RUNLOOP_STATE_QUIT;
      }
   }
#endif
   
   if (runloop_idle)
      return RUNLOOP_STATE_SLEEP;

#ifdef HAVE_MENU
   if (menu_event_keyboard_is_set(RETROK_F1) == 1)
   {
      if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
      {
         if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
               !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
         {
            rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
            menu_event_keyboard_set(false, RETROK_F1);
         }
      }
   }
   else if ((!menu_event_keyboard_is_set(RETROK_F1) && runloop_cmd_menu_press(current_input, old_input, trigger_input)) ||
         rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
   {
      if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
      {
         if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
               !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
            rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
      }
      else
      {
        menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER);
        rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
      }
   }
   else
      menu_event_keyboard_set(false, RETROK_F1);

   if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
   {
      if (!settings->menu.throttle_framerate && !settings->fastforward_ratio)
         return RUNLOOP_STATE_MENU_ITERATE;

      return RUNLOOP_STATE_END;
   }
#endif

   if (settings->pause_nonactive)
      focused                = video_driver_is_focused();

   if (runloop_cmd_triggered(trigger_input, RARCH_SCREENSHOT))
      command_event(CMD_EVENT_TAKE_SCREENSHOT, NULL);

   if (runloop_cmd_triggered(trigger_input, RARCH_MUTE))
      command_event(CMD_EVENT_AUDIO_MUTE_TOGGLE, NULL);

   if (runloop_cmd_triggered(trigger_input, RARCH_OSK))
   {
      if (input_keyboard_ctl(
               RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
         input_keyboard_ctl(
               RARCH_INPUT_KEYBOARD_CTL_UNSET_LINEFEED_ENABLED, NULL);
      else
         input_keyboard_ctl(
               RARCH_INPUT_KEYBOARD_CTL_SET_LINEFEED_ENABLED, NULL);
   }

   if (runloop_cmd_press(current_input, RARCH_VOLUME_UP))
      command_event(CMD_EVENT_VOLUME_UP, NULL);
   else if (runloop_cmd_press(current_input, RARCH_VOLUME_DOWN))
      command_event(CMD_EVENT_VOLUME_DOWN, NULL);

#ifdef HAVE_NETWORKING
   tmp = runloop_cmd_triggered(trigger_input, RARCH_NETPLAY_FLIP);
   netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, &tmp);
   tmp = runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY);
   netplay_driver_ctl(RARCH_NETPLAY_CTL_FULLSCREEN_TOGGLE, &tmp);
#endif

   /* Check if libretro pause key was pressed. If so, pause or
    * unpause the libretro core. */

   /* FRAMEADVANCE will set us into pause mode. */
   pause_pressed |= !runloop_paused && runloop_cmd_triggered(trigger_input, RARCH_FRAMEADVANCE);

   if (focused && pause_pressed)
      command_event(CMD_EVENT_PAUSE_TOGGLE, NULL);
   else if (focused && !old_focus)
      command_event(CMD_EVENT_UNPAUSE, NULL);
   else if (!focused && old_focus)
      command_event(CMD_EVENT_PAUSE, NULL);

   old_focus = focused;

   if (!focused)
      return RUNLOOP_STATE_SLEEP;

   if (runloop_paused)
   {
      /* check pause state */

      bool check_is_oneshot = runloop_cmd_triggered(trigger_input,
            RARCH_FRAMEADVANCE)
         || runloop_cmd_press(current_input, RARCH_REWIND);
      if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
      {
         command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
         if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL))
            video_driver_cached_frame();
      }

      if (!check_is_oneshot)
         return RUNLOOP_STATE_SLEEP;
   }

   /* To avoid continous switching if we hold the button down, we require
    * that the button must go from pressed to unpressed back to pressed
    * to be able to toggle between then.
    */
   if (runloop_cmd_triggered(trigger_input, RARCH_FAST_FORWARD_KEY))
   {
      if (input_driver_is_nonblock_state())
         input_driver_unset_nonblock_state();
      else
         input_driver_set_nonblock_state();
      driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL);
   }
   else if ((runloop_cmd_pressed(old_input, RARCH_FAST_FORWARD_HOLD_KEY) 
         != runloop_cmd_press(current_input, RARCH_FAST_FORWARD_HOLD_KEY)))
   {
      if (runloop_cmd_press(current_input, RARCH_FAST_FORWARD_HOLD_KEY))
         input_driver_set_nonblock_state();
      else
         input_driver_unset_nonblock_state();
      driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL);
   }

   /* Checks if the state increase/decrease keys have been pressed 
    * for this frame. */
   if (runloop_cmd_triggered(trigger_input, RARCH_STATE_SLOT_PLUS))
   {
      char msg[128];

      msg[0] = '\0';

      settings->state_slot++;

      snprintf(msg, sizeof(msg), "%s: %d",
            msg_hash_to_str(MSG_STATE_SLOT),
            settings->state_slot);

      runloop_msg_queue_push(msg, 2, 180, true);

      RARCH_LOG("%s\n", msg);
   }
   else if (runloop_cmd_triggered(trigger_input, RARCH_STATE_SLOT_MINUS))
   {
      char msg[128];

      msg[0] = '\0';

      if (settings->state_slot > 0)
         settings->state_slot--;

      snprintf(msg, sizeof(msg), "%s: %d",
            msg_hash_to_str(MSG_STATE_SLOT),
            settings->state_slot);

      runloop_msg_queue_push(msg, 2, 180, true);

      RARCH_LOG("%s\n", msg);
   }

   if (runloop_cmd_triggered(trigger_input, RARCH_SAVE_STATE_KEY))
      command_event(CMD_EVENT_SAVE_STATE, NULL);
   else if (runloop_cmd_triggered(trigger_input, RARCH_LOAD_STATE_KEY))
      command_event(CMD_EVENT_LOAD_STATE, NULL);

#ifdef HAVE_CHEEVOS
   if (!settings->cheevos.hardcore_mode_enable)
#endif
      state_manager_check_rewind(runloop_cmd_press(current_input, RARCH_REWIND));

   runloop_slowmotion = runloop_cmd_press(current_input, RARCH_SLOWMOTION);

   if (runloop_slowmotion)
   {
      /* Checks if slowmotion toggle/hold was being pressed and/or held. */
      if (settings->video.black_frame_insertion)
      {
         if (!runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL))
            video_driver_cached_frame();
      }

      if (state_manager_frame_is_reversed())
         runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 2, 30, true);
      else
         runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION), 2, 30, true);
   }

   if (runloop_cmd_triggered(trigger_input, RARCH_MOVIE_RECORD_TOGGLE))
      bsv_movie_check();

   if (runloop_cmd_triggered(trigger_input, RARCH_SHADER_NEXT) ||
      runloop_cmd_triggered(trigger_input, RARCH_SHADER_PREV))
      dir_check_shader(
            runloop_cmd_triggered(trigger_input, RARCH_SHADER_NEXT),
            runloop_cmd_triggered(trigger_input, RARCH_SHADER_PREV));

   if (runloop_cmd_triggered(trigger_input, RARCH_DISK_EJECT_TOGGLE))
      command_event(CMD_EVENT_DISK_EJECT_TOGGLE, NULL);
   else if (runloop_cmd_triggered(trigger_input, RARCH_DISK_NEXT))
      command_event(CMD_EVENT_DISK_NEXT, NULL);
   else if (runloop_cmd_triggered(trigger_input, RARCH_DISK_PREV))
      command_event(CMD_EVENT_DISK_PREV, NULL);

   if (runloop_cmd_triggered(trigger_input, RARCH_RESET))
      command_event(CMD_EVENT_RESET, NULL);

   cheat_manager_state_checks(
         runloop_cmd_triggered(trigger_input, RARCH_CHEAT_INDEX_PLUS),
         runloop_cmd_triggered(trigger_input, RARCH_CHEAT_INDEX_MINUS),
         runloop_cmd_triggered(trigger_input, RARCH_CHEAT_TOGGLE));

   return RUNLOOP_STATE_ITERATE;
}
Example #6
0
File: menu.c Project: AEUG/400plus
void menu_event_finish() { menu_event(MENU_EVENT_FINISH);  };
Example #7
0
File: menu.c Project: AEUG/400plus
void menu_event_display(){ menu_event(MENU_EVENT_DISPLAY); };
Example #8
0
File: menu.c Project: AEUG/400plus
void menu_event_in()     { menu_event(MENU_EVENT_IN);      };
Example #9
0
File: menu.c Project: AEUG/400plus
void menu_event_av_up()  { menu_event(MENU_EVENT_AV_UP);   };
Example #10
0
File: menu.c Project: AEUG/400plus
void menu_event_dp()     { menu_event(MENU_EVENT_DP);      };
Example #11
0
File: menu.c Project: AEUG/400plus
void menu_event_jump()   { menu_event(MENU_EVENT_JUMP);    };
Example #12
0
File: menu.c Project: AEUG/400plus
void menu_event_disp()   { menu_event(MENU_EVENT_DISP);    };
Example #13
0
File: menu.c Project: AEUG/400plus
void menu_event_menu()   { menu_event(MENU_EVENT_MENU);    };
Example #14
0
int menubar_event(menubar_t *m,int event,int data)
{
	int i,processed;
#ifndef PS2
	static int msx,msy;
#endif

	load_event(&m->load,event,data);
	video_event(&m->video,event,data);
	input_event(&m->input,event,data);
	sound_event(&m->sound,event,data);
	gui_input_event(&m->guiinput,event,data);
	options_event(&m->options,event,data);
	paths_event(&m->paths,event,data);
	rom_info_event(&m->rom_info,event,data);
	tracer_event(&m->tracer,event,data);
	memory_viewer_event(&m->memory_viewer,event,data);
	about_event(&m->about,event,data);
	switch(event) {
		//mouse button pressed
		case E_MOUSEDOWN:
		case E_MOUSEDOWN2:
			if(mouseinrange(&m->info,data) == 0)
				return(0);
			//see if the click was on a menu
			for(processed=0,i=0;i<MAX_MENUS && m->menus[i].info.w;i++) {
				//send event to the menu and see if it processes it
				if(menu_event(&m->menus[i],event,data) > 0)
					processed = 1;
			}
			for(i=0;i<3;i++) {
				if(button_event(&m->buttons[i],event,data) > 0)
					processed = 1;
			}
			//if event was not processed by a menu or button, then move the window
			if(processed == 0) {
				m->ismoving = 1;
#ifndef PS2
				video_getwindowpos(&msx,&msy);
#endif
			}
			break;
		case E_MOUSEUP:
			m->ismoving = 0;
			posx = newposx;
			posy = newposy;
			//send event off to children
			for(i=0;i<MAX_MENUS && m->menus[i].info.w;i++)
				menu_event(&m->menus[i],event,data);
#ifndef PS2
			for(i=0;i<3;i++)
				button_event(&m->buttons[i],event,data);
#endif
			break;
		case E_MOUSEMOVE:
#ifndef PS2
			if(m->ismoving && config.windowed) {
				int x,y;
				mousemove_u mm;

				mm.data = data;
				video_getwindowpos(&x,&y);
//					break;
				log_message("window moving: ms x = %d, y = %d\n",msx,msy);
				log_message("window moving: window x = %d, y = %d\n",x,y);
				log_message("window moving: mouse x = %d, y = %d\n",mm.info.x,mm.info.y);
				log_message("window moving: mouse xrel = %d, yrel = %d\n",mm.info.xrel,mm.info.yrel);
				x += mm.info.xrel;
				y += mm.info.yrel;
//				SDL_GetRelativeMouseState(&newposx,&newposy);
//				newposx += posx;
//				newposy += posy;
//				newposx = mm.info.x * 3;
//				newposy = mm.info.y * 3;
//				if(newposx == posx || newposy == posy)
//					break;
				if(x == msx && y == msy)
				video_setwindowpos(x,y);
				break;
			}
#endif
			//send event off to children
			for(i=0;i<MAX_MENUS && m->menus[i].info.w;i++)
				menu_event(&m->menus[i],event,data);
			break;
	}
	return(0);
}
Example #15
0
File: menu.c Project: AEUG/400plus
void menu_event_right()  { menu_event(MENU_EVENT_RIGHT);   };
Example #16
0
File: menu.c Project: AEUG/400plus
void menu_event_left()   { menu_event(MENU_EVENT_LEFT);    };
Example #17
0
File: menu.c Project: AEUG/400plus
void menu_event_play()   { menu_event(MENU_EVENT_PLAY);    };
Example #18
0
File: menu.c Project: AEUG/400plus
void menu_event_av()     { menu_event(MENU_EVENT_AV);      };
Example #19
0
File: menu.c Project: AEUG/400plus
void menu_event_trash()  { menu_event(MENU_EVENT_TRASH);   };
Example #20
0
File: menu.c Project: AEUG/400plus
void menu_event_out()    { menu_event(MENU_EVENT_OUT);     };
Example #21
0
File: menu.c Project: AEUG/400plus
void menu_event_set()    { menu_event(MENU_EVENT_SET);     };
Example #22
0
File: menu.c Project: AEUG/400plus
void menu_event_open()   { menu_event(MENU_EVENT_OPEN);    };
Example #23
0
File: menu.c Project: AEUG/400plus
void menu_event_prev()   { menu_event(MENU_EVENT_PREV);    };
Example #24
0
File: menu.c Project: AEUG/400plus
void menu_event_refresh(){ menu_event(MENU_EVENT_REFRESH); };
Example #25
0
File: menu.c Project: AEUG/400plus
void menu_event_next()   { menu_event(MENU_EVENT_NEXT);    };
Example #26
0
File: menu.c Project: AEUG/400plus
void menu_event_save()   { menu_event(MENU_EVENT_SAVE);    };
Example #27
0
File: menu.c Project: AEUG/400plus
void menu_event_up()     { menu_event(MENU_EVENT_UP);      };