1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at qt-info@nokia.com.
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \page qt-embedded-pointer.html
|
---|
30 |
|
---|
31 | \title Qt for Embedded Linux Pointer Handling
|
---|
32 | \ingroup qt-embedded-linux
|
---|
33 |
|
---|
34 | When running a \l{Qt for Embedded Linux} application, it either runs as a
|
---|
35 | server or connects to an existing server. The mouse driver is
|
---|
36 | loaded by the server application when it starts running, using
|
---|
37 | Qt's \l {How to Create Qt Plugins}{plugin system}.
|
---|
38 |
|
---|
39 | Internally in the client/server protocol, all system generated
|
---|
40 | events, including pointer events, are passed to the server
|
---|
41 | application which then propagates the event to the appropriate
|
---|
42 | client. Note that pointer handling in \l{Qt for Embedded Linux} works for
|
---|
43 | both mouse and mouse-like devices such as touch panels and
|
---|
44 | trackballs.
|
---|
45 |
|
---|
46 | Contents:
|
---|
47 |
|
---|
48 | \tableofcontents
|
---|
49 |
|
---|
50 | \section1 Available Drivers
|
---|
51 |
|
---|
52 | \l{Qt for Embedded Linux} provides ready-made drivers for the MouseMan,
|
---|
53 | IntelliMouse, Microsoft and Linux Touch Panel protocols, for the
|
---|
54 | standard Linux Input Subsystem as well as the universal touch screen
|
---|
55 | library, tslib. Run the \c configure script to list the available
|
---|
56 | drivers:
|
---|
57 |
|
---|
58 | \if defined(QTOPIA_PHONE)
|
---|
59 |
|
---|
60 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 0
|
---|
61 |
|
---|
62 | \bold{Note:} By default only the PC mouse driver is enabled.
|
---|
63 |
|
---|
64 | The various drivers can be enabled and disabled using the \c
|
---|
65 | configure script. For example:
|
---|
66 |
|
---|
67 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 1
|
---|
68 |
|
---|
69 | \else
|
---|
70 |
|
---|
71 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 2
|
---|
72 |
|
---|
73 | In the default Qt configuration, only the "pc" mouse driver is
|
---|
74 | enabled. The various drivers can be enabled and disabled using
|
---|
75 | the \c configure script. For example:
|
---|
76 |
|
---|
77 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 3
|
---|
78 | \endif
|
---|
79 |
|
---|
80 | Custom mouse drivers can be implemented by subclassing the
|
---|
81 | QWSMouseHandler class and creating a mouse driver plugin (derived
|
---|
82 | from the QMouseDriverPlugin class). The default implementation of the
|
---|
83 | QMouseDriverFactory class will automatically detect the plugin,
|
---|
84 | loading the driver into the server application at run-time.
|
---|
85 |
|
---|
86 | If you are creating a driver for a device that needs calibration
|
---|
87 | or noise reduction, such as a touchscreen, derive from the
|
---|
88 | QWSCalibratedMouseHandler subclass instead to take advantage of
|
---|
89 | its calibration functionality.
|
---|
90 |
|
---|
91 | \if defined(QTOPIA_PHONE)
|
---|
92 | For a tutorial on how to add a new keyboard driver plug-in
|
---|
93 | see: \l {Tutorial: Implementing a Device Plug-in}.
|
---|
94 | \endif
|
---|
95 |
|
---|
96 | \section1 Specifying a Driver
|
---|
97 |
|
---|
98 | Provided that the "pc" mouse driver is enabled, \l{Qt for Embedded Linux} will
|
---|
99 | try to auto-detect the mouse device if it is one of the supported
|
---|
100 | types on \c /dev/psaux or one of the \c /dev/ttyS? serial
|
---|
101 | lines. If multiple mice are detected, all may be used
|
---|
102 | simultaneously.
|
---|
103 |
|
---|
104 | Note that \l{Qt for Embedded Linux} does not support auto-detection of \e
|
---|
105 | {touch panels} in which case the driver must be specified
|
---|
106 | explicitly to determine which device to use.
|
---|
107 |
|
---|
108 | To manually specify which driver to use, set the \c QWS_MOUSE_PROTO
|
---|
109 | environment variable. For example (if the current shell is bash,
|
---|
110 | ksh, zsh or sh):
|
---|
111 |
|
---|
112 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 4
|
---|
113 |
|
---|
114 | The valid values for the \c <driver> argument are \c MouseMan, \c
|
---|
115 | IntelliMouse, \c Microsoft, \c LinuxTP, \c LinuxInput, \c
|
---|
116 | Tslib and \l {QMouseDriverPlugin::keys()}{keys} identifying custom
|
---|
117 | drivers, and the driver specific options are typically a device,
|
---|
118 | e.g., \c /dev/mouse for mouse devices and \c /dev/ts for touch
|
---|
119 | panels.
|
---|
120 |
|
---|
121 | Multiple mouse drivers can be specified in one go:
|
---|
122 |
|
---|
123 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 5
|
---|
124 |
|
---|
125 | Input will be read from all specified drivers.
|
---|
126 |
|
---|
127 | \table
|
---|
128 | \header \o The Tslib Mouse Driver
|
---|
129 | \row
|
---|
130 | \o
|
---|
131 |
|
---|
132 | The tslib mouse driver inherits the QWSCalibratedMouseHandler
|
---|
133 | class, providing calibration and noise reduction functionality in
|
---|
134 | addition to generating mouse events for devices using the
|
---|
135 | Universal Touch Screen Library.
|
---|
136 |
|
---|
137 | To be able to compile this mouse handler, \l{Qt for Embedded Linux} must be
|
---|
138 | configured with the \c -qt-mouse-tslib option as described
|
---|
139 | above. In addition, the tslib headers and library must be present
|
---|
140 | in the build environment.
|
---|
141 |
|
---|
142 | The tslib sources can be downloaded from \l
|
---|
143 | http://tslib.berlios.de. Specify the location of the library and
|
---|
144 | its headers using -L and -I options in the \c qmake.conf file in
|
---|
145 | your \c mkspec. Also it can be helpful to add a -rpath-link:
|
---|
146 |
|
---|
147 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 7
|
---|
148 |
|
---|
149 | In order to use this mouse driver, tslib must also be correctly
|
---|
150 | installed on the target machine. This includes providing a \c
|
---|
151 | ts.conf configuration file and setting the neccessary environment
|
---|
152 | variables (see the README file provided with tslib for details).
|
---|
153 |
|
---|
154 | The \c ts.conf file will usually contain the following two lines:
|
---|
155 |
|
---|
156 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 8
|
---|
157 |
|
---|
158 | To make \l{Qt for Embedded Linux} explicitly choose the tslib mouse
|
---|
159 | handler, set the \c QWS_MOUSE_PROTO environment variable as explained
|
---|
160 | above.
|
---|
161 |
|
---|
162 | \endtable
|
---|
163 |
|
---|
164 | \section1 Troubleshooting
|
---|
165 |
|
---|
166 | \section2 Device Files
|
---|
167 |
|
---|
168 | Make sure you are using the correct device file.
|
---|
169 |
|
---|
170 | As a first step, you can test whether the device file actually gives any
|
---|
171 | output. For instance, if you have specified the mouse driver with
|
---|
172 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 9
|
---|
173 | then try examining
|
---|
174 | the output from the device by entering the following command in a console:
|
---|
175 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 10
|
---|
176 |
|
---|
177 | If you see output from the device printed on the console when you move
|
---|
178 | the mouse, you are probably using the correct device file; otherwise, you
|
---|
179 | will need to experiment to find the correct device file.
|
---|
180 |
|
---|
181 | \section2 File Permissions
|
---|
182 |
|
---|
183 | Make sure you have sufficient permissions to access the device file.
|
---|
184 |
|
---|
185 | The Qt for Embedded Linux server process needs at least read permission for the
|
---|
186 | device file. Some drivers also require write access to the device file.
|
---|
187 | For instance, if you have specified the mouse driver with
|
---|
188 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 11
|
---|
189 | then examine the permissions of the device file by entering the
|
---|
190 | following command in a console:
|
---|
191 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc show permissions
|
---|
192 | Change the permissions of the device file, if necessary, in the following
|
---|
193 | way:
|
---|
194 | \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 12
|
---|
195 |
|
---|
196 | If the device file is actually a symbolic link to another file, you must
|
---|
197 | change the permissions of the actual file instead.
|
---|
198 | */
|
---|