亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? qwsmouse_qws.cpp

?? 基于LINUX2.6.9觸摸鼠標驅動QT3.0
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
/****************************************************************************
** $Id:  qt/qwsmouse_qws.cpp   3.0.4   edited Apr 2 09:25 $
**
** Implementation of Qt/Embedded mouse drivers
**
** Created : 991025
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of the kernel module of the Qt GUI Toolkit.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses for Qt/Embedded may use this file in accordance with the
** Qt Embedded Commercial License Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
**   information about Qt Commercial License Agreements.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/

#include "qwindowsystem_qws.h"
#include "qsocketnotifier.h"
#include "qwsevent_qws.h"
#include "qwscommand_qws.h"
#include "qwsutils_qws.h"
#include "qwsmouse_qws.h"

#include "qapplication.h"
#include "qpointarray.h"
#include "qtimer.h"
#include "qfile.h"
#include "qtextstream.h"

#include "tslib.h"

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>


#include <qgfx_qws.h>

#define QT_QWS_LUBBOCK

#ifdef QT_QWS_LUBBOCK
#include <linux/input.h>
#include <dlfcn.h>
#include "tslib.h"
#endif

#ifdef QT_QWS_CASSIOPEIA
#include <linux/tpanel.h>


#endif

#if defined(QT_QWS_IPAQ)
#define QT_QWS_IPAQ_RAW
typedef struct {
	unsigned short pressure;
	unsigned short x;
	unsigned short y;
	unsigned short pad;
} TS_EVENT;
#elif defined(QT_QWS_EBX)
#define QT_QWS_EBX_RAW
#ifndef QT_QWS_CUSTOM
typedef struct {
        unsigned short pressure;
        unsigned short x;
        unsigned short y;
        unsigned short pad;
} TS_EVENT;
#else
typedef struct {
       long y;
       long x;
       long pressure;
       long long millisecs;
} TS_EVENT;
#endif

#define QT_QWS_TP_SAMPLE_SIZE 5
#define QT_QWS_TP_PRESSURE_THRESHOLD 500
#define QT_QWS_TP_MOVE_LIMIT 50

#endif

#ifndef QT_QWS_TP_SAMPLE_SIZE
#define QT_QWS_TP_SAMPLE_SIZE 5
#endif

#ifndef QT_QWS_TP_PRESSURE_THRESHOLD
#define QT_QWS_TP_PRESSURE_THRESHOLD 1
#endif

#ifndef QT_QWS_TP_MOVE_LIMIT
#define QT_QWS_TP_MOVE_LIMIT 100
#endif

#ifndef QT_QWS_TP_SAMPLE_SIZE
#define QT_QWS_TP_SAMPLE_SIZE 5
#endif

#ifndef QT_QWS_TP_PRESSURE_THRESHOLD
#define QT_QWS_TP_PRESSURE_THRESHOLD 1
#endif

#ifndef QT_QWS_TP_MOVE_LIMIT
#define QT_QWS_TP_MOVE_LIMIT 100
#endif

/*!
  \class QWSMouseHandler qwsmouse_qws.h
  \ingroup qws
  \brief The QWSMouseHandler class is a mouse driver/handler for Qt/Embedded.

  The mouse driver/handler handles events from system devices and
  generates mouse events.

  A QWSMouseHandler will usually open some system device in its
  constructor, create a QSocketNotifier on that opened device and when
  it receives data, it will call mouseChanged() to send the event
  to Qt/Embedded for relaying to clients.
*/

/*!
  Constructs a mouse handler. This becomes the primary mouse handler.

  Note that once created, mouse handlers are controlled by the system
  and should not be deleted.
*/
QWSMouseHandler::QWSMouseHandler()
{
    QWSServer::setMouseHandler(this);
}

/*!
  Destroys the mouse handler. You should not call this directly.
*/
QWSMouseHandler::~QWSMouseHandler()
{
}

/*!
  To be called by the mouse handler to signal that the
  mouse is at position \a pos and the mouse buttons are
  in state \a bstate.
*/

static void limitToScreen( QPoint &pt )
{
    static int w = -1;
    static int h;
    if ( w < 0 ) {
	w = qt_screen->deviceWidth();
	h = qt_screen->deviceHeight();
    }

    pt.setX( QMIN( w-1, QMAX( 0, pt.x() )));
    pt.setY( QMIN( h-1, QMAX( 0, pt.y() )));
}

static QPoint &mousePos = QWSServer::mousePosition;

#ifdef Q_OS_QNX6
#include "qwsmouse_qnx6.cpp"
#endif

