1 | /* |
---|
2 | ///////////////////////////////////////////////////////////////////////////// |
---|
3 | // $Header$ |
---|
4 | // |
---|
5 | // Copyright (c) 2000 - Rosimildo da Silva |
---|
6 | // |
---|
7 | // MODULE DESCRIPTION: |
---|
8 | // This module defines the interface for input devices used by MicroWindows |
---|
9 | // in an embedded system environment. |
---|
10 | // |
---|
11 | // MODIFICATION/HISTORY: |
---|
12 | // |
---|
13 | // $Log$ |
---|
14 | // |
---|
15 | ///////////////////////////////////////////////////////////////////////////// |
---|
16 | */ |
---|
17 | #ifndef _MW_UID_H |
---|
18 | #define _MW_UID_H |
---|
19 | |
---|
20 | #ifdef __cplusplus |
---|
21 | extern "C" { |
---|
22 | #endif |
---|
23 | |
---|
24 | /* 0x41XX -- IOCLT functions for the Micro Input Devices commands */ |
---|
25 | #define MW_UID_REGISTER_DEVICE 0x4100 |
---|
26 | #define MW_UID_UNREGISTER_DEVICE 0x4101 |
---|
27 | |
---|
28 | |
---|
29 | /* devices supported by MicroWindows */ |
---|
30 | enum MW_INPUT_DEVICE_TYPE |
---|
31 | { |
---|
32 | MV_UID_INVALID = 0, |
---|
33 | MV_UID_REL_POS = 1, /* mouse */ |
---|
34 | MV_UID_ABS_POS = 2, /* touch-screen */ |
---|
35 | MV_UID_KBD = 3, /* keyboard */ |
---|
36 | MV_UID_TIMER = 4 /* timer -- not used */ |
---|
37 | }; |
---|
38 | |
---|
39 | |
---|
40 | /* matching MicroWindows */ |
---|
41 | #define MV_BUTTON_RIGHT 0x01 |
---|
42 | #define MV_BUTTON_CENTER 0x02 |
---|
43 | #define MV_BUTTON_LEFT 0x04 |
---|
44 | |
---|
45 | /* modifiers of the keyboard type devices */ |
---|
46 | #define MV_KEY_MODIFIER_SHIFT_DOWN 0x10 |
---|
47 | #define MV_KEY_MODIFIER_ALT_DOWN 0x20 |
---|
48 | |
---|
49 | /* indication of the LEDS */ |
---|
50 | #define MV_KEY_MODIFIER_CAPS_ON 0x04 |
---|
51 | #define MV_KEY_MODIFIER_NUN_LOCK_ON 0x02 |
---|
52 | #define MV_KEY_SCROLL_LOCK_ON 0x01 |
---|
53 | |
---|
54 | /* keyboard modes -- default ASCII */ |
---|
55 | #define MV_KEY_MODE_ASCII 0x01 |
---|
56 | /* |
---|
57 | * This mode one event is sent when a key is pressed, |
---|
58 | * and another one is send when a key is released. |
---|
59 | */ |
---|
60 | #define MV_KEY_MODE_SCANCODE 0x00 |
---|
61 | |
---|
62 | |
---|
63 | /* these defines match with the linux keyboard range |
---|
64 | for ioctls functions for the keyboard interface. |
---|
65 | 0x4BXX --- keyboard related functions |
---|
66 | */ |
---|
67 | #define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */ |
---|
68 | #define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */ |
---|
69 | |
---|
70 | /* |
---|
71 | * Message generated by input devices controlled by MicroWindows. |
---|
72 | */ |
---|
73 | struct MW_UID_MESSAGE |
---|
74 | { |
---|
75 | enum MW_INPUT_DEVICE_TYPE type; /* device type */ |
---|
76 | union |
---|
77 | { |
---|
78 | /* fired when keyboard events are raised */ |
---|
79 | struct kbd_t { |
---|
80 | unsigned short code; /* keycode or scancode */ |
---|
81 | unsigned char modifiers; /* key modifiers */ |
---|
82 | unsigned char mode; /* current Kbd mode */ |
---|
83 | } kbd; |
---|
84 | |
---|
85 | /* fired when position events are raised, mouse, touch screen, etc */ |
---|
86 | struct pos_t { |
---|
87 | unsigned short btns; /* indicates which buttons are pressed */ |
---|
88 | short x; /* x location */ |
---|
89 | short y; /* y location */ |
---|
90 | short z; /* z location, 0 for 2D */ |
---|
91 | } pos; |
---|
92 | |
---|
93 | /* fired by a timer device periodically */ |
---|
94 | struct timer_t { |
---|
95 | unsigned long frt; /* free running timer */ |
---|
96 | unsigned long seq; /* sequence number */ |
---|
97 | } tmr; |
---|
98 | |
---|
99 | } m; |
---|
100 | }; |
---|
101 | |
---|
102 | |
---|
103 | /* |
---|
104 | * API for creating/closing/accessing the message queue used by the micro |
---|
105 | * input device interface. All functions in this interface returns a |
---|
106 | * zero ( 0 ) on success. One exception for that is the "read" routine |
---|
107 | * that returns the number of bytes read. Negaive numbers indicate errors |
---|
108 | * |
---|
109 | * The implementation of the message queue for RTEMS uses a POSIX message |
---|
110 | * queue interface. It should be very portable among systems with a POSIX |
---|
111 | * support. |
---|
112 | */ |
---|
113 | |
---|
114 | /* creates the message queue that holds events from the input devices */ |
---|
115 | extern int uid_open_queue( const char *q_name, int flags, size_t max_msgs ); |
---|
116 | |
---|
117 | /* closes message queue */ |
---|
118 | extern int uid_close_queue( void ); |
---|
119 | |
---|
120 | /* |
---|
121 | * reads a message from the queue. It waits up to the specified |
---|
122 | * timeout in mili-seconds. |
---|
123 | */ |
---|
124 | extern int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout ); |
---|
125 | |
---|
126 | /* write a message to the queue */ |
---|
127 | extern int uid_write_message( struct MW_UID_MESSAGE *m ); |
---|
128 | |
---|
129 | |
---|
130 | /* register device to insert data to the queue */ |
---|
131 | extern int uid_register_device( int fd, const char *q_name ); |
---|
132 | |
---|
133 | /* unregister device to stop adding messages to the queue */ |
---|
134 | extern int uid_unregister_device( int fd ); |
---|
135 | |
---|
136 | /* set the keyboard */ |
---|
137 | extern int uid_set_kbd_mode( int fd, int mode, int *old_mode ); |
---|
138 | |
---|
139 | #ifdef __cplusplus |
---|
140 | } |
---|
141 | #endif |
---|
142 | |
---|
143 | #endif /* _MW_UID_H */ |
---|