原始输入处理(区分辅助鼠标) [英] raw input handling (distinguishing secondary mouse)

查看:160
本文介绍了原始输入处理(区分辅助鼠标)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在winapi的原始输入中写了一些图片 虽然我不确定它的可靠性(不可靠),但似乎可以正常工作 (如果它可以在所有系统机器上运行,那么会有点麻烦)

也出现了很多问题,一个是

我想以旧的方式使用我的第一个(我的意思是普通/基础鼠标), 它是processint WM_MOUSEMOVE等,并移动箭头光标,只有 辅助鼠标,我需要用raw_input处理(主要可以保持rawinput不变),问题是

1)我如何确定rawinput检测到的鼠标是 次要的?

2)如果禁用,第二只鼠标也会移动我的箭头-cursor RIDEV_NOLEGACY设置它,然后它们都没有移动光标(它是沙漏形的沙漏),这也是错误的

认为也许我应该对它的设置有些不同,我的setrup rawinput函数就像

    void SetupRawInput()
    {

    static RAWINPUTDEVICE Rid[1];

    Rid[0].usUsagePage = 0x01;
    Rid[0].usUsage = 0x02;
    Rid[0].dwFlags = 0;     //   Rid[0].dwFlags =  RIDEV_NOLEGACY;   /
    Rid[0].hwndTarget = NULL;

    int r = RegisterRawInputDevices( Rid, 1, sizeof(Rid[0]) );

    if (!r)  ERROR_EXIT("raw input register fail");

    }

如何解决此问题并使其起作用? tnx

解决方案

我不知道我的方法是否是最好的方法,但这是我针对问题中第一项的处理方法:

当我使用GetRawInputData(...)处理WM_INPUT时,我检查以查看RAWINPUTHEADER结构(包含在从函数返回的RAWINPUT结构中)传回的设备句柄是否与我要使用的设备相同.如果不是,那么我根本就不用去发回数据,如果是,那么我将处理在RAWINPUT结构中返回的RAWINPUTMOUSE数据.

如果您想知道如何获取设备列表,可以使用GetRawInputDeviceList(...),它将返回您要使用的鼠标的设备句柄.

正如我所说,这可能不是最好的方法,但是我已经确认它确实可以达到我的目的.我也对键盘原始输入数据执行此操作.

关于项目#2,似乎它会影响这两只鼠标,因为Windows拥有对这些鼠标的独占访问权,因此如果不使用相同的标志注册所有特定的鼠标,就无法注册一只特定的鼠标.但是比我有更多知识的人可能会给出更好的解释.

I was writing some pices in winapi's raw input It seem to working though I am not sure how reliable (unfaliable) it is (and if it will be working on all systems machines etc, this is a bit worry)

also there appears many question, the one is

I would like to use my first (I mean normal/base mouse) in old way, it is processint WM_MOUSEMOVE etc and moving arrow cursor, only the secondary mouse I need processing by raw_input (primary can stay untouched by rawinput), the problem is

1) how can i be sure which mouse detected by rawinput is the secondary?

2) the second mouse moves also my arrow -cursor, if I disable it by RIDEV_NOLEGACY then both are not moving cursor (it bacame hourglass) and it is wrong too

think maybe i should setup it a bit differently my setrup rawinput function is like

    void SetupRawInput()
    {

    static RAWINPUTDEVICE Rid[1];

    Rid[0].usUsagePage = 0x01;
    Rid[0].usUsage = 0x02;
    Rid[0].dwFlags = 0;     //   Rid[0].dwFlags =  RIDEV_NOLEGACY;   /
    Rid[0].hwndTarget = NULL;

    int r = RegisterRawInputDevices( Rid, 1, sizeof(Rid[0]) );

    if (!r)  ERROR_EXIT("raw input register fail");

    }

how to resolve this issueas andmake it work? tnx

解决方案

I don't know if my approach is the best one, or not, but this is how I do it for the first item in your question:

When I process WM_INPUT using GetRawInputData(...), I check to see if the device handle passed back by the RAWINPUTHEADER structure (contained within the RAWINPUT structure returned from the function) is the same as the device I want to use. If it is not, then I simply don't bother sending back data, if it is, I then process the RAWINPUTMOUSE data returned in the RAWINPUT struct.

And if you're wondering how to get the list of devices, you can use GetRawInputDeviceList(...), which will return the device handles of the mice you're trying to work with.

As I said, this may not be the best way, but I have confirmed that it does work for my purposes. I also do this for my keyboard raw input data as well.

As for item #2, it seems likely that it affects both mice because Windows has exclusive access to the mice, so you can't register one specific mouse without registering them all with the same flags. But someone with more knowledge than I could probably give a better explanation.

这篇关于原始输入处理(区分辅助鼠标)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