diff --git a/editor/Makefile b/editor/Makefile index 70ae65f..c4b9224 100644 --- a/editor/Makefile +++ b/editor/Makefile @@ -7,7 +7,6 @@ SRCDIR=src all: $(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/display.c $(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/input.c - $(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/event_callbacks.c $(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/main.c $(CC) $(CFLAGS) $(LINKER_FLAGS) $(GTKLIBS) -o ledcube-edit main.o display.o input.o diff --git a/editor/src/event_callbacks.c b/editor/src/event_callbacks.c index 6d05df9..ad366ea 100644 --- a/editor/src/event_callbacks.c +++ b/editor/src/event_callbacks.c @@ -1,8 +1,10 @@ #include #include #include +#include #include "config.h" +#include "input.h" #include "display.h" void on_main_window_delete_event(GtkObject *object, gpointer userData) { @@ -46,7 +48,22 @@ void on_drawing_area_realize(GtkWidget *widget, gpointer data) { gdk_gl_drawable_gl_end(glDrawable); } -void on_drawing_area_key_press_event(GtkWidget *widget, gpointer data) { - g_print("pressed"); +void on_drawing_area_key_press_event(GtkWidget *widget, GdkEventKey *event) { + switch (event->keyval) { + case GDK_KEY_Left: + moveCameraPosition(MOVE_SPEED); + break; + case GDK_KEY_Right: + moveCameraPosition(MOVE_SPEED*-1); + break; + case GDK_KEY_Up: + moveCameraAngle(MOVE_SPEED); + break; + case GDK_KEY_Down: + moveCameraAngle(MOVE_SPEED*-1); + break; + } + + gtk_widget_queue_draw_area(widget, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); } diff --git a/editor/src/input.c b/editor/src/input.c index 79392cf..39c87c4 100644 --- a/editor/src/input.c +++ b/editor/src/input.c @@ -23,33 +23,6 @@ void moveCameraAngle(float angle) { if (eyeAngle < 0) eyeAngle = 0; } - -void keyboard(unsigned char key, int x, int y) { - switch (key) { - case 27: // ESC - exit(0); - break; - } - glutPostRedisplay(); -} - -void keyboard_special(int key, int x, int y) { - switch (key) { - case GLUT_KEY_LEFT: - moveCameraPosition(MOVE_SPEED); - break; - case GLUT_KEY_RIGHT: - moveCameraPosition(MOVE_SPEED*-1); - break; - case GLUT_KEY_UP: - moveCameraAngle(MOVE_SPEED); - break; - case GLUT_KEY_DOWN: - moveCameraAngle(MOVE_SPEED*-1); - } - glutPostRedisplay(); -} - void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { int position, viewport[4]; diff --git a/editor/src/input.h b/editor/src/input.h index bb48fa1..1c3751f 100644 --- a/editor/src/input.h +++ b/editor/src/input.h @@ -4,9 +4,6 @@ void moveCameraPosition(float direction); void moveCameraAngle(float angle); -void keyboard(unsigned char key, int x, int y); -void keyboard_special(int key, int x, int y); - void mouse(int button, int state, int x, int y); #endif diff --git a/editor/src/main.c b/editor/src/main.c index d1a7741..53aa65f 100644 --- a/editor/src/main.c +++ b/editor/src/main.c @@ -66,13 +66,13 @@ int main(int argc, char *argv[]) { } xml = glade_xml_new("src/main_gui.glade", NULL, NULL); - glade_xml_signal_autoconnect(xml); window = glade_xml_get_widget(xml, "main_window"); gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), TRUE); drawingArea = glade_xml_get_widget(xml, "drawing_area"); gtk_widget_set_gl_capability(drawingArea, glConfig, NULL, TRUE, GDK_GL_RGBA_TYPE); + glade_xml_signal_autoconnect(xml); gtk_widget_show(window); gtk_main(); diff --git a/editor/src/main_gui.glade b/editor/src/main_gui.glade index 0bf1120..0fb50f7 100644 --- a/editor/src/main_gui.glade +++ b/editor/src/main_gui.glade @@ -22,8 +22,9 @@ True 7 - + True + LED Cube is not connected @@ -32,18 +33,6 @@ True - - - True - Connect to cube - True - gtk-connect - - - False - True - - True @@ -100,6 +89,8 @@ 500 500 True + True + GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK