From d18d5890abf09a2c75e985e688fb2baa6e0bfdc3 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 17 Feb 2011 19:24:20 +0000 Subject: 2011-02-17 Joel Sherrill * libmisc/Makefile.am, libmisc/fb/mw_uid.c, libmisc/fb/mw_uid.h: Clean up. Add Doxygen style comments. Add method to print uid structure. * libmisc/fb/mw_print.c: New file. --- cpukit/libmisc/fb/mw_print.c | 92 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 cpukit/libmisc/fb/mw_print.c (limited to 'cpukit/libmisc/fb/mw_print.c') diff --git a/cpukit/libmisc/fb/mw_print.c b/cpukit/libmisc/fb/mw_print.c new file mode 100644 index 0000000000..4e8abf2bd8 --- /dev/null +++ b/cpukit/libmisc/fb/mw_print.c @@ -0,0 +1,92 @@ +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +const char *uid_buttons( + unsigned short btns, + char *buffer, + size_t max +) +{ + snprintf( + buffer, + max, + "LEFT=%s CENTER=%s RIGHT=%s", + ((btns & MV_BUTTON_LEFT) ? "down" : "up"), + ((btns & MV_BUTTON_CENTER) ? "down" : "up"), + ((btns & MV_BUTTON_RIGHT) ? "down" : "up") + ); + return buffer; +} + +void uid_print_message( + struct MW_UID_MESSAGE *uid +) +{ + uid_print_message_with_plugin( NULL, printk_plugin, uid ); +} + +void uid_print_message_with_plugin( + void *context, + rtems_printk_plugin_t handler, + struct MW_UID_MESSAGE *uid +) +{ + char buttons[80]; + + switch (uid->type) { + case MV_UID_INVALID: + (*handler)( context, "MV_UID_INVALID\n" ); + break; + case MV_UID_REL_POS: + (*handler)( + context, + "MV_UID_REL_POS - %s x=%d y=%d z=%d\n", + uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)), + uid->m.pos.x, /* x location */ + uid->m.pos.y, /* y location */ + uid->m.pos.z /* z location, 0 for 2D */ + ); + break; + case MV_UID_ABS_POS: + (*handler)( + context, + "MV_UID_ABS_POS - %s x=%d y=%d z=%d\n", + uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)), + uid->m.pos.x, /* x location */ + uid->m.pos.y, /* y location */ + uid->m.pos.z /* z location, 0 for 2D */ + ); + break; + case MV_UID_KBD: + (*handler)( context, + "MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n", + uid->m.kbd.code, /* keycode or scancode */ + uid->m.kbd.modifiers, /* key modifiers */ + uid->m.kbd.mode /* current Kbd mode */ + ); + break; + case MV_UID_TIMER: + (*handler)( context, "MV_UID_TIMER\n" ); + break; + default: + (*handler)( context, "Invalid device type\n" ); + break; + } + +} + -- cgit v1.2.3