Beispiel #1
0
void maybe_complete_pause(GLFWwindow *window)
{
    /* In a finished app, there's usually still things to update and render when
    paused, but this function is good for initial prototyping / debugging. */
    if (toggle_pause(window)) {
        while (!(glfwWindowShouldClose(window) || toggle_pause(window))) {
            glfwWaitEvents();
        }
    }
}
Beispiel #2
0
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    // Get render_state from GLFW user pointer
    render_t *render_state = glfwGetWindowUserPointer(window);

    if(action == GLFW_PRESS || action == GLFW_REPEAT)
    {

        // Let renderer know of activity
        set_activity_time(render_state);

        switch(key)
        { 
            case GLFW_KEY_ESCAPE:
                toggle_quit_mode(render_state);              
	        break;
            case GLFW_KEY_RIGHT:
                increase_parameter(render_state);
                break;
            case GLFW_KEY_LEFT:
                decrease_parameter(render_state);
                break;
            case GLFW_KEY_UP:
                move_parameter_up(render_state);
                break;
            case GLFW_KEY_DOWN:
                move_parameter_down(render_state);
                break;
            case GLFW_KEY_LEFT_BRACKET:
                remove_partition(render_state);
                break;
            case GLFW_KEY_RIGHT_BRACKET:
                add_partition(render_state);
                break;
            case GLFW_KEY_X:
                set_fluid_x(render_state);
                break;
            case GLFW_KEY_Y:
                set_fluid_y(render_state);
                break;
            case GLFW_KEY_A:
                if(render_state->quit_mode)
                    exit_with_selected_program(render_state, window);
                set_fluid_a(render_state);
                break;
            case GLFW_KEY_B:
                set_fluid_b(render_state);
                break;
            case GLFW_KEY_D:
                toggle_dividers(render_state);
                break;
            case GLFW_KEY_P:
                toggle_pause(render_state);
                break;
            case GLFW_KEY_L:
                toggle_liquid(render_state);
                break;
        }
    }
}
Beispiel #3
0
static void handle_keypress(int key, camera *camera) {
  switch(key) {
    case SDLK_LEFT:
      move_camera(camera, -arrows_camera_delta * ZOOM_LEVEL, 0);
      break;
    case SDLK_RIGHT:
      move_camera(camera, arrows_camera_delta * ZOOM_LEVEL, 0);
      break;
    case SDLK_UP:
      move_camera(camera, 0, -arrows_camera_delta * ZOOM_LEVEL);
      break;
    case SDLK_DOWN:
      move_camera(camera, 0, arrows_camera_delta * ZOOM_LEVEL);
      break;
    case SDLK_PAGEUP:
      zoom_in(camera);
      update_background();
      break;
    case SDLK_PAGEDOWN:
      zoom_out(camera);
      update_background();
      break;
    case SDLK_p:
      toggle_pause();
  }
}
	void FFVideo::play()
	{
		if (isOpen() && is_stream_pause((VideoState*)_ctx) && !isSeeking())
		{
			toggle_pause((VideoState*)_ctx);
		}
	}
