From d26cfab77984803f14bd198880670241f8cdffee Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Tue, 20 Sep 2011 22:32:56 +0200 Subject: Fixed redundant code in AltGr handling --- evspy-core.c | 8 +++++++- evspy-core.h | 21 ++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/evspy-core.c b/evspy-core.c index edcd4e5..ec41f1e 100644 --- a/evspy-core.c +++ b/evspy-core.c @@ -28,7 +28,10 @@ static char *rdp; // read pointer static char *wrp; // write pointer static unsigned short int capslock_on = 0; static unsigned short int shift_on = 0; + +#ifdef EVS_ALTGR_ENABLED static unsigned short int altgr_on = 0; +#endif /* * Executed when the procfs file is read (EVS_PROCNAME) @@ -193,9 +196,12 @@ static void evspy_event(struct input_handle *handle, unsigned int type, // "Immediate" keys (alphanumeric + some symbols) } else if (value == EVS_VAL_PRESS) { +#ifdef EVS_ALTGR_ENABLED if (altgr_on) evs_insert(evs_altgr(code)); - else if (shift_on || capslock_on) + else +#endif + if (shift_on || capslock_on) evs_insert(evs_shift(code)); else evs_insert(map[code]); diff --git a/evspy-core.h b/evspy-core.h index 49da4b5..6cbe913 100644 --- a/evspy-core.h +++ b/evspy-core.h @@ -142,18 +142,13 @@ * Returns the character associated with event code c when altgr is pressed */ #ifdef EVS_ALTGR_ENABLED -# define evs_altgr(c) \ - ({ \ - void *__vp; \ - char __c; \ - __vp = khm_get(ahm, (c)); \ - if (__vp) __c = *(char *)__vp; \ - else __c = map[c]; \ - __c; \ - }) -#else -# define evs_altgr(c) \ +#define evs_altgr(c) \ ({ \ - (c); \ - }) + void *__vp; \ + char __c; \ + __vp = khm_get(ahm, (c)); \ + if (__vp) __c = *(char *)__vp; \ + else __c = map[c]; \ + __c; \ +}) #endif -- cgit v1.2.3