1 | /** |
---|
2 | * @file rtems/mw_uid.h |
---|
3 | * |
---|
4 | * @defgroup libmisc_fb_mw Input Devices for MicroWindows |
---|
5 | * |
---|
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. |
---|
11 | */ |
---|
12 | |
---|
13 | /* |
---|
14 | * Copyright (c) 2000 - Rosimildo da Silva |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _MW_UID_H |
---|
18 | #define _MW_UID_H |
---|
19 | |
---|
20 | #include <sys/types.h> |
---|
21 | #include <rtems/print.h> |
---|
22 | |
---|
23 | /** |
---|
24 | * @defgroup libmisc_fb_mw Input Devices for MicroWindows |
---|
25 | * |
---|
26 | * @ingroup libmisc |
---|
27 | */ |
---|
28 | /**@{*/ |
---|
29 | #ifdef __cplusplus |
---|
30 | extern "C" { |
---|
31 | #endif |
---|
32 | |
---|
33 | /* 0x41XX -- IOCTL functions for the Micro Input Devices commands */ |
---|
34 | #define MW_UID_REGISTER_DEVICE 0x4100 |
---|
35 | #define MW_UID_UNREGISTER_DEVICE 0x4101 |
---|
36 | |
---|
37 | /* devices supported by MicroWindows */ |
---|
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 */ |
---|
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 |
---|
62 | /* |
---|
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 |
---|
69 | * for ioctls functions for the keyboard interface. |
---|
70 | * 0x4BXX --- keyboard related functions |
---|
71 | */ |
---|
72 | #define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */ |
---|
73 | #define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */ |
---|
74 | |
---|
75 | /* |
---|
76 | * Message generated by input devices controlled by MicroWindows. |
---|
77 | */ |
---|
78 | struct MW_UID_MESSAGE { |
---|
79 | enum MW_INPUT_DEVICE_TYPE type; /* device type */ |
---|
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 */ |
---|
86 | } kbd; |
---|
87 | |
---|
88 | /* fired when position events are raised, mouse, touch screen, etc */ |
---|
89 | struct pos_t { |
---|
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 */ |
---|
94 | } pos; |
---|
95 | |
---|
96 | /* fired by a timer device periodically */ |
---|
97 | struct timer_t { |
---|
98 | unsigned long frt; /* free running timer */ |
---|
99 | unsigned long seq; /* sequence number */ |
---|
100 | } tmr; |
---|
101 | } m; |
---|
102 | }; |
---|
103 | |
---|
104 | |
---|
105 | /* |
---|
106 | * API for creating/closing/accessing the message queue used by the micro |
---|
107 | * input device interface. All functions in this interface returns a |
---|
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 | |
---|
116 | /** |
---|
117 | * This method creates the message queue that holds events from the |
---|
118 | * input devices. |
---|
119 | * |
---|
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 |
---|
123 | * |
---|
124 | * @note The message queue is from the Classic API. |
---|
125 | * |
---|
126 | * @retval This method returns 0 on success and -1 on error. |
---|
127 | */ |
---|
128 | extern int uid_open_queue( const char *q_name, int flags, size_t max_msgs ); |
---|
129 | |
---|
130 | /** |
---|
131 | * This method closes the message queue and deletes it. |
---|
132 | * |
---|
133 | * @retval This method returns 0 on success and -1 on error. |
---|
134 | */ |
---|
135 | extern int uid_close_queue( void ); |
---|
136 | |
---|
137 | /** |
---|
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. |
---|
140 | * |
---|
141 | * @param[in] m will be filled in with the received message |
---|
142 | * @param[in] timeout is the maximum number of mulliseconds to wait |
---|
143 | * |
---|
144 | * @retval This method returns 0 on success and -1 on error. |
---|
145 | */ |
---|
146 | extern int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout ); |
---|
147 | |
---|
148 | /** |
---|
149 | * This methods writes a message to the queue. |
---|
150 | * |
---|
151 | * @param[in] m is the message to send |
---|
152 | * |
---|
153 | * @retval This method returns 0 on success and -1 on error. |
---|
154 | */ |
---|
155 | extern int uid_send_message( struct MW_UID_MESSAGE *m ); |
---|
156 | |
---|
157 | /** |
---|
158 | * This method registers the device associated with @a fd to |
---|
159 | * to insert data to the queue |
---|
160 | */ |
---|
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 | |
---|
169 | /** |
---|
170 | * This methods prints the specified UID message using printk |
---|
171 | * |
---|
172 | * @param[in] uid points to the message to print |
---|
173 | */ |
---|
174 | void uid_print_message( |
---|
175 | struct MW_UID_MESSAGE *uid |
---|
176 | ); |
---|
177 | |
---|
178 | /** |
---|
179 | * This methods prints the specified UID message using your fprintf |
---|
180 | * style method of choice. |
---|
181 | * |
---|
182 | * @param[in] RTEMS printer |
---|
183 | * @param[in] uid points to the message to print |
---|
184 | */ |
---|
185 | void uid_print_message_with_plugin( |
---|
186 | const rtems_printer *printer, |
---|
187 | struct MW_UID_MESSAGE *uid |
---|
188 | ); |
---|
189 | |
---|
190 | #ifdef __cplusplus |
---|
191 | } |
---|
192 | #endif |
---|
193 | /**@}*/ |
---|
194 | #endif /* _MW_UID_H */ |
---|