X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fmain.cc;h=f9c9f3a0d88dd0e87aab3f946af2403dd7f5a523;hp=f0ac0376973b5900d4d03bfb73985a2b20dbd669;hb=dbcb9345c23c5c027d808915962843e7db2d14aa;hpb=72b941af07bbf2673539ad4eea073e68d3bcbbfc diff --git a/src/main.cc b/src/main.cc index f0ac037..f9c9f3a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -16,8 +16,10 @@ static void reshape(int x, int y); static void key_press(unsigned char key, int x, int y); static void key_release(unsigned char key, int x, int y); static void mouse(int bn, int st, int x, int y); +static void proc_modkeys(); static unsigned int start_time; +static unsigned int modkeys; int main(int argc, char **argv) { @@ -54,6 +56,11 @@ void app_quit() exit(0); } +unsigned int app_get_modifiers() +{ + return modkeys; +} + static bool init() { glewInit(); @@ -87,11 +94,13 @@ static void reshape(int x, int y) static void key_press(unsigned char key, int x, int y) { + proc_modkeys(); app_keyboard(key, true); } static void key_release(unsigned char key, int x, int y) { + proc_modkeys(); app_keyboard(key, false); } @@ -100,5 +109,22 @@ static void mouse(int bn, int st, int x, int y) int bidx = bn - GLUT_LEFT_BUTTON; bool down = st == GLUT_DOWN; + proc_modkeys(); app_mouse_button(bidx, down, x, y); } + +static void proc_modkeys() +{ + int glutmod = glutGetModifiers(); + + modkeys = 0; + if(glutmod & GLUT_ACTIVE_SHIFT) { + modkeys |= MOD_SHIFT; + } + if(glutmod & GLUT_ACTIVE_CTRL) { + modkeys |= MOD_CTRL; + } + if(glutmod & GLUT_ACTIVE_ALT) { + modkeys |= MOD_ALT; + } +}