/*!
   When a mouse event occurs this function is called with the mouse's
   position in \a pos, and the state of its buttons in \a bstate.
*/
void QWSMouseHandler::mouseChanged( const QPoint& pos, int bstate )
{
    QWSServer::sendMouseEvent(pos,bstate);
}

typedef struct {
    char *name;
    MouseProtocol id;
} MouseConfig;

static const MouseConfig mouseConfig[] = {
    { "Auto",		Auto },
    { "MouseMan",	MouseMan },
    { "IntelliMouse",	IntelliMouse },
    { "Microsoft",      Microsoft },
    { "QVFbMouse",      QVFBMouse },
    { "TPanel",         TPanel },
    { "BusMouse",       BusMouse },
    { 0,		Unknown }
};

#ifndef QT_NO_QWS_MOUSE_AUTO
/*
 * Automatic-detection mouse driver
 */

class QAutoMouseSubHandler {
protected:
    enum { max_buf=32 };

    int fd;

    uchar buffer[max_buf];
    int nbuf;

    QPoint motion;
    int bstate;

    int goodness;
    int badness;

    virtual int tryData()=0;

public:
    QAutoMouseSubHandler(int f) : fd(f)
    {
	nbuf = bstate = goodness = badness = 0;
    }

    int file() const { return fd; }

    void closeIfNot(int& f)
    {
	if ( fd != f ) {
	    f = fd;
	    close(fd);
	}
    }

    void worse(int by=1) { badness+=by; }
    bool reliable() const { return goodness >= 5 && badness < 50; }
    int buttonState() const { return bstate; }
    bool motionPending() const { return motion!=QPoint(0,0); }
    QPoint takeMotion() { QPoint r=motion; motion=QPoint(0,0); return r; }

    void appendData(uchar* data, int length)
    {
	memcpy(buffer+nbuf, data, length);
	nbuf += length;
    }

    enum UsageResult { Insufficient, Motion, Button };

    UsageResult useData()
    {
	int pbstate = bstate;
	int n = tryData();
	if ( n > 0 ) {
	    if ( n<nbuf )
		memcpy( buffer, buffer+n, nbuf-n );
	    nbuf -= n;
	    return pbstate == bstate ? Motion : Button;
	}
	return Insufficient;
    }
};

class QAutoMouseSubHandler_intellimouse : public QAutoMouseSubHandler {
    int packetsize;
public:
    QAutoMouseSubHandler_intellimouse(int f) : QAutoMouseSubHandler(f)
    {
	init();
    }

    void init()
    {
	int n;
	uchar reply[20];

	tcflush(fd,TCIOFLUSH);
	static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
	static const uchar query[] = { 0xf2 };
	if (write(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
	    badness = 100;
	    return;
	}
	usleep(10000);
	tcflush(fd,TCIOFLUSH);
	if (write(fd, query, sizeof(query))!=sizeof(query)) {
	    badness = 100;
	    return;
	}
	usleep(10000);
	n = read(fd, reply, 20);
	if ( n > 0 ) {
	    goodness = 10;
	    switch ( reply[n-1] ) {
	      case 3:
	      case 4:
		packetsize = 4;
		break;
	     default:
		packetsize = 3;
	    }
	} else {
	    badness = 100;
	}
    }

    int tryData()
    {
	if ( nbuf >= packetsize ) {
	    //int overflow = (buffer[0]>>6 )& 0x03;

	    if ( /*overflow ||*/ !(buffer[0] & 8) ) {
		badness++;
		return 1;
	    } else {
		motion +=
		    QPoint((buffer[0] & 0x10) ? buffer[1]-256 : buffer[1],
			   (buffer[0] & 0x20) ? 256-buffer[2] : -buffer[2]);
		int nbstate = buffer[0] & 0x7;
		if ( motion.x() || motion.y() || bstate != nbstate ) {
		    bstate = nbstate;
		    goodness++;
		} else {
		    badness++;
		    return 1;
		}
	    }
	    return packetsize;
	}
	return 0;
    }
};

class QAutoMouseSubHandler_serial : public QAutoMouseSubHandler {
public:
    QAutoMouseSubHandler_serial(int f) : QAutoMouseSubHandler(f)
    {
	initSerial();
    }

protected:
    void setflags(int f)
    {
	termios tty;
	tcgetattr(fd, &tty);
	tty.c_iflag     = IGNBRK | IGNPAR;
	tty.c_oflag     = 0;
	tty.c_lflag     = 0;
	tty.c_cflag     = f | CREAD | CLOCAL | HUPCL;
#if !defined(Q_OS_FREEBSD) && !defined(Q_OS_SOLARIS)
	tty.c_line      = 0;
#endif
	tty.c_cc[VTIME] = 0;
	tty.c_cc[VMIN]  = 1;
	tcsetattr(fd, TCSANOW, &tty);
    }

private:
    void initSerial()
    {
	int speed[4] = { B9600, B4800, B2400, B1200 };

	for (int n = 0; n < 4; n++) {
	    setflags(CSTOPB | speed[n]);
	    write(fd, "*q", 2);
	    usleep(10000);
	}
    }
};

class QAutoMouseSubHandler_mousesystems : public QAutoMouseSubHandler_serial {
public:
    // ##### This driver has not been tested

