[GTK3] Implement rewind, turbo and slow-motion
This commit is contained in:
parent
9224b3f2ac
commit
a1b464bd23
36
gtk3/main.c
36
gtk3/main.c
@ -860,6 +860,27 @@ static gboolean on_key_press(GtkWidget *w, GdkEventKey *event, gpointer data) {
|
||||
case GDK_KEY_k: mask = BUTTON_MASK_B; break;
|
||||
case GDK_KEY_l: mask = BUTTON_MASK_A; break;
|
||||
|
||||
case GDK_KEY_Tab: {
|
||||
rewind_down = event->type == GDK_KEY_PRESS;
|
||||
GB_set_turbo_mode(&gb, turbo_down, turbo_down && rewind_down);
|
||||
|
||||
if (event->type == GDK_KEY_RELEASE) {
|
||||
rewind_paused = false;
|
||||
}
|
||||
break; }
|
||||
|
||||
case GDK_KEY_space: {
|
||||
turbo_down = event->type == GDK_KEY_PRESS;
|
||||
SDL_ClearQueuedAudio(device_id);
|
||||
GB_set_turbo_mode(&gb, turbo_down, turbo_down && rewind_down);
|
||||
break; }
|
||||
|
||||
case GDK_KEY_dead_acute: // fall through
|
||||
case GDK_KEY_acute: // fall through
|
||||
case GDK_KEY_apostrophe:
|
||||
underclock_down = event->type == GDK_KEY_PRESS;
|
||||
break;
|
||||
|
||||
case GDK_KEY_F11: {
|
||||
if (event->type == GDK_KEY_RELEASE) {
|
||||
if (is_fullscreen) {
|
||||
@ -869,7 +890,7 @@ static gboolean on_key_press(GtkWidget *w, GdkEventKey *event, gpointer data) {
|
||||
gtk_window_fullscreen(GTK_WINDOW(main_window));
|
||||
}
|
||||
}
|
||||
}
|
||||
break; }
|
||||
}
|
||||
|
||||
if (event->type == GDK_KEY_PRESS) {
|
||||
@ -1405,6 +1426,7 @@ G_MODULE_EXPORT void on_keep_aspect_ratio_changed(GtkWidget *w, gpointer user_da
|
||||
G_MODULE_EXPORT void on_rewind_duration_changed(GtkWidget *w, gpointer user_data_gptr) {
|
||||
GtkComboBox *box = GTK_COMBO_BOX(w);
|
||||
config.rewind_duration = g_ascii_strtoll(gtk_combo_box_get_active_id(box), NULL, 10);
|
||||
GB_set_rewind_length(&gb, config.rewind_duration);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void on_sample_rate_changed(GtkWidget *w, gpointer user_data_gptr) {
|
||||
@ -1823,6 +1845,17 @@ static void vblank(GB_gameboy_t *gb) {
|
||||
GB_set_pixels_output(gb, get_pixels());
|
||||
|
||||
g_idle_add((GSourceFunc) on_vblank, NULL);
|
||||
|
||||
if (underclock_down && clock_mutliplier > 0.5) {
|
||||
clock_mutliplier -= 1.0/16;
|
||||
GB_set_clock_multiplier(gb, clock_mutliplier);
|
||||
}
|
||||
else if (!underclock_down && clock_mutliplier < 1.0) {
|
||||
clock_mutliplier += 1.0/16;
|
||||
GB_set_clock_multiplier(gb, clock_mutliplier);
|
||||
}
|
||||
|
||||
do_rewind = rewind_down;
|
||||
}
|
||||
|
||||
static void run(GuiData *gui_data) {
|
||||
@ -2004,6 +2037,7 @@ static void start(GuiData *gui_data) {
|
||||
while (running) {
|
||||
if (rewind_paused) {
|
||||
handle_events(&gb);
|
||||
g_usleep(G_USEC_PER_SEC / 8);
|
||||
}
|
||||
else {
|
||||
if (do_rewind) {
|
||||
|
Loading…
Reference in New Issue
Block a user