教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 法律文档 >

Minigui移植uClinux(4)

来源:网络收集 时间:2026-08-29
导读: { return 1; } static void mouse_getxy(int *x, int* y) { #ifdef _DEBUG printf (\#endif if (mousex 239) mousex = 239; if (mousey > 319) mousey = 319; *x = mousex; *y = mousey; } static int mouse_getbut

{

return 1; }

static void mouse_getxy(int *x, int* y) {

#ifdef _DEBUG

printf (\#endif

if (mousex < 0) mousex = 0; if (mousey < 0) mousey = 0; if (mousex > 239) mousex = 239; if (mousey > 319) mousey = 319;

*x = mousex; *y = mousey; }

static int mouse_getbutton(void) {

return ts_event.pressure; }

#ifdef _LITE_VERSION

static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout) #else

static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except, struct timeval *timeout) #endif {

fd_set rfds;

int retvalue = 0;

int e;

static int last_pressure=0;

if (!in) {

in = &rfds; FD_ZERO (in); }

if ((which & IAL_MOUSEEVENT) && ts >= 0) { FD_SET (ts, in); #ifdef _LITE_VERSION

if (ts > maxfd) maxfd = ts; #endif }

#ifdef _LITE_VERSION

e = select (maxfd + 1, in, out, except, timeout) ; #else

e = select (FD_SETSIZE, in, out, except, timeout) ; #endif

if (e > 0) {

if (ts >= 0 && FD_ISSET (ts, in) ) { FD_CLR (ts, in); ts_event.x=0; ts_event.y=0;

read (ts, &ts_event, sizeof (TS_EVENT));

if(last_pressure==0) {

read(ts,&ts_event,sizeof(TS_EVENT)); read(ts,&ts_event,sizeof(TS_EVENT)); }

if (ts_event.pressure > 0 ) {

int new_x; int new_y;

mPOINT ts_point,display_point;

ts_point.x=ts_event.x; ts_point.y=ts_event.y;

getDisplayPoint(&display_point,&ts_point,&m_matrix);

new_x = display_point.x; new_y = display_point.y;

if(last_pressure==0 || (last_pressure>0 && abs(new_x-mousex)<7)) mousex=new_x;

if(last_pressure==0 || (last_pressure>0 && abs(new_y-mousey)<7)) mousey=new_y; /*

printf(\printf(\*/

}

#ifdef _DEBUG

if (ts_event.pressure > 0) {

printf (\down: ts_event.x = %d, ts_event.y = %d\\n\ts_event.x, ts_event.y); } #endif

ts_event.pressure = ( ts_event.pressure > 0 ? IAL_MOUSE_LEFTBUTTON : 0);

last_pressure=ts_event.pressure; /*

printf(\*/

retvalue |= IAL_MOUSEEVENT; } }

else if (e < 0) { return -1; }

return retvalue; }

BOOL Init2410Input (INPUT* input, const char* mdev, const char* mtype) {

ts = open (\ if (ts < 0) {

fprintf (stderr, \ return FALSE; }

input->update_mouse = mouse_update; input->get_mouse_xy = mouse_getxy; input->set_mouse_xy = NULL;

input->get_mouse_button = mouse_getbutton; input->set_mouse_range = NULL;

input->wait_event = wait_event; mousex = 0; mousey = 0;

ts_event.x = ts_event.y = ts_event.pressure = 0;

setCalibrationMatrix(&display_position,&ts_position,&m_matrix); return TRUE; }

void Term2410Input(void) {

if (ts >= 0)

close(ts); }

#endif /* _SMDK2410_IAL */

int setCalibrationMatrix( mPOINT * displayPtr, mPOINT * screenPtr, mMATRIX * matrixPtr) {

int retvalue = 0 ;

matrixPtr->Divider = ((screenPtr[0].x - screenPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -

((screenPtr[1].x - screenPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;

if( matrixPtr->Divider == 0 ) {

retvalue = -1 ; } else {

matrixPtr->An = ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -

((displayPtr[1].x - displayPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;

matrixPtr->Bn = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].x - displayPtr[2].x)) -

((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].x - screenPtr[2].x)) ;

matrixPtr->Cn = (screenPtr[2].x * displayPtr[1].x - screenPtr[1].x * displayPtr[2].x) * screenPtr[0].y +

(screenPtr[0].x * displayPtr[2].x - screenPtr[2].x * displayPtr[0].x) * screenPtr[1].y +

(screenPtr[1].x * displayPtr[0].x - screenPtr[0].x * displayPtr[1].x) * screenPtr[2].y ;

matrixPtr->Dn = ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].y - screenPtr[2].y)) -

((displayPtr[1].y - displayPtr[2].y) * (screenPtr[0].y - screenPtr[2].y)) ;

matrixPtr->En = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].y - displayPtr[2].y)) -

((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].x - screenPtr[2].x)) ;

matrixPtr->Fn = (screenPtr[2].x * displayPtr[1].y - screenPtr[1].x * displayPtr[2].y) * screenPtr[0].y +

(screenPtr[0].x * displayPtr[2].y - screenPtr[2].x * displayPtr[0].y) * screenPtr[1].y +

(screenPtr[1].x * displayPtr[0].y - screenPtr[0].x * displayPtr[1].y) * screenPtr[2].y ; }

return( retvalue ) ;

} /* end of setCalibrationMatrix() */

int getDisplayPoint( mPOINT * displayPtr, mPOINT * screenPtr, mMATRIX * matrixPtr ) {

int retvalue = 0 ;

…… 此处隐藏:1862字,全部文档内容请下载后查看。喜欢就下载吧 ……
Minigui移植uClinux(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/435707.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)