    QAutoMouseSubHandler_mousesystems(int f) : QAutoMouseSubHandler_serial(f)
    {
	init();
    }

    void init()
    {
	setflags(B1200|CS8|CSTOPB);
	// 60Hz
	if (write(fd, "R", 1)!=1) {
	    badness = 100;
	    return;
	}
	tcflush(fd,TCIOFLUSH);
    }

    int tryData()
    {
	if ( nbuf >= 5 ) {
	    if ( (buffer[0] & 0xf8) != 0x80 ) {
		badness++;
		return 1;
	    }
	    motion +=
		QPoint((signed char)buffer[1] + (signed char)buffer[3],
		       -(signed char)buffer[2] + (signed char)buffer[4]);
	    int t = ~buffer[0];
	    int nbstate = ((t&3) << 1) | ((t&4) >> 2);
	    if ( motion.x() || motion.y() || bstate != nbstate ) {
		bstate = nbstate;
		goodness++;
	    } else {
		badness++;
		return 1;
	    }
	    return 5;
	}
	return 0;
    }
};

class QAutoMouseSubHandler_ms : public QAutoMouseSubHandler_serial {
    int mman;
public:
    QAutoMouseSubHandler_ms(int f) : QAutoMouseSubHandler_serial(f)
    {
	mman=0;
	init();
    }

    void init()
    {
	setflags(B1200|CS7);
	// 60Hz
	if (write(fd, "R", 1)!=1) {
	    badness = 100;
	    return;
	}
	tcflush(fd,TCIOFLUSH);
    }

