void events2(t_window *w, t_music *m, t_list *l, t_text *t, t_font *f, t_image *img) { int next; SDL_Event event; next = 1; refresh(w, l, t, f, img); while (next) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: clean_exit(w, m, l, t); break; case SDL_MOUSEBUTTONUP: if (event.button.button == SDL_BUTTON_LEFT) pars_scene(w, m, l, t, f); break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_RETURN: pars_scene(w, m, l, t, f); break; case SDLK_SPACE: pars_scene(w, m, l, t, f); break; case SDLK_LEFT: history_navigation(w, m, l, t, f, img); break; case SDLK_m: music_pause(m); break; case SDLK_ESCAPE: game_menu(w, m, l, t, f, img); break; default: break; } break; default: break; } } }
static void fifo_execute (const char *command) { if (!g_ascii_strncasecmp (command, "quit", 4)) main_quit (); else if (!g_ascii_strncasecmp (command, "play", 4)) music_play (); else if (!g_ascii_strncasecmp (command, "pause", 5)) if (music_playing) music_pause (); else music_play (); else if (!g_ascii_strncasecmp (command, "stop", 4)) music_stop (); else if (!g_ascii_strncasecmp (command, "next", 4)) { playlist_advance (1, TRUE); } else if (!g_ascii_strncasecmp (command, "prev", 4)) { playlist_advance (-1, TRUE); } else if (!g_ascii_strncasecmp (command, "append", 6)) { if (strlen (command) > 7) { gchar *u; const gchar *path; path = (command + 7); if (!(u = g_filename_to_utf8 (path, -1, NULL, NULL, NULL))) { g_warning (_("Skipping '%s'. Could not convert to UTF-8. " "See the README for a possible solution."), path); } else { playlist_append_single (u); g_free (u); } } } else if (!g_ascii_strncasecmp (command, "track", 5)) { if (strlen (command) > 6) { int i = atoi (command + 6); playlist_seek (i - 1); /* first track is '1' */ } } else if (!g_ascii_strncasecmp (command, "remove", 6)) { if (strlen (command) > 7) { int i = atoi (command + 7); playlist_remove (i - 1); /* first track is '1' */ } } else if (!g_ascii_strncasecmp (command, "clear", 5)) { playlist_clear (); } else if (!g_ascii_strncasecmp (command, "move", 4)) { if (strlen (command) > 5) { char *p; int i = strtol (command + 5, &p, 10); if (strlen (command) > (unsigned)(p - command)) { int before = atoi (p); playlist_move (i - 1, before - 1); /* first track is '1' */ } } } else if (!g_ascii_strncasecmp (command, "loop", 4)) { main_set_loop_at_end(!main_loop_at_end); } else if (!g_ascii_strncasecmp (command, "random", 6)) { main_set_random_order(!main_random_order); } else if (!g_ascii_strncasecmp (command, "dump", 4)) { playlist_dump (); } else if (!g_ascii_strncasecmp (command, "connect", 7)) { if (strlen (command) > 8) { fifo_add_notify (command + 8); } } }
int main() { char chout='\n'; int action=1; time_t last_time_action, current_time, last_time; if ( init_mpc () == 0) { printf("Error init mpc\n"); exit (-1); } output_t * output_st = init_output_st (); while (init_display(output_st)) { printf("Error display\n"); sleep (1); } set_cirilic (); clear_scr(); int encoder_fd = 0; if (cfileexists(ENCODER_COM_PORT)) { encoder_fd = init_comport(ENCODER_COM_PORT, ENCODER_COM_SPEED); } else { encoder_fd = init_comport(DEFAULT_ENCODER_COM_PORT, ENCODER_COM_SPEED); } init_term(); last_time = time(NULL); int count_click = 0; struct timeval t_start, t_end; int show_time = 0; while (1) { get_all (output_st); int ret_read = read_com(encoder_fd, 1 , 100, &chout); if ((chout=='R') || (chout=='L') ||(chout=='a') || (chout=='d')) { action=0; last_time_action = time(NULL); set_play_list_position(tuning_movement(chout)); get_cur_position (); show_current_cursor_pos (); } if ((chout=='P') ||(chout=='s') ) { gettimeofday(&t_end, NULL); if(!count_click) { t_start = t_end; count_click++; } else { if (usec_used (&t_start, &t_end) <= 500000) { double_click_button(); if (show_time) { show_time--; } else { show_time++; } } count_click = 0; } } if (count_click) { gettimeofday(&t_end, NULL); if (usec_used (&t_start, &t_end) > 500000) { print_button_pressed(); music_pause(); count_click = 0; } } chout = '\0'; current_time = time(NULL); if (action==0) { if ((current_time-last_time_action)>3) { action++; } } if ((action) && ((current_time-last_time)>0)) { if (!show_time) { show_current_track(output_st); } else { show_current_time_and_date(); } last_time = current_time; } } }
int trap_PauseMusic(lua_State *s) { music_pause(); return 0; }
void history_navigation(t_window *w, t_music *m, t_list *l, t_text *t, t_font *f, t_image *img) { int next; SDL_Event event; t_elem_text *e_text; next = 1; e_text = t->tail; if (e_text->prev != NULL) e_text = e_text->prev; first_left_show(w, t, f, l); while (next) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: clean_exit(w, m, l, t); break; case SDL_MOUSEBUTTONUP: if (event.button.button == SDL_BUTTON_LEFT) pars_scene(w, m, l, t, f); break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_RETURN: next = 0; events2(w, m, l, t, f, img); break; case SDLK_SPACE: next = 0; events2(w, m, l, t, f, img); break; case SDLK_LEFT: if (e_text->prev != NULL) { e_text = e_text->prev; history_show(w, t, f, e_text, l); } break; case SDLK_RIGHT: if (e_text->next != NULL && e_text->next->next != NULL) { e_text = e_text->next; history_show(w, t, f, e_text, l); } break; case SDLK_m: music_pause(m); break; case SDLK_ESCAPE: clean_exit(w, m, l, t); break; default: break; } break; default: break; } } }