Beispiel #5
0
ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
{
	connect (SkinManager::instance (), SIGNAL (skinChanged (Skin *)),
	         this, SLOT (setPixmaps(Skin *)));

	const XClient *client = App->client ();

	setFixedSize (275, 14);

	m_mw = qobject_cast<MainWindow *>(parent);

	m_tbar = new TitleBar(this, true);
	m_tbar->move (0, 0);

	m_time = new SmallTimeDisplay (this);
	m_time->move (130, 4);
	connect (m_time, SIGNAL(clicked()), App, SLOT(toggleTime()));

	m_title = new TextScroller (this, 39, 7, "shaded");
	m_title->move (79, 4);

	m_prev = new PixmapButton (this);
	m_prev->move(169, 4);
	m_prev->resize (8, 7);
	connect (m_prev, SIGNAL(clicked()), client->xplayback (), SLOT(prev ()));

	m_play = new PixmapButton (this);
	m_play->move(177, 4);
	m_play->resize (10, 7);
	connect (m_play, SIGNAL(clicked()), client->xplayback (), SLOT(play ()));

	m_pause = new PixmapButton (this);
	m_pause->move(187, 4);
	m_pause->resize (10, 7);
	connect (m_pause, SIGNAL(clicked()),
	         client->xplayback (), SLOT(toggle_pause ()));

	m_stop = new PixmapButton (this);
	m_stop->move(197, 4);
	m_stop->resize (9, 7);
	connect (m_stop, SIGNAL(clicked()), client->xplayback (), SLOT(stop ()));

	m_next = new PixmapButton (this);
	m_next->move(206, 4);
	m_next->resize (8, 7);
	connect (m_next, SIGNAL(clicked()), client->xplayback (), SLOT(next ()));

	m_eject = new PixmapButton (this);
	m_eject->move(216, 4);
	m_eject->resize (9, 7);
	connect (m_eject, SIGNAL(clicked()), this, SLOT(fileOpen()));

	connect (client->xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
	         this, SLOT(setStatus(Xmms::Playback::Status)));
	connect (client->cache (), SIGNAL (playtime (uint32_t)),
	         this, SLOT ( setPlaytime(uint32_t)));
	connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)),
	         this, SLOT (setMediainfo (QVariantHash)));
}
void DBSearch::stop()
{
    if (is_paused())
        toggle_pause();        
    if (!_working)
        return;
    _stop = true;
    while (_working);
    _state = "Cancelled";
}
Beispiel #7
0
void MotionMenu::_call (int N)
{
    logger.debug() << "selected choice "  << N |0;
    switch (N) {
        case 0: animator->shift_channels();        break;
        case 1: animator->toggle_drifting();       break;
        case 2: animator->toggle_stopped();        break;
        case 3: animator->toggle_centered();       break;
        case 4: animator->invert();                break;
        case 5: animator->set_center();            break;
        case 6: animator->slow_down();             break;
        case 7: animator->speed_up();              break;
        case 8: animator->reset();
                projector->pan_center();               break;
        case 9: toggle_pause();                   break;
        default: delete this;
    }
}
//State Machine Definitions
int tickFct_Keypad(int state) {
    char key = GetKeypadKey();
    switch(state) {
    case keypad_start:
        state = keypad_poll;
        break;
    case keypad_poll:
        state = keypad_poll;
        break;
    }
    switch(state) {
    case keypad_start:
        break;
    case keypad_poll:
        switch(key) {
        case '\0':
            break;
        case '1':
            if( gameover == OFF ) {
                toggle_pause();
            }
            else if( gameover == ON ) {
                restart_game();
            }
            break;
        case '4':
            if( gameover == OFF ) {
                move_player(PLAYER_TOP);
            }
            break;
        case '7':
            if( gameover == OFF ) {
                move_player(PLAYER_BOT);
            }
            break;
        default:
            break;
        }
        break;
    }
    return state;
}
Beispiel #9
0
static void handle_mousedown(SDL_MouseButtonEvent button_event, camera *camera, PLAYERS *players) {
  bool modifier = (SDL_GetModState() & KMOD_CTRL) > 0;
  gsl_vector *dest;

  int rel_map_size = MAP_SIZE / ZOOM_LEVEL;
  int start_x = (WIDTH - rel_map_size) / 2;
  int end_x = WIDTH - start_x;
  int start_y = (HEIGHT - rel_map_size) / 2;
  int end_y = HEIGHT - start_y;

  if(button_event.x > end_x || button_event.x < start_x ||
      button_event.y > end_y || button_event.y < start_y)
    return;

  switch(button_event.button) {
    case 1:
      if(paused)
        toggle_pause();
      select_units_at(modifier, button_event.x, button_event.y, camera, players);
      break;
    case 3:
      dest = calculate_map_position(button_event.x, button_event.y, camera);
      unit *un = check_for_unit_near(dest, players, NULL, false, true);
      if(un != NULL) {
        selected_units_attack(un);
      } else {
        move_selected_units_to(dest, players);
      }
      gsl_vector_free(dest);
      break;
    case 4:
      zoom_in(camera);
      update_background();
      break;
    case 5:
      zoom_out(camera);
      update_background();
  }
}
void DBSearch::count()
{
    run(boost::bind(&DBSearch::count_data, this, _1, _2, _3, _4, _5, _6));
};

void DBSearch::run(select_func_t select_func)
{
    struct working_state_guard
    {
        volatile bool& _state;
        working_state_guard(volatile bool& state) : _state(state) {}
        ~working_state_guard() { _state = false; }
    };
    working_state_guard w(_working);
    if (is_paused())
        toggle_pause();
    _starting = false;
    _working = true;
    _stop = false;
    _limit_counter = _limit_total?_limit_total:-1;
    _state = "Fetch schema list";
    _searched_tables = 0;
    _matched_rows = 0;
    std::map<std::string, std::vector<std::string> > schemas;
    std::map<std::string, std::vector<std::string> > schemas_tables;
    {
        boost::scoped_ptr<sql::Statement> stmt(_db_conn->createStatement());
        for(size_t count= _filter_list.count(), i= 0; i < count; i++)
        {
            wait_if_paused();
            if (_stop)
Beispiel #11
0
/**
 * The main loop of game
 * @return TRUE if it completed successfully or FALSE otherwise
 */
bool
update_frame (void)
{
  spaceship_struct *ship = spaceship_get ();
#ifdef DEVELOPPEMENT
  /* 1 = phase grid editor enable (don't work) */
  static bool grid_editor = FALSE;
#endif
  /* global frame counter */
  global_counter++;

  /* play start and congratulations animations files
   * ("movie_congratulation.gca" and "movie_introduction.gca") */
  if (movie_playing_switch != MOVIE_NOT_PLAYED)
    {
      if (!movie_player ())
        {
          LOG_ERR ("movie_player() failed!");
          return FALSE;
        }
      else
        {
          return TRUE;
        }
    }

  display_clear_offscreen ();

#ifdef __EMSCRIPTEN__
  lock_surface_game ();
  lock_surface_options ();
  lock_surface_scores ();
#endif

  /* restores the level of energy of the player spaceship */
  spaceship_energy_restore ();

  /* phase grid and curve phase editor (don't work) */
#ifdef DEVELOPPEMENT
  if (grid_editor || curve_editor_enable)
    {
      if (grid_editor)
        {
          Grid_Edit ();
        }
      else
        {
          courbe_editeur ();
        }
    }
  else
#endif

    /* pause or main menu enable */
  if (!player_pause && menu_status == MENU_OFF &&
        menu_section == NO_SECTION_SELECTED)
    {
      /* 
       * handle the phases of the game 
       */
      /* phase 2: grids (enemy wave like Space Invaders) */
      grid_handle ();
      /* phase 1: curves (little skirmish) */
      curve_phase ();
      /* phase 3: meteor storm */
      meteors_handle ();
    }

  /* draw the starfield background */
  starfield_handle ();

  /* handle bonus: green, red, yellow, blue and purple gems */
  bonus_handle ();

  /* handle protection satellites and extra gun of the player spaceship  */
  if (!gameover_enable && menu_section == NO_SECTION_SELECTED)
    {
      /* orbital protection satellites gravitate around player's spaceship */
      satellites_handle ();
      /* extra gun positioned on the sides */
      guns_handle ();
    }

  /* handle enemies */
  if (!is_congratulations_enabled)
    {
      /* handling of all the possible types of enemies */
      enemies_handle ();
    }
  else
    {
      /* congratulations, end of the game */
      congratulations ();
    }

  /* spaceship temporary invincibility  */
  spaceship_invincibility ();

  /* handle the powerful electrical shocks */
  electrical_shock ();

  /* draw the player's spaceship */
  spaceship_draw ();

  /* handle explosions */
  explosions_handle ();

  /* handle shots */
  shots_handle ();

  /* wait until all enemies are dead before jumping on next phase */
  if (num_of_enemies == 0 && !player_pause && menu_status == MENU_OFF
      && menu_section == NO_SECTION_SELECTED)
    {
      /* end of a guardian phase? */
      if (!guardian_finished ())
        {
          LOG_ERR ("guardian_finished() failed!");
          return FALSE;
        }
      /* check if curve phase is finished */
      curve_finished ();
      /* check if grid phase is finished */
      grid_finished ();
      /* check if meteors phase is finished */
      if (!meteors_finished ())
        {
          LOG_ERR ("meteors_finished failed!");
          return FALSE;
        }
    }

  /* display pixel mouse pointer */
#ifdef DEVELOPPEMENT
  if (mouse_here)
    {
      put_pixel (game_offscreen, mouse_x, mouse_y, 5);
    }
#endif

  /* draw powerful circular shock wave propagated by the player spaceship */
  shockwave_draw ();

  /* animations of the options box on the right options panel */
  option_execution ();

  /* handle high score table, game over, about and order sections */
  menu_sections_run ();

  /* display "PAUSE" chars sprites */
  if (is_pause_draw)
    {
      text_pause_draw ();
    }

  /* player's spaceship come */
  if (spaceship_appears_count > 0)
    {
      spaceship_appears_count--;
      /* accelerate the speed of the starfield */
      starfield_speed += 0.028f;
      if (starfield_speed > 2.0)
        {
          starfield_speed = 2.0;
        }
      /* invincibility time */
      spaceship_set_invincibility (SPACESHIP_INVINCIBILITY_TIME / 3);
    }

  /* player's spaceship disappearing to the bottom of the screen. */
  if (spaceship_disappears && is_congratulations_enabled == 0)
    {
      /* decelerate the speed of the starfield */
      starfield_speed -= 0.02f;
      if (starfield_speed <= 0.0)
        {
          starfield_speed = 0.0;
          ship->y_speed = 0.0;
        }
      else
        {
          /* accelerate the speed of the spaceship */
          ship->y_speed += -0.15f;
        }
    }

  /* display number level */
  text_level_draw ();

  /* display scrolltext in the main menu */
  scrolltext_handle ();

  /* handle the main menu of Powermanga */
  menu_handle ();

  /* [F1] spaceship_appears / [F2] spaceship disappears */
#ifdef DEVELOPPEMENT
  if (keys_down[K_F1])
    {
      spaceship_disappears = 1;
    }
  if (keys_down[K_F2] && starfield_speed == 0.0)
    {
      spaceship_show ();
    }
#endif

  /* handle "TLK Games" sprite logo */
  if (tlk_logo_is_move)
    {
      draw_bitmap (&logotlk[tlk_logo_image_index], tlk_logo_xcoord,
                   tlk_logo_ycoord);
      if (tlk_logo_is_next_image)
        {
          tlk_logo_image_index++;
          if (tlk_logo_image_index >= TLKLOGO_MAXOF_IMAGES)
            {
              tlk_logo_image_index = 0;
            }
          tlk_logo_is_next_image = FALSE;
          tlk_logo_ycoord--;
        }
      else
        {
          tlk_logo_is_next_image = TRUE;
        }
      if (tlk_logo_ycoord <= 32)
        {
          tlk_logo_is_move = FALSE;
        }
    }

  /* display text overlay (about, cheats menu and variables) */
  text_overlay_draw ();

  /* handle the loss and the regression of the spaceship or cause game over */
  spaceship_downgrading ();

  /* handle spaceship's energy level */
  energy_gauge_spaceship_update ();

  /* handle guardian's energy level */
  energy_gauge_guardian_update ();

  /* draw player's score into the top panel */
  text_draw_score ();

#ifdef DEVELOPPEMENT
  if (keys_down[K_E] && keys_down[K_G])
    {
      /* [e]+[g] = enable the grid editor */
      grid_editor = 1;
    }
  if (keys_down[K_E] && keys_down[K_C])
    {
      /* [e]+[c] enable the curve editor */
      curve_editor_enable = 1;
    }
  /* [p]+[g] back to the game */
  if (keys_down[K_P] && keys_down[K_G])
    {
      grid_editor = 0;
      curve_editor_enable = 0;
    }
#endif

  /* control the spaceship movements */
  if (!player_pause && !gameover_enable && menu_status == MENU_OFF
      && menu_section == NO_SECTION_SELECTED)
    {
      spaceship_control_movements ();
    }

  /* [P] or [Pause] enable/disable pause */
  if (!keys_down[K_CTRL] && (keys_down[K_P] || keys_down[K_PAUSE]))
    {
      toggle_pause ();
    }
  keys_down[K_P] = FALSE;
  keys_down[K_PAUSE] = FALSE;   /* clear flag pause key */


  /* switch between full screen and windowed mode */
#ifdef POWERMANGA_SDL
  if ((keys_down[K_F] && !is_playername_input ()
       && menu_section != SECTION_ORDER) || keys_down[K_F11])
    {
      if (power_conf->fullscreen)
        {
          power_conf->fullscreen = FALSE;
        }
      else
        {
          power_conf->fullscreen = TRUE;
        }
      init_video_mode ();
    }
  keys_down[K_F] = FALSE;
  keys_down[K_F11] = FALSE;
#endif

  /* control the speed of the spaceship */
  spaceship_speed_control ();

  /* cheat code keys */
#ifdef UNDER_DEVELOPMENT
  special_keys ();
#endif

  /* handle weapon's player spaceship */
#ifdef DEVELOPPEMENT
  if (!grid_editor && !curve_editor_enable && !spaceship_is_dead
      && !player_pause && menu_status == MENU_OFF
      && menu_section == NO_SECTION_SELECTED)
#else
  if (!spaceship_is_dead && !player_pause && menu_status == MENU_OFF
      && menu_section == NO_SECTION_SELECTED)
#endif
    {
      spaceship_weapons ();
    }

#ifdef __EMSCRIPTEN__
  unlock_surface_scores ();
  unlock_surface_options ();
  unlock_surface_game ();
#endif

  return TRUE;
}
Beispiel #12
0
int
main(int argc, char *argv[])
{    
  int  c, nostop=0;
  char *h;
  int  i_rc = 0;
  cd_operation_t cd_op = NO_OP; /* operation to do in non-interactive mode */
  
  
  psz_program = strrchr(argv[0],'/');
  psz_program = psz_program ? psz_program+1 : argv[0];

  memset(&cddb_opts, 0, sizeof(cddb_opts));
  
  cdio_loglevel_default = CDIO_LOG_WARN;
  /* parse options */
  while ( 1 ) {
    if (-1 == (c = getopt(argc, argv, "acCdehkplL:sSt:vx")))
      break;
    switch (c) {
    case 'v':
      b_verbose = true;
      if (cdio_loglevel_default > CDIO_LOG_INFO) 
        cdio_loglevel_default = CDIO_LOG_INFO;
      break;
    case 'd':
      debug = 1;
      if (cdio_loglevel_default > CDIO_LOG_DEBUG) 
      cdio_loglevel_default = CDIO_LOG_DEBUG;
      break;
    case 'a':
      auto_mode = 1;
      break;

    case 'L':
      i_volume_level = atoi(optarg);
      cd_op = SET_VOLUME;
      b_interactive = false;
      break;

    case 't':
      if (NULL != (h = strchr(optarg,'-'))) {
        *h = 0;
        start_track = atoi(optarg);
        stop_track = atoi(h+1)+1;
        if (0 == start_track) start_track = 1;
        if (1 == stop_track)  stop_track  = CDIO_CDROM_LEADOUT_TRACK;
      } else {
        start_track = atoi(optarg);
        stop_track = start_track+1;
        one_track = 1;
      }
      b_interactive = false;
      cd_op = PLAY_TRACK;
      break;
    case 'p':
      b_interactive = false;
      cd_op = PLAY_CD;
      break;
    case 'l':
      b_interactive = false;
      cd_op = LIST_TRACKS;
      break;
    case 'C':
      b_interactive = false;
      cd_op = CLOSE_CD;
      break;
    case 'c':
      b_interactive = false;
      cd_op = PS_LIST_TRACKS;
      break;
    case 's':
      b_interactive = false;
      cd_op = STOP_PLAYING;
      break;
    case 'S':
      b_interactive = false;
      cd_op = LIST_SUBCHANNEL;
      break;
    case 'e':
      b_interactive = false;
      cd_op = EJECT_CD;
      break;
    case 'k':
      print_keys();
      exit(1);
    case 'h':
      usage(psz_program);
      exit(1);
    default:
      usage(psz_program);
      exit(1);
    }
  }
  
  if (argc > optind) {
    psz_device = strdup(argv[optind]);
  } else {
    char **ppsz_cdda_drives=NULL;
    char **ppsz_all_cd_drives = cdio_get_devices_ret(&driver_id);

    if (!ppsz_all_cd_drives) {
      fprintf(stderr, "Can't find a CD-ROM drive\n");
      exit(2);
    }
    ppsz_cdda_drives = cdio_get_devices_with_cap(ppsz_all_cd_drives, 
                                                 CDIO_FS_AUDIO, false);
    if (!ppsz_cdda_drives || !ppsz_cdda_drives[0]) {
      fprintf(stderr, "Can't find a CD-ROM drive with a CD-DA in it\n");
      exit(3);
    }
    psz_device = strdup(ppsz_cdda_drives[0]);
    cdio_free_device_list(ppsz_all_cd_drives);
    cdio_free_device_list(ppsz_cdda_drives);
  }
  
  if (!b_interactive) {
    b_sig = true;
    nostop=1;
  }

  tty_raw();
  signal(SIGINT,ctrlc);
  signal(SIGQUIT,ctrlc);
  signal(SIGTERM,ctrlc);
  signal(SIGHUP,ctrlc);
  signal(SIGWINCH, sigwinch);

  if (CLOSE_CD != cd_op) {
    /* open device */
    if (b_verbose)
      fprintf(stderr, "open %s... ", psz_device);
    p_cdio = cdio_open (psz_device, driver_id);
    if (!p_cdio && cd_op != EJECT_CD) {
      cd_close(psz_device);
      p_cdio = cdio_open (psz_device, driver_id);
    }
    
    if (p_cdio && b_verbose)
      fprintf(stderr,"ok\n");
  }
  
  if (b_interactive) {
#ifdef HAVE_CDDB
    cddb_log_set_handler (cddb_log_handler);
#else
    ;
#endif
  }  else {
    b_sig = true;
    nostop=1;
    if (EJECT_CD == cd_op) {
      i_rc = cd_eject() ? 0 : 1;
    } else {
      switch (cd_op) {
      case PS_LIST_TRACKS:
      case LIST_TRACKS:
      case PLAY_TRACK:
        read_toc(p_cdio);
      default:
        break;
      }
      if (p_cdio)
        switch (cd_op) {
        case STOP_PLAYING:
          b_cd = true;
          i_rc = cd_stop(p_cdio) ? 0 : 1;
          break;
        case EJECT_CD:
          /* Should have been handled above. */
          cd_eject();
          break;
        case LIST_TRACKS:
          list_tracks();
          break;
        case PS_LIST_TRACKS:
          ps_list_tracks();
          break;

        case PLAY_TRACK:
          /* play just this one track */
          if (b_record) {
            printf("%s / %s\n", artist, title);
            if (one_track)
              printf("%s\n", cd_info[start_track].title);
          }
          i_rc = play_track(start_track, stop_track) ? 0 : 1;
          break;

        case PLAY_CD:
          if (b_record)
            printf("%s / %s\n", artist, title);
          play_track(1,CDIO_CDROM_LEADOUT_TRACK);
          break;

        case SET_VOLUME:
          i_rc = set_volume_level(p_cdio, i_volume_level);
          break;

        case LIST_SUBCHANNEL: 
          if (read_subchannel(p_cdio)) {
            if (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
                sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY) {
              {
                printf("track %2d - %02x:%02x (%02x:%02x abs) ",
                       sub.track, sub.rel_addr.m, sub.rel_addr.s,
                       sub.abs_addr.m, sub.abs_addr.s);
              }
            }
            printf("drive state: %s\n", 
                   mmc_audio_state2str(sub.audio_status));
          } else {
            i_rc = 1;
          }
          break;
        case CLOSE_CD: /* Handled below */
        case LIST_KEYS:
        case TOGGLE_PAUSE:
        case EXIT_PROGRAM:
        case NO_OP:
          break;
        }
      else if (CLOSE_CD == cd_op) {
        i_rc = (DRIVER_OP_SUCCESS == cdio_close_tray(psz_device, NULL))
                ? 0 : 1;
      } else {
        fprintf(stderr,"no CD in drive (%s)\n", psz_device);
      }
    }
  }

  /* Play all tracks *unless* we have a play or paused status
     already. */

  read_subchannel(p_cdio);
  if (sub.audio_status != CDIO_MMC_READ_SUB_ST_PAUSED &&
      sub.audio_status != CDIO_MMC_READ_SUB_ST_PLAY)
    play_track(1, CDIO_CDROM_LEADOUT_TRACK);

  while ( !b_sig ) {
    int key;
    if (!b_cd) read_toc(p_cdio);
    read_subchannel(p_cdio);
    display_status(false);
    
    if (1 == select_wait(b_cd ? 1 : 5)) {
      switch (key = getch()) {
      case '-':
        decrease_volume_level(p_cdio);
        break;
      case '+':
        increase_volume_level(p_cdio);
        break;
      case 'A':
      case 'a':
        auto_mode = !auto_mode;
        break;
      case 'X':
      case 'x':
        nostop=1;
        /* fall through */
      case 'Q':
      case 'q':
        b_sig = true;
        break;
      case 'E':
      case 'e':
        cd_eject();
        break;
      case 's':
        cd_stop(p_cdio);
        break;
      case 'C':
      case 'c':
        cd_close(psz_device);
        break;
      case 'L':
      case 'l':
        b_all_tracks = !b_all_tracks;
        if (b_all_tracks)
          display_tracks();
        else {
          i_last_display_track = CDIO_INVALID_TRACK;
          display_cdinfo(p_cdio, i_tracks, i_first_track);
        }
        
        break;
      case 'K':
      case 'k':
      case 'h':
      case 'H':
      case '?':
        list_keys();
        break;
      case ' ':
      case 'P':
      case 'p':
        toggle_pause();
        break;
      case KEY_RIGHT:
        if (b_cd &&
            (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
             sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY)) 
          play_track(sub.track+1, CDIO_CDROM_LEADOUT_TRACK);
        else
          play_track(1,CDIO_CDROM_LEADOUT_TRACK);
        break;
      case KEY_LEFT:
        if (b_cd &&
            (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
             sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY))
          play_track(sub.track-1,CDIO_CDROM_LEADOUT_TRACK);
        break;
      case KEY_UP:
        if (b_cd && sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY)
          skip(10);
        break;
      case KEY_DOWN:
        if (b_cd && sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY)
          skip(-10);
        break;
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
      case '8':
      case '9':
        play_track(key - '0', CDIO_CDROM_LEADOUT_TRACK);
        break;
      case '0':
        play_track(10, CDIO_CDROM_LEADOUT_TRACK);
        break;
      case KEY_F(1):
      case KEY_F(2):
      case KEY_F(3):
      case KEY_F(4):
      case KEY_F(5):
      case KEY_F(6):
      case KEY_F(7):
      case KEY_F(8):
      case KEY_F(9):
      case KEY_F(10):
      case KEY_F(11):
      case KEY_F(12):
      case KEY_F(13):
      case KEY_F(14):
      case KEY_F(15):
      case KEY_F(16):
      case KEY_F(17):
      case KEY_F(18):
      case KEY_F(19):
      case KEY_F(20):
        play_track(key - KEY_F(1) + 11, CDIO_CDROM_LEADOUT_TRACK);
        break;
      }
    }
  }
  if (!nostop) cd_stop(p_cdio);
  tty_restore();
  finish("bye", i_rc);
  
  return 0; /* keep compiler happy */
}
Beispiel #13
0
int common_keypress_handler(int key)
{
	switch (key) {
		case 0x01: /* Escape */
			request_abort_suspend();
			break;
		case 0x02: /* 1 */
		case 0x03: /* 2 */
		case 0x04: /* 3 */
		case 0x05: /* 4 */
		case 0x06: /* 5 */
		case 0x07: /* 6 */
		case 0x08: /* 7 */
		case 0x09: /* 8 */
		case 0x0a: /* 9 */
		case 0x0b: /* 0 */
			console_loglevel = (key - 1)%10;
			set_console_loglevel(0);
			break;
		case 0x13: /* R */
			toggle_reboot();
			break;
		case 0x18: /* O */
			toggle_poweroff();
			break;
		case 0x19: /* P */
			toggle_pause();
			break;
		case 0x1F: /* S */
			toggle_singlestep();
			break;
		case 0x26: /* L */
			toggle_log_all();
			break;
		case 0x39: /* Spacebar */
			notify_space_pressed();
			break;
		case 0x3B: /* F1 */
		case 0x3C: /* F2 */
		case 0x3D: /* F3 */
		case 0x3E: /* F4 */
		case 0x3F: /* F5 */
		case 0x40: /* F6 */
		case 0x41: /* F7 */
		case 0x42: /* F8 */
		case 0x43: /* F9 */
		case 0x44: /* F10 */
		case 0x57: /* F11 */
		case 0x58: /* F12 */
			toggle_debug_state(key);
			break;
		case 0x2D: /* X: Text */
			next_ops = 1;
			break;
		case 0x21: /* F: Fbsplash */
			next_ops = 2;
			break;
		case 0x16: /* U: Usplash */
			next_ops = 3;
			break;
		default: 
			return 0;
	}
	return 1;
}
Beispiel #14
0
void
ScreenManager::process_events()
{
  InputManager::current()->update();
  SDL_Event event;
  auto session = GameSession::current();
  while (SDL_PollEvent(&event))
  {
    InputManager::current()->process_event(event);

    m_menu_manager->event(event);

    if (Editor::is_active()) {
      Editor::current()->event(event);
    }

    switch(event.type)
    {
      case SDL_QUIT:
        quit();
        break;

      case SDL_WINDOWEVENT:
        switch(event.window.event)
        {
          case SDL_WINDOWEVENT_RESIZED:
            m_video_system.on_resize(event.window.data1, event.window.data2);
            m_menu_manager->on_window_resize();
            if (Editor::is_active()) {
              Editor::current()->resize();
            }
            break;

          case SDL_WINDOWEVENT_FOCUS_LOST:
            if (g_config->pause_on_focusloss)
            {
              if(session != nullptr && session->is_active())
              {
                session->toggle_pause();
              }
            }
            break;
        }
        break;

      case SDL_KEYDOWN:
        if (event.key.keysym.sym == SDLK_F9)
        {
          g_debug.set_use_bitmap_fonts(!g_debug.get_use_bitmap_fonts());
        }
        else if (event.key.keysym.sym == SDLK_F10)
        {
          g_config->show_fps = !g_config->show_fps;
        }
        else if (event.key.keysym.sym == SDLK_F11 ||
                 ((event.key.keysym.mod & KMOD_LALT || event.key.keysym.mod & KMOD_RALT) &&
                 (event.key.keysym.sym == SDLK_KP_ENTER || event.key.keysym.sym == SDLK_RETURN)))
        {
          g_config->use_fullscreen = !g_config->use_fullscreen;
          m_video_system.apply_config();
          m_menu_manager->on_window_resize();
        }
        else if (event.key.keysym.sym == SDLK_PRINTSCREEN ||
                 event.key.keysym.sym == SDLK_F12)
        {
          m_video_system.do_take_screenshot();
        }
        else if (event.key.keysym.sym == SDLK_F2 &&
                 event.key.keysym.mod & KMOD_CTRL)
        {
          g_config->developer_mode = !g_config->developer_mode;
          log_info << "developer mode: " << g_config->developer_mode << std::endl;
        }
        break;
    }
  }
}
void SpeakingAgent::on_click()
{
   toggle_pause();
}