Qt 4.8
Public Functions | Properties | List of all members
QWSPcMouseSubHandler_intellimouse Class Reference
Inheritance diagram for QWSPcMouseSubHandler_intellimouse:
QWSPcMouseSubHandler

Public Functions

void init ()
 
 QWSPcMouseSubHandler_intellimouse (int f)
 
int tryData ()
 
- Public Functions inherited from QWSPcMouseSubHandler
void appendData (uchar *data, int length)
 
int buttonState () const
 
void closeIfNot (int &f)
 
int file () const
 
void initState ()
 
bool motionPending () const
 
 QWSPcMouseSubHandler (int f)
 
bool reliable () const
 
QPoint takeMotion ()
 
int takeWheel ()
 
UsageResult useData ()
 
void worse (int by=1)
 
virtual ~QWSPcMouseSubHandler ()
 

Properties

int packetsize
 

Additional Inherited Members

- Public Types inherited from QWSPcMouseSubHandler
enum  UsageResult { Insufficient, Motion, Button }
 
- Protected Types inherited from QWSPcMouseSubHandler
enum  { max_buf =32 }
 
- Protected Variables inherited from QWSPcMouseSubHandler
int badness
 
int bstate
 
uchar buffer [max_buf]
 
int fd
 
int goodness
 
QPoint motion
 
int nbuf
 
int wheel
 

Detailed Description

Definition at line 154 of file qmousepc_qws.cpp.

Constructors and Destructors

◆ QWSPcMouseSubHandler_intellimouse()

QWSPcMouseSubHandler_intellimouse::QWSPcMouseSubHandler_intellimouse ( int  f)
inline

Definition at line 157 of file qmousepc_qws.cpp.

158  {
159  init();
160  }

Functions

◆ init()

void QWSPcMouseSubHandler_intellimouse::init ( )
inline

Definition at line 162 of file qmousepc_qws.cpp.

163  {
164  int n;
165  uchar reply[20];
166 
167  if (tcflush(fd,TCIOFLUSH) == -1) {
168 #ifdef QWS_MOUSE_DEBUG
169  perror("QWSPcMouseSubHandler_intellimouse: pre-init tcflush");
170 #endif
171  }
172  static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
173  static const uchar query[] = { 0xf2 };
174  if (QT_WRITE(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
175  badness = 100;
176  return;
177  }
178  usleep(10000);
179  if (tcflush(fd,TCIOFLUSH) == -1) {
180 #ifdef QWS_MOUSE_DEBUG
181  perror("QWSPcMouseSubHandler_intellimouse: post-init tcflush");
182 #endif
183  }
184  if (QT_WRITE(fd, query, sizeof(query))!=sizeof(query)) {
185  badness = 100;
186  return;
187  }
188  usleep(10000);
189  n = QT_READ(fd, reply, 20);
190  if (n > 0) {
191  goodness = 10;
192  switch (reply[n-1]) {
193  case 3:
194  case 4:
195  packetsize = 4;
196  break;
197  default:
198  packetsize = 3;
199  }
200  } else {
201  badness = 100;
202  }
203  }
#define QT_READ
Definition: qcore_unix_p.h:280
unsigned char uchar
Definition: qglobal.h:994
#define QT_WRITE
Definition: qcore_unix_p.h:289

◆ tryData()

int QWSPcMouseSubHandler_intellimouse::tryData ( )
inlinevirtual

Implements QWSPcMouseSubHandler.

Definition at line 205 of file qmousepc_qws.cpp.

206  {
207  if (nbuf >= packetsize) {
208  //int overflow = (buffer[0]>>6)& 0x03;
209 
210  if (/*overflow ||*/ !(buffer[0] & 8)) {
211 #ifdef QWS_MOUSE_DEBUG
212  qDebug("Intellimouse: skipping (overflow)");
213 #endif
214  badness++;
215  return 1;
216  } else {
217  QPoint delta((buffer[0] & 0x10) ? buffer[1]-256 : buffer[1],
218  (buffer[0] & 0x20) ? 256-buffer[2] : -buffer[2]);
219  motion += delta;
220  int nbstate = buffer[0] & 0x7;
221 #ifdef QWS_MOUSE_DEBUG
222  int debugwheel =
223 #endif
224  wheel = packetsize > 3 ? -(signed char)buffer[3] : 0;
225  if (wheel < -2 || wheel > 2)
226  wheel = 0;
227  wheel *= 120; // WHEEL_DELTA?
228 #ifdef QWS_MOUSE_DEBUG
229  qDebug("Intellimouse: motion %d,%d, state %d, raw wheel %d, wheel %d", motion.x(), motion.y(), nbstate, debugwheel, wheel);
230 #endif
231  if (motion.x() || motion.y() || bstate != nbstate || wheel) {
232  bstate = nbstate;
233  goodness++;
234  } else {
235  badness++;
236  return 1;
237  }
238  }
239  return packetsize;
240  }
241  return 0;
242  }
uchar buffer[max_buf]
Q_CORE_EXPORT void qDebug(const char *,...)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

Properties

◆ packetsize

int QWSPcMouseSubHandler_intellimouse::packetsize
private

Definition at line 155 of file qmousepc_qws.cpp.


The documentation for this class was generated from the following file: