[21242c2] | 1 | /** |
---|
| 2 | * @file rtems/mw_uid.h |
---|
[957d886] | 3 | * |
---|
[a163882] | 4 | * @defgroup libmisc_fb_mw Input Devices for MicroWindows |
---|
[9ab091e] | 5 | * |
---|
[a163882] | 6 | * @ingroup libmisc |
---|
| 7 | * @brief Input Devices for MicroWindows |
---|
| 8 | * |
---|
| 9 | * This file defines the interface for input devices used by MicroWindows |
---|
| 10 | * in an embedded system environment. |
---|
[21242c2] | 11 | */ |
---|
| 12 | |
---|
| 13 | /* |
---|
| 14 | * Copyright (c) 2000 - Rosimildo da Silva |
---|
[957d886] | 15 | */ |
---|
| 16 | |
---|
[152b1e3] | 17 | #ifndef _MW_UID_H |
---|
| 18 | #define _MW_UID_H |
---|
| 19 | |
---|
[d18d5890] | 20 | #include <sys/types.h> |
---|
[24d0ee57] | 21 | #include <rtems/print.h> |
---|
[d18d5890] | 22 | |
---|
[f5f2676] | 23 | /** |
---|
| 24 | * @defgroup libmisc_fb_mw Input Devices for MicroWindows |
---|
| 25 | * |
---|
| 26 | * @ingroup libmisc |
---|
| 27 | */ |
---|
| 28 | /**@{*/ |
---|
[d18d5890] | 29 | #ifdef __cplusplus |
---|
[152b1e3] | 30 | extern "C" { |
---|
| 31 | #endif |
---|
| 32 | |
---|
[d18d5890] | 33 | /* 0x41XX -- IOCTL functions for the Micro Input Devices commands */ |
---|
[152b1e3] | 34 | #define MW_UID_REGISTER_DEVICE 0x4100 |
---|
| 35 | #define MW_UID_UNREGISTER_DEVICE 0x4101 |
---|
| 36 | |
---|
| 37 | /* devices supported by MicroWindows */ |
---|
[d18d5890] | 38 | enum MW_INPUT_DEVICE_TYPE { |
---|
| 39 | MV_UID_INVALID = 0, |
---|
| 40 | MV_UID_REL_POS = 1, /* mouse */ |
---|
| 41 | MV_UID_ABS_POS = 2, /* touch-screen */ |
---|
| 42 | MV_UID_KBD = 3, /* keyboard */ |
---|
| 43 | MV_UID_TIMER = 4 /* timer -- not used */ |
---|
[152b1e3] | 44 | }; |
---|
| 45 | |
---|
| 46 | /* matching MicroWindows */ |
---|
| 47 | #define MV_BUTTON_RIGHT 0x01 |
---|
| 48 | #define MV_BUTTON_CENTER 0x02 |
---|
| 49 | #define MV_BUTTON_LEFT 0x04 |
---|
| 50 | |
---|
| 51 | /* modifiers of the keyboard type devices */ |
---|
| 52 | #define MV_KEY_MODIFIER_SHIFT_DOWN 0x10 |
---|
| 53 | #define MV_KEY_MODIFIER_ALT_DOWN 0x20 |
---|
| 54 | |
---|
| 55 | /* indication of the LEDS */ |
---|
| 56 | #define MV_KEY_MODIFIER_CAPS_ON 0x04 |
---|
| 57 | #define MV_KEY_MODIFIER_NUN_LOCK_ON 0x02 |
---|
| 58 | #define MV_KEY_SCROLL_LOCK_ON 0x01 |
---|
| 59 | |
---|
| 60 | /* keyboard modes -- default ASCII */ |
---|
| 61 | #define MV_KEY_MODE_ASCII 0x01 |
---|
[aed742c] | 62 | /* |
---|
[152b1e3] | 63 | * This mode one event is sent when a key is pressed, |
---|
| 64 | * and another one is send when a key is released. |
---|
| 65 | */ |
---|
| 66 | #define MV_KEY_MODE_SCANCODE 0x00 |
---|
| 67 | |
---|
| 68 | /* these defines match with the linux keyboard range |
---|
[d18d5890] | 69 | * for ioctls functions for the keyboard interface. |
---|
| 70 | * 0x4BXX --- keyboard related functions |
---|
[152b1e3] | 71 | */ |
---|
[d18d5890] | 72 | #define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */ |
---|
| 73 | #define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */ |
---|
[152b1e3] | 74 | |
---|
| 75 | /* |
---|
[aed742c] | 76 | * Message generated by input devices controlled by MicroWindows. |
---|
[152b1e3] | 77 | */ |
---|
[d18d5890] | 78 | struct MW_UID_MESSAGE { |
---|
[152b1e3] | 79 | enum MW_INPUT_DEVICE_TYPE type; /* device type */ |
---|
[d18d5890] | 80 | union { |
---|
| 81 | /* fired when keyboard events are raised */ |
---|
| 82 | struct kbd_t { |
---|
| 83 | unsigned short code; /* keycode or scancode */ |
---|
| 84 | unsigned char modifiers; /* key modifiers */ |
---|
| 85 | unsigned char mode; /* current Kbd mode */ |
---|
[152b1e3] | 86 | } kbd; |
---|
| 87 | |
---|
| 88 | /* fired when position events are raised, mouse, touch screen, etc */ |
---|
| 89 | struct pos_t { |
---|
[d18d5890] | 90 | unsigned short btns; /* indicates which buttons are pressed */ |
---|
| 91 | short x; /* x location */ |
---|
| 92 | short y; /* y location */ |
---|
| 93 | short z; /* z location, 0 for 2D */ |
---|
[152b1e3] | 94 | } pos; |
---|
| 95 | |
---|
| 96 | /* fired by a timer device periodically */ |
---|
| 97 | struct timer_t { |
---|
[d18d5890] | 98 | unsigned long frt; /* free running timer */ |
---|
| 99 | unsigned long seq; /* sequence number */ |
---|
[152b1e3] | 100 | } tmr; |
---|
| 101 | } m; |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | /* |
---|
| 106 | * API for creating/closing/accessing the message queue used by the micro |
---|
[aed742c] | 107 | * input device interface. All functions in this interface returns a |
---|
[152b1e3] | 108 | * zero ( 0 ) on success. One exception for that is the "read" routine |
---|
| 109 | * that returns the number of bytes read. Negaive numbers indicate errors |
---|
| 110 | * |
---|
| 111 | * The implementation of the message queue for RTEMS uses a POSIX message |
---|
| 112 | * queue interface. It should be very portable among systems with a POSIX |
---|
| 113 | * support. |
---|
| 114 | */ |
---|
| 115 | |
---|
[d18d5890] | 116 | /** |
---|
[a163882] | 117 | * This method creates the message queue that holds events from the |
---|
| 118 | * input devices. |
---|
[d18d5890] | 119 | * |
---|
[a163882] | 120 | * @param[in] q_name is the name of the message queue |
---|
| 121 | * @param[in] flags controls the behaviour of the queue |
---|
| 122 | * @param[in] max_msgs specifies the maximum number of pending messages |
---|
[d18d5890] | 123 | * |
---|
[a163882] | 124 | * @note The message queue is from the Classic API. |
---|
[d18d5890] | 125 | * |
---|
[a163882] | 126 | * @retval This method returns 0 on success and -1 on error. |
---|
[d18d5890] | 127 | */ |
---|
[152b1e3] | 128 | extern int uid_open_queue( const char *q_name, int flags, size_t max_msgs ); |
---|
| 129 | |
---|
[d18d5890] | 130 | /** |
---|
[a163882] | 131 | * This method closes the message queue and deletes it. |
---|
[d18d5890] | 132 | * |
---|
[a163882] | 133 | * @retval This method returns 0 on success and -1 on error. |
---|
[d18d5890] | 134 | */ |
---|
[152b1e3] | 135 | extern int uid_close_queue( void ); |
---|
| 136 | |
---|
[d18d5890] | 137 | /** |
---|
[a163882] | 138 | * This method reads a message from the queue. It waits up to the specified |
---|
| 139 | * timeout in miliseconds. A @a timeout of 0 is a poll. |
---|
[d18d5890] | 140 | * |
---|
[a163882] | 141 | * @param[in] m will be filled in with the received message |
---|
| 142 | * @param[in] timeout is the maximum number of mulliseconds to wait |
---|
[d18d5890] | 143 | * |
---|
[a163882] | 144 | * @retval This method returns 0 on success and -1 on error. |
---|
[152b1e3] | 145 | */ |
---|
| 146 | extern int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout ); |
---|
| 147 | |
---|
[d18d5890] | 148 | /** |
---|
[a163882] | 149 | * This methods writes a message to the queue. |
---|
[d18d5890] | 150 | * |
---|
[a163882] | 151 | * @param[in] m is the message to send |
---|
[d18d5890] | 152 | * |
---|
[a163882] | 153 | * @retval This method returns 0 on success and -1 on error. |
---|
[d18d5890] | 154 | */ |
---|
| 155 | extern int uid_send_message( struct MW_UID_MESSAGE *m ); |
---|
[152b1e3] | 156 | |
---|
[d18d5890] | 157 | /** |
---|
| 158 | * This method registers the device associated with @a fd to |
---|
| 159 | * to insert data to the queue |
---|
| 160 | */ |
---|
[152b1e3] | 161 | extern int uid_register_device( int fd, const char *q_name ); |
---|
| 162 | |
---|
| 163 | /* unregister device to stop adding messages to the queue */ |
---|
| 164 | extern int uid_unregister_device( int fd ); |
---|
| 165 | |
---|
| 166 | /* set the keyboard */ |
---|
| 167 | extern int uid_set_kbd_mode( int fd, int mode, int *old_mode ); |
---|
| 168 | |
---|
[d18d5890] | 169 | /** |
---|
[a163882] | 170 | * This methods prints the specified UID message using printk |
---|
[d18d5890] | 171 | * |
---|
[a163882] | 172 | * @param[in] uid points to the message to print |
---|
[d18d5890] | 173 | */ |
---|
| 174 | void uid_print_message( |
---|
| 175 | struct MW_UID_MESSAGE *uid |
---|
| 176 | ); |
---|
| 177 | |
---|
| 178 | /** |
---|
[a163882] | 179 | * This methods prints the specified UID message using your fprintf |
---|
| 180 | * style method of choice. |
---|
[d18d5890] | 181 | * |
---|
[24d0ee57] | 182 | * @param[in] RTEMS printer |
---|
[a163882] | 183 | * @param[in] uid points to the message to print |
---|
[d18d5890] | 184 | */ |
---|
| 185 | void uid_print_message_with_plugin( |
---|
[24d0ee57] | 186 | const rtems_printer *printer, |
---|
[d18d5890] | 187 | struct MW_UID_MESSAGE *uid |
---|
| 188 | ); |
---|
| 189 | |
---|
| 190 | #ifdef __cplusplus |
---|
[152b1e3] | 191 | } |
---|
| 192 | #endif |
---|
[f5f2676] | 193 | /**@}*/ |
---|
[152b1e3] | 194 | #endif /* _MW_UID_H */ |
---|