    int tryData()
    {
	if ( !(buffer[0] & 0x40) ) {
	    if ( buffer[0] == 0x20 && (bstate & Qt::MidButton) ) {
		mman=1; // mouseman extension
	    }
	    return 1;
	}
	int extra = mman&&(bstate & Qt::MidButton);
	if ( nbuf >= 3+extra ) {
	    int nbstate = 0;
	    if ( buffer[0] == 0x40 && !bstate && !buffer[1] && !buffer[2] ) {
		nbstate = Qt::MidButton;
	    } else {
		nbstate = ((buffer[0] & 0x20) >> 5)
			| ((buffer[0] & 0x10) >> 3);
		if ( extra && buffer[3] == 0x20 )
		    nbstate = Qt::MidButton;
	    }

	    if ( buffer[1] & 0x40 ) {
		badness++;
		return 1;
	    } else {
		motion +=
		    QPoint((signed char)((buffer[0]&0x3)<<6)
			    |(signed char)(buffer[1]&0x3f),
			   (signed char)((buffer[0]&0xc)<<4)
			    |(signed char)(buffer[2]&0x3f));
		if ( motion.x() || motion.y() || bstate != nbstate ) {
		    bstate = nbstate;
		    goodness++;
		} else {
		    badness++;
		    return 1;
		}
		return 3+extra;
	    }
	}
	return 0;
    }
};

/*
QAutoMouseHandler::UsageResult QAutoMouseHandler::useDev(Dev& d)
{
    if ( d.nbuf >= mouseData[d.protocol].bytesPerPacket ) {
	uchar *mb = d.buf;
	int bstate = 0;
	int dx = 0;
	int dy = 0;

	switch (mouseProtocol) {
	    case MouseMan:
	    case IntelliMouse:
	    {
		bstate = mb[0] & 0x7; // assuming Qt::*Button order

		int overflow = (mb[0]>>6 )& 0x03;
		if (mouseProtocol == MouseMan && overflow) {
		    //### wheel events signalled with overflow bit, ignore for now
		}
		else {
		    bool xs = mb[0] & 0x10;
		    bool ys = mb[0] & 0x20;
		    dx = xs ? mb[1]-256 : mb[1];
		    dy = ys ? mb[2]-256 : mb[2];
		}
		break;
	    }
	    case Microsoft:
		if ( ((mb[0] & 0x20) >> 3) ) {
		    bstate |= Qt::LeftButton;
		}
		if ( ((mb[0] & 0x10) >> 4) ) {
		    bstate |= Qt::RightButton;
		}

		dx=(signed char)(((mb[0] & 0x03) << 6) | (mb[1] & 0x3f));
		dy=-(signed char)(((mb[0] & 0x0c) << 4) | (mb[2] & 0x3f));

		break;
	}
    }
    }
*/


bool QAutoMouseHandlerPrivate::sendEvent(QAutoMouseSubHandler& h)
{
	if ( h.reliable() ) {
	    mousePos += h.takeMotion();
	    limitToScreen( mousePos );
/*
qDebug("%d,%d %c%c%c",
mousePos.x(),mousePos.y(),
(h.buttonState()&Qt::LeftButton)?'L':'.',
(h.buttonState()&Qt::MidButton)?'M':'.',
(h.buttonState()&Qt::RightButton)?'R':'.');
*/
	    mouseChanged(mousePos,h.buttonState());
	    return TRUE;
	} else {
	    h.takeMotion();
	    if ( h.buttonState() & (Qt::RightButton|Qt::MidButton) ) {
		// Strange for the user to press right or middle without
		// a moving mouse!
		h.worse();
	    }
	    return FALSE;
	}
}

QAutoMouseHandlerPrivate::QAutoMouseHandlerPrivate()
{
    notifiers.setAutoDelete( TRUE );
    retries = 0;
    openDevices();
}

QAutoMouseHandlerPrivate::~QAutoMouseHandlerPrivate()
{
    closeDevices();
}

void QAutoMouseHandlerPrivate::openDevices()
{
    nsub=0;
    int fd;
    fd = open( "/dev/psaux", O_RDWR | O_NDELAY );
    if ( fd >= 0 ) {
	sub[nsub++] = new QAutoMouseSubHandler_intellimouse(fd);
	notify(fd);
    }
#if 0
    char fn[] = "/dev/ttyS?";
    for (int ch='0'; ch<='3'; ch++) {
	fn[9] = ch;
	fd = open( fn, O_RDWR | O_NDELAY );
	if ( fd >= 0 ) {
	    //sub[nsub++] = new QAutoMouseSubHandler_intellimouse(fd);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲柠檬福利资源导航| 亚洲精品国产成人久久av盗摄| 成人国产一区二区三区精品| 亚洲国产精品影院| 国产精品免费丝袜| 欧美mv日韩mv国产网站| 欧美网站一区二区| 成人美女视频在线观看18| 麻豆久久久久久久| 亚洲国产一区二区三区青草影视| 国产亚洲一区二区三区| 欧美日韩不卡一区| 91美女片黄在线观看91美女| 国产麻豆视频精品| 日韩精品福利网| 一区二区在线观看视频| 欧美韩国日本综合| 欧美精品一区二区在线播放| 欧美中文字幕一二三区视频| 国产成人免费av在线| 日日嗨av一区二区三区四区| 亚洲免费观看高清完整版在线| 久久久精品日韩欧美| 精品精品欲导航| 制服视频三区第一页精品| 欧美影视一区在线| 91在线视频观看| 成人国产亚洲欧美成人综合网| 国产精品综合二区| 狠狠色狠狠色合久久伊人| 蜜臂av日日欢夜夜爽一区| 亚洲超丰满肉感bbw| 一区二区不卡在线视频 午夜欧美不卡在| 国产婷婷一区二区| 久久美女高清视频| 精品日韩在线一区| 欧美成人精精品一区二区频| 日韩一区二区三区在线观看| 欧美丰满嫩嫩电影| 欧美日韩另类国产亚洲欧美一级| 日本精品视频一区二区| 在线视频欧美精品| 欧美三区在线观看| 欧美日韩和欧美的一区二区| 欧美美女黄视频| 91麻豆精品国产91| 欧美日韩视频在线一区二区| 欧美三级三级三级| 欧美视频你懂的| 欧美挠脚心视频网站| 欧美一级理论片| 欧美大片免费久久精品三p| 日韩欧美成人一区二区| 久久久蜜桃精品| 久久精品一区二区三区四区| 国产精品久久久久毛片软件| 亚洲精品国产精华液| 亚洲午夜日本在线观看| 奇米一区二区三区| 国产精品888| 99久久久国产精品| 欧美性大战久久久| 日韩你懂的在线观看| 亚洲国产精品成人综合色在线婷婷 | 欧美sm极限捆绑bd| 国产欧美日本一区视频| 亚洲人一二三区| 午夜精品福利一区二区蜜股av | 久久婷婷综合激情| 欧美激情一区二区三区四区| 亚洲免费看黄网站| 麻豆久久一区二区| 成人av电影免费观看| 欧美性大战久久久久久久蜜臀| 欧美成人一区二区| 椎名由奈av一区二区三区| 婷婷久久综合九色国产成人 | 中文字幕亚洲在| 国产精品一区二区不卡| 大尺度一区二区| 欧美日韩免费电影| 欧美极品xxx| 丝袜美腿高跟呻吟高潮一区| 懂色av中文一区二区三区| 欧美无人高清视频在线观看| 久久女同精品一区二区| 亚洲免费毛片网站| 国产美女主播视频一区| 欧美日韩五月天| 国产精品福利在线播放| 日韩高清在线不卡| 不卡电影免费在线播放一区| 在线综合视频播放| 亚洲女人的天堂| 国产精品综合一区二区| 欧美精品久久99久久在免费线 | 国产精品一区在线观看你懂的| 91网站最新地址| 精品日韩一区二区三区 | 国产精品性做久久久久久| 精品视频在线视频| 国产精品免费观看视频| 久久国内精品视频| 欧美日韩国产综合久久| 中文字幕亚洲欧美在线不卡| 国产麻豆精品在线| 日韩一级完整毛片| 一区二区三区在线高清| 国产精品一区二区你懂的| 3d动漫精品啪啪一区二区竹菊| 亚洲欧洲精品一区二区三区不卡 | 国产69精品一区二区亚洲孕妇| 欧美日韩在线播放| 亚洲视频免费观看| 国产二区国产一区在线观看| 日韩精品中文字幕一区| 香蕉av福利精品导航| 在线免费不卡视频| 自拍偷拍亚洲欧美日韩| 东方aⅴ免费观看久久av| 精品国产一区二区亚洲人成毛片| 亚欧色一区w666天堂| 一本大道久久精品懂色aⅴ| 欧美国产一区二区| 精品一区二区三区免费毛片爱| 欧美日韩中文一区| 一区二区三区四区视频精品免费| 不卡一卡二卡三乱码免费网站| 亚洲精品一区二区三区四区高清 | 久久99久久99小草精品免视看| 精品国产一区二区国模嫣然| 天天免费综合色| 欧美夫妻性生活| 亚洲国产日韩精品| 在线看日本不卡| 亚洲小少妇裸体bbw| 欧日韩精品视频| 亚洲精品国产一区二区精华液 | 亚洲国产精品激情在线观看| 国产成人在线电影| 国产精品你懂的| 色综合一个色综合| 亚洲精品国产高清久久伦理二区| 欧美在线看片a免费观看| 亚洲一区二区三区激情| 欧美日韩电影在线播放| 日产欧产美韩系列久久99| 日韩免费看网站| 国产成人综合网| 国产精品美女视频| 99re热这里只有精品免费视频| 亚洲美女在线一区| 欧美日本免费一区二区三区| 日本午夜一本久久久综合| 欧美成人欧美edvon| 成人性生交大片免费看在线播放| 1000精品久久久久久久久| 91久久人澡人人添人人爽欧美| 亚洲福利一二三区| 日韩欧美中文字幕精品| 国产激情一区二区三区四区 | 欧美高清视频一二三区| 麻豆精品一区二区综合av| 精品成人佐山爱一区二区| 懂色av一区二区三区免费观看| 亚洲乱码国产乱码精品精可以看 | 久久国产欧美日韩精品| 中文字幕国产一区| 欧美视频在线观看一区| 激情欧美日韩一区二区| 最好看的中文字幕久久| 制服丝袜一区二区三区| 粉嫩av一区二区三区| 一区二区三区日韩欧美精品| 日韩欧美国产午夜精品| 91网站最新网址| 久久精品国产99国产精品| 日韩美女视频一区| 91精品在线麻豆| 97se亚洲国产综合自在线不卡 | 日本久久一区二区| 蓝色福利精品导航| 日韩美女视频一区二区| 欧美成人aa大片| 色婷婷亚洲一区二区三区| 玖玖九九国产精品| 一区二区三区日韩在线观看| 久久亚洲精精品中文字幕早川悠里| 一本久久a久久免费精品不卡| 久久国产精品一区二区| 亚洲伦理在线精品| 日本一区二区三区免费乱视频 | 日韩一级大片在线观看| 99麻豆久久久国产精品免费| 精品影视av免费| 亚洲综合区在线| 国产欧美精品一区二区三区四区 | 7777精品伊人久久久大香线蕉最新版 | 亚洲午夜久久久久久久久电影院 | 一片黄亚洲嫩模|