让minigui的IAL支持鼠标中键滚轮事件

本文介绍如何为MiniGUI的IAL qvfb模块增加鼠标中键滚轮的支持,包括修改源代码及编译配置等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

给minigui增加了对鼠标中键滚轮的支持后,发现使用IAL的qvfb又不支持中键滚轮的事件,所以就修改qvfb的代码,以增加对中键滚轮的支持。
首先修改minigui中IAL的qvfb.c中
static int mouse_delta = 0;//增加的
static int mouse_update (void)
{
    int ret1, ret2;
    POINT l_mouse_pt;
    int l_mouse_buttons;

    ret1 = read (mouse_fd, &l_mouse_pt, sizeof (POINT));
    ret2 = read (mouse_fd, &l_mouse_buttons, sizeof (int));
    read (mouse_fd, &mouse_delta, sizeof (int));//增加的
 
    if (ret1 == sizeof (POINT) && ret2 && sizeof (int)
            && l_mouse_buttons < 0x08) {
        mouse_pt = l_mouse_pt;
        mouse_buttons = l_mouse_buttons;
    }
    else
        return 0;

    return 1;
}

static void mouse_getxy (int *x, int* y, int *z)
{
    *x = mouse_pt.x;
    *y = mouse_pt.y;
 *z = mouse_delta;//增加的
}


然后修改qvfb的源代码中QVFbView类,我使用的qvfb1.1
修改QVFbView::sendMouseData函数,增加一个参数delta
void QVFbView::sendMouseData( const QPoint &pos, int buttons, int delta )
{
    write( mouseFd, &pos, sizeof( QPoint ) );
    write( mouseFd, &buttons, sizeof( int ) );
    write( mouseFd, &delta, sizeof( int ) );//add,发送鼠标中键滚轮值
}

函数contentsMousePressEvent、contentsMouseDoubleClickEvent、contentsMouseReleaseEvent、contentsMouseMoveEvent中调用
sendMouseData时,最后一个参数delta都置0

再增加一个函数,用于接收鼠标中键滚动时所产生的值
#ifndef QT_NO_WHEELEVENT

void QVFbView::contentsWheelEvent( QWheelEvent *e )
{
    sendMouseData( e->pos()/zm, e->state(), e->delta());
}
#endif
记得qvfbview.h头文件中也要相应根据修改和增加的函数进行修改即可,然后重新编译qvfb

需要注意的是QT必须支持WHEELEVENT,,否则不行。

就是如果没有定义宏QT_NO_WHEELEVENT,就说明QT是支持

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值