more elaborate keyboard input handling, and debug gui improvements
[laserbrain_demo] / src / app.cc
index 0356104..a03fd34 100644 (file)
@@ -500,9 +500,9 @@ void app_keyboard(int key, bool pressed)
 {
        unsigned int mod = app_get_modifiers();
 
-       if(!debug_gui_key(key, pressed, mod)) {
-               // the debug gui indicated that we should ignore the event
-               return;
+       if(show_debug_gui && !(pressed && (key == '`' || key == 27))) {
+               debug_gui_key(key, pressed, mod);
+               return; // ignore all keystrokes when GUI is visible
        }
 
        if(pressed) {
@@ -518,12 +518,12 @@ void app_keyboard(int key, bool pressed)
                        }
                        break;
 
-               case '\t':
+               case '`':
                        show_debug_gui = !show_debug_gui;
                        show_message("debug gui %s", show_debug_gui ? "enabled" : "disabled");
                        break;
 
-               case '`':
+               case 'm':
                        app_toggle_grab_mouse();
                        show_message("mouse %s", app_is_mouse_grabbed() ? "grabbed" : "released");
                        break;
@@ -592,9 +592,9 @@ void app_keyboard(int key, bool pressed)
 
 void app_mouse_button(int bn, bool pressed, int x, int y)
 {
-       if(!debug_gui_mbutton(bn, pressed, x, y)) {
-               // the debug GUI indicated we should ignore the event
-               return;
+       if(show_debug_gui) {
+               debug_gui_mbutton(bn, pressed, x, y);
+               return; // ignore mouse events while GUI is visible
        }
 
        prev_mx = x;
@@ -620,9 +620,9 @@ static void mouse_zoom(float dx, float dy)
 
 void app_mouse_motion(int x, int y)
 {
-       if(!debug_gui_mmotion(x, y)) {
-               // the debug GUI indicated we should ignore the event
-               return;
+       if(show_debug_gui) {
+               debug_gui_mmotion(x, y);
+               return; // ignore mouse events while GUI is visible
        }
 
        int dx = x - prev_mx;
@@ -649,6 +649,13 @@ void app_mouse_delta(int dx, int dy)
        }
 }
 
+void app_mouse_wheel(int dir)
+{
+       if(show_debug_gui) {
+               debug_gui_wheel(dir);
+       }
+}
+
 void app_gamepad_axis(int axis, float val)
 {
        switch(axis) {