0

我在 mousedev_packet()(在 mousedev.c 中)的 Linux 内核源代码中添加了一些跟踪。当我从内核 printk 移动鼠标时,我想查看坐标的变化。但这似乎有点奇怪。

static void mousedev_packet(struct mousedev_client *client,
                signed char *ps2_data)
{
    struct mousedev_motion *p = &client->packets[client->tail];
    int val;
    printk(KERN_WARNING "..................tomxue: case 19.................");

    ps2_data[0] = 0x08 |
        ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07);
    ps2_data[1] = mousedev_limit_delta(p->dx, 127);
    ps2_data[2] = mousedev_limit_delta(p->dy, 127);
    p->dx -= ps2_data[1];
    p->dy -= ps2_data[2];
    val = p->dx;
    printk(KERN_WARNING "mousedev_packet: ps2_data[1]=%d ps2_data[2] =%d.................", ps2_data[1], ps2_data[2]);
    printk(KERN_WARNING "mousedev_packet: p->dx=%d p->dy=%d p=%p val=%d.................", p->dx, p->dy, p, val);

dmesg 如下:

[  105.631164] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.631195] mousedev_read data=�s�$......................
[  105.639160] mousedev_packet: ps2_data[1]=-25 ps2_data[2] =3.................
[  105.639160] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.639190] mousedev_read data=�s�$......................
[  105.647155] mousedev_packet: ps2_data[1]=-26 ps2_data[2] =3.................
[  105.647155] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.647186] mousedev_read data=�s�$......................
[  105.655151] mousedev_packet: ps2_data[1]=-24 ps2_data[2] =5.................
[  105.655181] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.655212] mousedev_read data=�s�$......................
[  105.663543] mousedev_packet: ps2_data[1]=-19 ps2_data[2] =6.................
[  105.663543] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.663574] mousedev_read data=�s�$......................
[  105.671142] mousedev_packet: ps2_data[1]=-17 ps2_data[2] =6.................
[  105.671173] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.671173] mousedev_read data=�s�$......................
[  105.679168] mousedev_packet: ps2_data[1]=-13 ps2_data[2] =5.................
[  105.679168] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.679199] mousedev_read data=�s�$......................
[  105.687133] mousedev_packet: ps2_data[1]=-8 ps2_data[2] =3.................
[  105.687164] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.687194] mousedev_read data=�s�$......................
[  105.695190] mousedev_packet: ps2_data[1]=-4 ps2_data[2] =1.................
[  105.695190] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.695220] mousedev_read data=�s�$......................
[  105.703155] mousedev_packet: ps2_data[1]=-5 ps2_data[2] =0.................
[  105.703186] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  105.703186] mousedev_read data=�......................
[  106.047302] mousedev_packet: ps2_data[1]=0 ps2_data[2] =1.................
[  106.047302] mouMinicom2.5Minicom2.5Minicom2.5sedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................
[  106.047332] mousedev_read data......................

正如你所看到的,p->dx并且p->dy总是为零,为什么?

4

1 回答 1

0

我感觉合理。

查看此输出:

[  105.639160] mousedev_packet: ps2_data[1]=-25 ps2_data[2] =3.................
[  105.639160] mousedev_packet: p->dx=0 p->dy=0 p=dd9b6a10 val=0.................

似乎在这一行

ps2_data[1] = mousedev_limit_delta(p->dx, 127);

p->dx-25,并且您也将ps2_data[1]成为-25

然后在这一行:

p->dx -= ps2_data[1];

你设置p->dxp->dx - ps2_data[1]. 或者,-25 - -250

于 2013-04-14T15:30:11.200 回答