Skip to content

Commit

Permalink
Use functions from evdev.c to improce input event diagnostics
Browse files Browse the repository at this point in the history
On debug verbosity mce will print event type, code and value
before processing the events.

Also removed a function made redundant by evdev.c
  • Loading branch information
spiiroin committed Jan 31, 2013
1 parent ee4bc86 commit fb09a80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .depend
Expand Up @@ -33,6 +33,7 @@ evdev.pic.o:\
event-input.o:\
event-input.c\
datapipe.h\
evdev.h\
event-input.h\
mce-conf.h\
mce-io.h\
Expand All @@ -43,6 +44,7 @@ event-input.o:\
event-input.pic.o:\
event-input.c\
datapipe.h\
evdev.h\
event-input.h\
mce-conf.h\
mce-io.h\
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -274,6 +274,7 @@ MCE_CORE += mce-modules.c
MCE_CORE += mce-io.c
MCE_CORE += mce-lib.c
MCE_CORE += median_filter.c
MCE_CORE += evdev.c

# HACK: do not link against libgconf-2
ifeq ($(strip $(ENABLE_BUILTIN_GCONF)),y)
Expand Down
42 changes: 18 additions & 24 deletions event-input.c
Expand Up @@ -84,7 +84,7 @@
* mce_conf_get_string()
*/
#include "datapipe.h" /* execute_datapipe() */

#include "evdev.h"
/** ID for touchscreen I/O monitor timeout source */
static guint touchscreen_io_monitor_timeout_cb_id = 0;

Expand Down Expand Up @@ -132,28 +132,6 @@ static void update_inputdevices(const gchar *device, gboolean add);
# endif
#endif

static const char *evtype(int type)
{
static const char * const lut[EV_CNT] = {
[EV_SYN] = "EV_SYN",
[EV_KEY] = "EV_KEY",
[EV_REL] = "EV_REL",
[EV_ABS] = "EV_ABS",
[EV_MSC] = "EV_MSC",
[EV_SW] = "EV_SW",
[EV_LED] = "EV_LED",
[EV_SND] = "EV_SND",
[EV_REP] = "EV_REP",
[EV_FF] = "EV_FF",
[EV_PWR] = "EV_PWR",
[EV_FF_STATUS] = "EV_FF_STATUS",
};

if( (unsigned)type < (unsigned)EV_CNT )
return lut[type];
return 0;
};

/** Calculate how many elements an array of longs bitmap needs to
* have enough space for bc items */
#define EVDEVBITS_LEN(bc) (((bc)+LONG_BIT-1)/LONG_BIT)
Expand Down Expand Up @@ -240,7 +218,8 @@ static int evdevbits_probe(evdevbits_t *self, int fd)
{
int res = 0;
if( self && ioctl(fd, EVIOCGBIT(self->type, self->cnt), self->bit) == -1 ) {
mce_log(LL_WARN, "EVIOCGBIT(%s, %d): %m", evtype(self->type), self->cnt);
mce_log(LL_WARN, "EVIOCGBIT(%s, %d): %m",
evdev_get_event_type_name(self->type), self->cnt);
evdevbits_clear(self);
res = -1;
}
Expand Down Expand Up @@ -700,6 +679,11 @@ static gboolean touchscreen_iomon_cb(gpointer data, gsize bytes_read)
goto EXIT;
}

mce_log(LL_DEBUG, "type: %s, code: %s, value: %d",
evdev_get_event_type_name(ev->type),
evdev_get_event_code_name(ev->type, ev->code),
ev->value);

/* Ignore unwanted events */
if ((ev->type != EV_ABS) &&
(ev->type != EV_KEY) &&
Expand Down Expand Up @@ -816,6 +800,11 @@ static gboolean keypress_iomon_cb(gpointer data, gsize bytes_read)
goto EXIT;
}

mce_log(LL_DEBUG, "type: %s, code: %s, value: %d",
evdev_get_event_type_name(ev->type),
evdev_get_event_code_name(ev->type, ev->code),
ev->value);

/* Ignore non-keypress events */
if ((ev->type != EV_KEY) && (ev->type != EV_SW)) {
goto EXIT;
Expand Down Expand Up @@ -981,6 +970,11 @@ static gboolean misc_iomon_cb(gpointer data, gsize bytes_read)
goto EXIT;
}

mce_log(LL_DEBUG, "type: %s, code: %s, value: %d",
evdev_get_event_type_name(ev->type),
evdev_get_event_code_name(ev->type, ev->code),
ev->value);

/* Ignore synchronisation, force feedback, LED,
* and force feedback status
*/
Expand Down

0 comments on commit fb09a80

Please sign in to comment.