Back to home page

LXR

 
 

    


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

0001 /**
0002  * @file
0003  *
0004  * @ingroup libmisc_fb_mw
0005  *
0006  * @brief Input Devices for MicroWindows
0007  *
0008  * This file defines the interface for input devices used by MicroWindows
0009  * in an embedded system environment.
0010  */
0011 
0012 /*
0013  * Copyright (c) 2000 - Rosimildo da Silva
0014  */
0015 
0016 #ifndef _MW_UID_H
0017 #define _MW_UID_H
0018 
0019 #include <sys/types.h>
0020 #include <rtems/print.h>
0021 
0022 /**
0023  *  @defgroup libmisc_fb_mw Input Devices for MicroWindows
0024  *
0025  *  @ingroup RTEMSDeviceDrivers
0026  */
0027 /**@{*/
0028 #ifdef __cplusplus
0029 extern "C" {
0030 #endif
0031 
0032 /* 0x41XX  -- IOCTL functions for the Micro Input Devices commands */
0033 #define MW_UID_REGISTER_DEVICE     0x4100
0034 #define MW_UID_UNREGISTER_DEVICE   0x4101
0035 
0036 /* devices supported by MicroWindows */
0037 enum MW_INPUT_DEVICE_TYPE {
0038   MV_UID_INVALID   = 0,
0039   MV_UID_REL_POS   = 1,   /* mouse        */
0040   MV_UID_ABS_POS   = 2,   /* touch-screen */
0041   MV_UID_KBD       = 3,   /* keyboard     */
0042   MV_UID_TIMER     = 4    /* timer -- not used */
0043 };
0044 
0045 /* matching MicroWindows */
0046 #define MV_BUTTON_RIGHT                 0x01
0047 #define MV_BUTTON_CENTER                0x02
0048 #define MV_BUTTON_LEFT                  0x04
0049 
0050 /* modifiers of the keyboard type devices */
0051 #define MV_KEY_MODIFIER_SHIFT_DOWN      0x10
0052 #define MV_KEY_MODIFIER_ALT_DOWN        0x20
0053 
0054 /* indication of the LEDS */
0055 #define MV_KEY_MODIFIER_CAPS_ON         0x04
0056 #define MV_KEY_MODIFIER_NUN_LOCK_ON     0x02
0057 #define MV_KEY_SCROLL_LOCK_ON           0x01
0058 
0059 /* keyboard modes -- default ASCII     */
0060 #define MV_KEY_MODE_ASCII               0x01
0061 /*
0062  * This mode one event is sent when a key is pressed,
0063  * and another one is send when a key is released.
0064  */
0065 #define MV_KEY_MODE_SCANCODE            0x00
0066 
0067 /* these defines match with the linux keyboard range
0068  * for ioctls functions for the keyboard interface.
0069  * 0x4BXX --- keyboard related functions
0070  */
0071 #define MV_KDGKBMODE  0x4B44   /* gets current keyboard mode */
0072 #define MV_KDSKBMODE  0x4B45   /* sets current keyboard mode */
0073 
0074 /*
0075  * Message generated by input devices controlled by MicroWindows.
0076  */
0077 struct MW_UID_MESSAGE {
0078   enum MW_INPUT_DEVICE_TYPE type;  /* device type */
0079   union {
0080     /* fired when keyboard events are raised */
0081     struct kbd_t {
0082       unsigned short code;        /* keycode or scancode        */
0083       unsigned char  modifiers;   /* key modifiers              */
0084       unsigned char  mode;        /* current Kbd mode           */
0085     } kbd;
0086 
0087     /* fired when position events are raised, mouse, touch screen, etc */
0088     struct pos_t {
0089       unsigned short btns; /* indicates which buttons are pressed */
0090       short x;             /* x location */
0091       short y;             /* y location */
0092       short z;             /* z location, 0 for 2D */
0093     } pos;
0094 
0095     /* fired by a timer device periodically */
0096     struct timer_t {
0097       unsigned long  frt;   /* free running timer */
0098       unsigned long  seq;   /* sequence number */
0099     } tmr;
0100   } m;
0101 };
0102 
0103 
0104 /*
0105  * API for creating/closing/accessing the message queue used by the micro
0106  * input device interface. All functions in this interface returns a
0107  * zero ( 0 ) on success. One exception for that is the "read" routine
0108  * that returns the number of bytes read. Negaive numbers indicate errors
0109  *
0110  * The implementation of the message queue for RTEMS uses a POSIX message
0111  * queue interface. It should be very portable among systems with a POSIX
0112  * support.
0113  */
0114 
0115 /**
0116  * This method creates the message queue that holds events from the
0117  * input devices.
0118  *
0119  * @param[in] q_name is the name of the message queue
0120  * @param[in] flags controls the behaviour of the queue
0121  * @param[in] max_msgs specifies the maximum number of pending messages
0122  *
0123  * @note The message queue is from the Classic API.
0124  *
0125  * @retval This method returns 0 on success and -1 on error.
0126  */
0127 extern int uid_open_queue( const char *q_name, int flags, size_t max_msgs );
0128 
0129 /**
0130  * This method closes the message queue and deletes it.
0131  *
0132  * @retval This method returns 0 on success and -1 on error.
0133  */
0134 extern int uid_close_queue( void );
0135 
0136 /**
0137  * This method reads a message from the queue. It waits up to the specified
0138  * timeout in miliseconds. A @a timeout of 0 is a poll.
0139  *
0140  * @param[in] m will be filled in with the received message
0141  * @param[in] timeout is the maximum number of mulliseconds to wait
0142  *
0143  * @retval This method returns 0 on success and -1 on error.
0144  */
0145 extern int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout );
0146 
0147 /**
0148  * This methods writes a message to the queue.
0149  *
0150  * @param[in] m is the message to send
0151  *
0152  * @retval This method returns 0 on success and -1 on error.
0153  */
0154 extern int uid_send_message( struct MW_UID_MESSAGE *m );
0155 
0156 /**
0157  *  This method registers the device associated with @a fd to
0158  *  to insert data to the queue
0159  */
0160 extern int uid_register_device( int fd, const char *q_name );
0161 
0162 /* unregister device to stop adding messages to the queue */
0163 extern int uid_unregister_device( int fd );
0164 
0165 /* set the keyboard */
0166 extern int uid_set_kbd_mode( int fd, int mode, int *old_mode );
0167 
0168 /**
0169  * This methods prints the specified UID message using printk
0170  *
0171  * @param[in] uid points to the message to print
0172  */
0173 void uid_print_message(
0174   struct MW_UID_MESSAGE *uid
0175 );
0176 
0177 /**
0178  * This methods prints the specified UID message using your fprintf
0179  * style method of choice.
0180  *
0181  * @param[in] RTEMS printer
0182  * @param[in] uid points to the message to print
0183  */
0184 void uid_print_message_with_plugin(
0185   const rtems_printer   *printer,
0186   struct MW_UID_MESSAGE *uid
0187 );
0188 
0189 #ifdef __cplusplus
0190 }
0191 #endif
0192 /**@}*/
0193 #endif /* _MW_UID_H */