From 970b0cfcc67b0fe32854dffba3643b62dc285dc1 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 8 Jul 2005 21:16:38 +0000 Subject: [PATCH] * src/event.c src/caca.c: fixed coding style --- src/caca.c | 2 - src/event.c | 126 ++++++++++++++++++++++++++-------------------------- 2 files changed, 62 insertions(+), 66 deletions(-) diff --git a/src/caca.c b/src/caca.c index 854f0b0..13afa46 100644 --- a/src/caca.c +++ b/src/caca.c @@ -505,9 +505,7 @@ static void caca_init_driver(void) #endif #if defined(USE_NULL) if(!strcasecmp(var, "null")) - { _caca_driver = CACA_DRIVER_NULL; - } else #endif diff --git a/src/event.c b/src/event.c index 5d24d59..3bbb78e 100644 --- a/src/event.c +++ b/src/event.c @@ -195,15 +195,14 @@ static unsigned int _get_next_event(void) static unsigned int autorepeat_ticks = 0; static unsigned int last_key = 0; unsigned int ticks; + unsigned int event; #endif #if defined(USE_NULL) - { - if(_caca_driver == CACA_DRIVER_NULL) - return CACA_EVENT_NONE; - } + if(_caca_driver == CACA_DRIVER_NULL) + return CACA_EVENT_NONE; #endif - unsigned int event = _lowlevel_event(); + event = _lowlevel_event(); #if defined(USE_SLANG) if(_caca_driver != CACA_DRIVER_SLANG) @@ -740,66 +739,65 @@ static unsigned int _lowlevel_event(void) else #endif #if defined(USE_GL) - if(_caca_driver == CACA_DRIVER_GL) - { - glutMainLoopEvent(); - - if(gl_resized) - { - if(!_caca_resize) - { - _caca_resize = 1; - gl_resized=0; - return CACA_EVENT_RESIZE; - } - } - if(gl_mouse_changed) - { - if(gl_mouse_clicked) - { - event|= CACA_EVENT_MOUSE_PRESS | gl_mouse_button; - gl_mouse_clicked=0; - } - mouse_x = gl_mouse_x; - mouse_y = gl_mouse_y; - event |= CACA_EVENT_MOUSE_MOTION | (mouse_x << 12) | mouse_y; - gl_mouse_changed = 0; - } - if(gl_key!=0) - { - event |= CACA_EVENT_KEY_PRESS; - event |= gl_key; - gl_key = 0; - } - - if(gl_special_key != 0) - { - event |= CACA_EVENT_KEY_PRESS; + if(_caca_driver == CACA_DRIVER_GL) + { + glutMainLoopEvent(); + + if(gl_resized && !_caca_resize) + { + _caca_resize = 1; + gl_resized = 0; + return CACA_EVENT_RESIZE; + } + + if(gl_mouse_changed) + { + if(gl_mouse_clicked) + { + event|= CACA_EVENT_MOUSE_PRESS | gl_mouse_button; + gl_mouse_clicked=0; + } + mouse_x = gl_mouse_x; + mouse_y = gl_mouse_y; + event |= CACA_EVENT_MOUSE_MOTION | (mouse_x << 12) | mouse_y; + gl_mouse_changed = 0; + } + + if(gl_key != 0) + { + event |= CACA_EVENT_KEY_PRESS; + event |= gl_key; + gl_key = 0; + } + + if(gl_special_key != 0) + { + event |= CACA_EVENT_KEY_PRESS; - switch(gl_special_key) - { - case GLUT_KEY_F1 : gl_special_key = 0; return event | CACA_KEY_F1; - case GLUT_KEY_F2 : gl_special_key = 0; return event | CACA_KEY_F2; - case GLUT_KEY_F3 : gl_special_key = 0; return event | CACA_KEY_F3; - case GLUT_KEY_F4 : gl_special_key = 0; return event | CACA_KEY_F4; - case GLUT_KEY_F5 : gl_special_key = 0; return event | CACA_KEY_F5; - case GLUT_KEY_F6 : gl_special_key = 0; return event | CACA_KEY_F6; - case GLUT_KEY_F7 : gl_special_key = 0; return event | CACA_KEY_F7; - case GLUT_KEY_F8 : gl_special_key = 0; return event | CACA_KEY_F8; - case GLUT_KEY_F9 : gl_special_key = 0; return event | CACA_KEY_F9; - case GLUT_KEY_F10 : gl_special_key = 0; return event | CACA_KEY_F10; - case GLUT_KEY_F11 : gl_special_key = 0; return event | CACA_KEY_F11; - case GLUT_KEY_F12 : gl_special_key = 0; return event | CACA_KEY_F12; - case GLUT_KEY_LEFT : gl_special_key = 0; return event | CACA_KEY_LEFT; - case GLUT_KEY_RIGHT: gl_special_key = 0; return event | CACA_KEY_RIGHT; - case GLUT_KEY_UP : gl_special_key = 0; return event | CACA_KEY_UP; - case GLUT_KEY_DOWN : gl_special_key = 0; return event | CACA_KEY_DOWN; - default: return CACA_EVENT_NONE; - } - } - return event; - } - else + switch(gl_special_key) + { + case GLUT_KEY_F1 : gl_special_key = 0; return event | CACA_KEY_F1; + case GLUT_KEY_F2 : gl_special_key = 0; return event | CACA_KEY_F2; + case GLUT_KEY_F3 : gl_special_key = 0; return event | CACA_KEY_F3; + case GLUT_KEY_F4 : gl_special_key = 0; return event | CACA_KEY_F4; + case GLUT_KEY_F5 : gl_special_key = 0; return event | CACA_KEY_F5; + case GLUT_KEY_F6 : gl_special_key = 0; return event | CACA_KEY_F6; + case GLUT_KEY_F7 : gl_special_key = 0; return event | CACA_KEY_F7; + case GLUT_KEY_F8 : gl_special_key = 0; return event | CACA_KEY_F8; + case GLUT_KEY_F9 : gl_special_key = 0; return event | CACA_KEY_F9; + case GLUT_KEY_F10: gl_special_key = 0; return event | CACA_KEY_F10; + case GLUT_KEY_F11: gl_special_key = 0; return event | CACA_KEY_F11; + case GLUT_KEY_F12: gl_special_key = 0; return event | CACA_KEY_F12; + case GLUT_KEY_LEFT : gl_special_key = 0; return event | CACA_KEY_LEFT; + case GLUT_KEY_RIGHT: gl_special_key = 0; return event | CACA_KEY_RIGHT; + case GLUT_KEY_UP : gl_special_key = 0; return event | CACA_KEY_UP; + case GLUT_KEY_DOWN : gl_special_key = 0; return event | CACA_KEY_DOWN; + default: return CACA_EVENT_NONE; + } + } + return event; + } + else #endif { /* Dummy */