X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Flinux%2Fgp2x.c;h=b89990bc0a02bb3cffbda501e40c4697a0545a58;hb=047db02217aca2879886504b97549cdbb15a056c;hp=0a1c73b25c871afd0a02d8a074f90d99d4719662;hpb=a12e01162349cd970e9b6fe5674497760631279b;p=picodrive.git diff --git a/platform/linux/gp2x.c b/platform/linux/gp2x.c index 0a1c73b..b89990b 100644 --- a/platform/linux/gp2x.c +++ b/platform/linux/gp2x.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -18,6 +19,8 @@ #include "../gp2x/usbjoy.h" #include "../gp2x/version.h" +#include "log_io.h" + void *gp2x_screen; static int current_bpp = 8; static int current_pal[256]; @@ -65,6 +68,8 @@ static gint key_press_event (GtkWidget *widget, GdkEventKey *event) case 0x29: current_keys |= GP2X_PUSH; break; // f case 0x18: current_keys |= GP2X_VOL_DOWN;break; // q case 0x19: current_keys |= GP2X_VOL_UP;break; // w + case 0x2d: log_io_clear(); break; // k + case 0x2e: log_io_dump(); break; // l } return 0; @@ -94,22 +99,12 @@ static gint key_release_event (GtkWidget *widget, GdkEventKey *event) return 0; } -static void *gtk_threadf(void *none) -{ - gtk_main(); - - printf("linux: gtk thread finishing\n"); - engineState = PGS_Quit; - - return NULL; -} - -static void gtk_initf(void) +static void *gtk_threadf(void *targ) { int argc = 0; char *argv[] = { "" }; GtkWidget *box; - pthread_t gtk_thread; + sem_t *sem = targ; g_thread_init (NULL); gdk_threads_init (); @@ -145,11 +140,27 @@ static void gtk_initf(void) gtk_widget_show (gtk_items.window); - // pthread_mutex_init (&thr_mutex, NULL); - // pthread_mutex_lock (&thr_mutex); - // pthread_mutex_init (&scanner_muttex, NULL); + sem_post(sem); + + gtk_main(); - pthread_create(>k_thread, NULL, gtk_threadf, NULL); + printf("linux: gtk thread finishing\n"); + exit(1); + + return NULL; +} + +static void gtk_initf(void) +{ + pthread_t gtk_thread; + sem_t sem; + sem_init(&sem, 0, 0); + + pthread_create(>k_thread, NULL, gtk_threadf, &sem); + pthread_detach(gtk_thread); + + sem_wait(&sem); + sem_close(&sem); } void finalize_image(guchar *pixels, gpointer data) @@ -417,5 +428,13 @@ void spend_cycles(int c) usleep(c/200); } +/* lprintf */ +void lprintf(const char *fmt, ...) +{ + va_list vl; + va_start(vl, fmt); + vprintf(fmt, vl); + va_end(vl); +}