[GTK3] Add debug console prompt
This commit is contained in:
parent
29ce04ff8a
commit
a53d7f1e92
34
gtk3/main.c
34
gtk3/main.c
@ -72,6 +72,9 @@ static uint8_t oamHeight;
|
||||
|
||||
static uint8_t pressed_buttons;
|
||||
|
||||
static gboolean in_sync_input = false;
|
||||
static gchar *last_console_input = NULL;
|
||||
|
||||
static GMutex debugger_input_mutex;
|
||||
static GCond debugger_input_cond;
|
||||
static GMutex console_output_lock;
|
||||
@ -373,7 +376,8 @@ static void gb_audio_callback(GB_gameboy_t *gb, GB_sample_t *sample) {
|
||||
}
|
||||
|
||||
static char *sync_console_input(GB_gameboy_t *gb) {
|
||||
console_log(gb, ">", 0);
|
||||
console_log(gb, "> ", 0);
|
||||
in_sync_input = true;
|
||||
|
||||
g_mutex_lock(&debugger_input_mutex);
|
||||
g_cond_wait(&debugger_input_cond, &debugger_input_mutex);
|
||||
@ -386,6 +390,13 @@ static char *sync_console_input(GB_gameboy_t *gb) {
|
||||
|
||||
g_mutex_unlock(&debugger_input_mutex);
|
||||
|
||||
in_sync_input = false;
|
||||
|
||||
// clear sidebar
|
||||
GtkTextView *sidebar_output = builder_get(GTK_TEXT_VIEW, "console_sidebar_output");
|
||||
GtkTextBuffer *sidebar_text_buf = gtk_text_view_get_buffer(sidebar_output);
|
||||
gtk_text_buffer_set_text(sidebar_text_buf, "", -1);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@ -1464,13 +1475,30 @@ G_MODULE_EXPORT void on_use_integer_scaling_changed(GtkWidget *w, gpointer user_
|
||||
G_MODULE_EXPORT void console_on_enter(GtkWidget *w, gpointer user_data_gptr) {
|
||||
GtkEntry *input = GTK_ENTRY(w);
|
||||
const gchar *_text = gtk_entry_get_text(input);
|
||||
const gchar *text = g_strdup(_text);
|
||||
gtk_entry_set_text(input, "");
|
||||
gchar *text = g_strdup(_text);
|
||||
|
||||
if (g_strcmp0("", text) == 0 && g_strcmp0("", last_console_input) < 0) {
|
||||
text = g_strdup(last_console_input);
|
||||
}
|
||||
else if (text) {
|
||||
if (last_console_input != NULL) g_free(last_console_input);
|
||||
last_console_input = g_strdup(text);
|
||||
}
|
||||
|
||||
if (!in_sync_input) {
|
||||
console_log(&gb, "> ", 0);
|
||||
}
|
||||
|
||||
console_log(&gb, text, 0);
|
||||
console_log(&gb, "\n", 0);
|
||||
|
||||
g_mutex_lock(&debugger_input_mutex);
|
||||
g_ptr_array_add(debugger_input_queue, (gpointer)text);
|
||||
g_cond_signal(&debugger_input_cond);
|
||||
g_mutex_unlock(&debugger_input_mutex);
|
||||
|
||||
// clear input
|
||||
gtk_entry_set_text(input, "");
|
||||
}
|
||||
|
||||
static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b) {
|
||||
|
Loading…
Reference in New Issue
Block a user