Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:18

0001 /**
0002  * @file
0003  *
0004  * @ingroup libmisc_fb_mw Input Devices for MicroWindows
0005  *
0006  * @brief MicroWindows Print
0007  */
0008 
0009 /*
0010  *  COPYRIGHT (c) 1989-2011.
0011  *  On-Line Applications Research Corporation (OAR).
0012  *
0013  *  The license and distribution terms for this file may be
0014  *  found in the file LICENSE in this distribution or at
0015  *  http://www.rtems.org/license/LICENSE.
0016  */
0017 
0018 #ifdef HAVE_CONFIG_H
0019 #include "config.h"
0020 #endif
0021 
0022 #include <stdio.h>
0023 
0024 #include <rtems/mw_uid.h>
0025 #include <rtems/printer.h>
0026 
0027 static const char *uid_buttons(
0028   unsigned short  btns,
0029   char           *buffer,
0030   size_t          max
0031 )
0032 {
0033   snprintf(
0034     buffer,
0035     max,
0036     "LEFT=%s CENTER=%s RIGHT=%s",
0037     ((btns & MV_BUTTON_LEFT) ? "down" : "up"),
0038     ((btns & MV_BUTTON_CENTER) ? "down" : "up"),
0039     ((btns & MV_BUTTON_RIGHT) ? "down" : "up")
0040   );
0041   return buffer;
0042 }
0043 
0044 void uid_print_message(
0045   struct MW_UID_MESSAGE *uid
0046 )
0047 {
0048   rtems_printer printer;
0049   rtems_print_printer_printk(&printer);
0050   uid_print_message_with_plugin( &printer, uid );
0051 }
0052 
0053 void uid_print_message_with_plugin(
0054   const rtems_printer   *printer,
0055   struct MW_UID_MESSAGE *uid
0056 )
0057 {
0058   char buttons[80];
0059 
0060   switch (uid->type) {
0061     case MV_UID_INVALID:
0062       rtems_printf( printer, "MV_UID_INVALID\n" );
0063       break;
0064     case MV_UID_REL_POS:
0065       rtems_printf(
0066         printer,
0067         "MV_UID_REL_POS - %s x=%d y=%d z=%d\n",
0068         uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
0069         uid->m.pos.x,    /* x location */
0070         uid->m.pos.y,    /* y location */
0071         uid->m.pos.z     /* z location, 0 for 2D */
0072       );
0073       break;
0074     case MV_UID_ABS_POS:
0075       rtems_printf(
0076         printer,
0077         "MV_UID_ABS_POS - %s x=%d y=%d z=%d\n",
0078         uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
0079         uid->m.pos.x,    /* x location */
0080         uid->m.pos.y,    /* y location */
0081         uid->m.pos.z     /* z location, 0 for 2D */
0082       );
0083       break;
0084     case MV_UID_KBD:
0085       rtems_printf( printer,
0086         "MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n",
0087         uid->m.kbd.code,        /* keycode or scancode        */
0088         uid->m.kbd.modifiers,   /* key modifiers              */
0089         uid->m.kbd.mode         /* current Kbd mode           */
0090       );
0091       break;
0092    case MV_UID_TIMER:
0093       rtems_printf( printer, "MV_UID_TIMER\n" );
0094       break;
0095     default:
0096       rtems_printf( printer, "Invalid device type\n" );
0097       break;
0098   }
0099 
0100 }