source: rtems/cpukit/libmisc/fb/mw_print.c @ 506bfc8

5
Last change on this file since 506bfc8 was 506bfc8, checked in by Sebastian Huber <sebastian.huber@…>, on 06/21/16 at 11:30:15

Move printer initialization to separate header

The RTEMS print user need to know nothing about a particular printer
implementation. In particular get rid of the <stdio.h> include which
would be visible via <rtems.h>.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief MicroWindows Print
5 * @ingroup libmisc_fb_mw Input Devices for MicroWindows
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <stdio.h>
22
23#include <rtems/mw_uid.h>
24#include <rtems/printer.h>
25
26static const char *uid_buttons(
27  unsigned short  btns,
28  char           *buffer,
29  size_t          max
30)
31{
32  snprintf(
33    buffer,
34    max,
35    "LEFT=%s CENTER=%s RIGHT=%s",
36    ((btns & MV_BUTTON_LEFT) ? "down" : "up"),
37    ((btns & MV_BUTTON_CENTER) ? "down" : "up"),
38    ((btns & MV_BUTTON_RIGHT) ? "down" : "up")
39  );
40  return buffer;
41}
42
43void uid_print_message(
44  struct MW_UID_MESSAGE *uid
45)
46{
47  rtems_printer printer;
48  rtems_print_printer_printk(&printer);
49  uid_print_message_with_plugin( &printer, uid );
50}
51
52void uid_print_message_with_plugin(
53  const rtems_printer   *printer,
54  struct MW_UID_MESSAGE *uid
55)
56{
57  char buttons[80];
58
59  switch (uid->type) {
60    case MV_UID_INVALID:
61      rtems_printf( printer, "MV_UID_INVALID\n" );
62      break;
63    case MV_UID_REL_POS:
64      rtems_printf(
65        printer,
66        "MV_UID_REL_POS - %s x=%d y=%d z=%d\n",
67        uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
68        uid->m.pos.x,    /* x location */
69        uid->m.pos.y,    /* y location */
70        uid->m.pos.z     /* z location, 0 for 2D */
71      );
72      break;
73    case MV_UID_ABS_POS:
74      rtems_printf(
75        printer,
76        "MV_UID_ABS_POS - %s x=%d y=%d z=%d\n",
77        uid_buttons( uid->m.pos.btns, buttons, sizeof(buttons)),
78        uid->m.pos.x,    /* x location */
79        uid->m.pos.y,    /* y location */
80        uid->m.pos.z     /* z location, 0 for 2D */
81      );
82      break;
83    case MV_UID_KBD:
84      rtems_printf( printer,
85        "MV_UID_KBD - code=0x%04x modifiers=0x%02x mode=0x%02x\n",
86        uid->m.kbd.code,        /* keycode or scancode        */
87        uid->m.kbd.modifiers,   /* key modifiers              */
88        uid->m.kbd.mode         /* current Kbd mode           */
89      );
90      break;
91   case MV_UID_TIMER:
92      rtems_printf( printer, "MV_UID_TIMER\n" );
93      break;
94    default:
95      rtems_printf( printer, "Invalid device type\n" );
96      break;
97  }
98
99}
Note: See TracBrowser for help on using the repository browser.