From 2d187a02033d7980202b44d9f6b4b0a4d185a60b Mon Sep 17 00:00:00 2001 From: Takamichi Horikawa Date: Tue, 31 Jan 2017 23:09:30 +0900 Subject: added color palette support (ctrl-f1 - ctrl-f10) --- gtk/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'gtk') diff --git a/gtk/main.c b/gtk/main.c index 77bf105..e3a0e45 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -425,6 +425,20 @@ static void destroynothing(gpointer p) { (void)p; } +static gboolean key_press_cb(GtkWidget *w, + GdkEvent *e, + gpointer ptr) { + (void)w; + (void)ptr; + if (GDK_KEY_F1 <= e->key.keyval && e->key.keyval <= GDK_KEY_F10) { + if (e->key.state & GDK_CONTROL_MASK) { + fmdsp_palette_set(&g.fmdsp, e->key.keyval - GDK_KEY_F1); + return TRUE; + } + } + return FALSE; +} + int main(int argc, char **argv) { load_fontrom(); gtk_init(&argc, &argv); @@ -472,7 +486,9 @@ int main(int argc, char **argv) { fmdsp_vram_init(&g.fmdsp, &g.work, g.vram); g.vram32_stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, PC98_W); g.vram32 = malloc((g.vram32_stride*PC98_H)*4); - + + g_signal_connect(w, "key-press-event", G_CALLBACK(key_press_cb), 0); + gtk_widget_add_events(w, GDK_KEY_PRESS_MASK); gtk_widget_show_all(w); gtk_widget_add_tick_callback(w, tick_cb, drawarea, destroynothing); gtk_main(); -- cgit v1.2.3