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

Public Functions

void init ()
 
 QWSPcMouseSubHandler_mouseman (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 245 of file qmousepc_qws.cpp.

Constructors and Destructors

◆ QWSPcMouseSubHandler_mouseman()

QWSPcMouseSubHandler_mouseman::QWSPcMouseSubHandler_mouseman ( int  f)
inline

Definition at line 248 of file qmousepc_qws.cpp.

249  {
250  init();
251  }

Functions

◆ init()

void QWSPcMouseSubHandler_mouseman::init ( )
inline

Definition at line 253 of file qmousepc_qws.cpp.

254  {
255  if (tcflush(fd,TCIOFLUSH) == -1) {
256 #ifdef QWS_MOUSE_DEBUG
257  perror("QWSPcMouseSubHandler_mouseman: initial tcflush");
258 #endif
259  }
260  QT_WRITE(fd,"",1);
261  usleep(50000);
262  QT_WRITE(fd,"@EeI!",5);
263  usleep(10000);
264  static const unsigned char ibuf[] = { 246, 244 };
265  QT_WRITE(fd,ibuf,1);
266  QT_WRITE(fd,ibuf+1,1);
267  if (tcflush(fd,TCIOFLUSH) == -1) {
268 #ifdef QWS_MOUSE_DEBUG
269  perror("QWSPcMouseSubHandler_mouseman: tcflush");
270 #endif
271  }
272  usleep(10000);
273 
274  char buf[100];
275  while (QT_READ(fd, buf, 100) > 0) { } // eat unwanted replies
276  }
#define QT_READ
Definition: qcore_unix_p.h:280
#define QT_WRITE
Definition: qcore_unix_p.h:289

◆ tryData()

int QWSPcMouseSubHandler_mouseman::tryData ( )
inlinevirtual

Implements QWSPcMouseSubHandler.

Definition at line 278 of file qmousepc_qws.cpp.

279  {
280  if (nbuf >= 3) {
281  int nbstate = 0;
282  if (buffer[0] & 0x01)
283  nbstate |= Qt::LeftButton;
284  if (buffer[0] & 0x02)
285  nbstate |= Qt::RightButton;
286  if (buffer[0] & 0x04)
287  nbstate |= Qt::MidButton;
288 
289  int overflow = (buffer[0]>>6)& 0x03;
290  if (overflow) {
291  //### wheel events signalled with overflow bit, ignore for now
292  badness++;
293  return 1;
294  } else {
295  bool xs = buffer[0] & 0x10;
296  bool ys = buffer[0] & 0x20;
297  int dx = xs ? buffer[1]-256 : buffer[1];
298  int dy = ys ? buffer[2]-256 : buffer[2];
299 
300  motion += QPoint(dx, -dy);
301  if (motion.x() || motion.y() || bstate != nbstate) {
302  bstate = nbstate;
303  goodness++;
304  } else {
305  badness++;
306  return 1;
307  }
308  }
309  return 3;
310  }
311  return 0;
312  }
uchar buffer[max_buf]
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_mouseman::packetsize
private

Definition at line 246 of file qmousepc_qws.cpp.


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