Page 1 of 1

How to dynamically switch on/off a mouse?

Posted: Sun Feb 08, 2015 1:37 pm
by konstantin_lozev
Hello, I have been trying to intercapt mouse movement and block it on the fly before it reaches the PC FPS. GlovePIE has the ability to swalow a mouse, but that is only for the cursor, so any game that reads the raw mouse data, i.e. all FPSs is not affected :(
Now, I read on some forums that it's possible to intercept the mouse readings at that level with WH_MOUSE_LL but I have not seen a solution. My question is whether that is easily doable and is there support for that in FreePIE.
My goal is to be able to read selectively an airmouse. Currently, I have no means to do that.
Thanks in advance :)

Re: How to dynamically switch on/off a mouse?

Posted: Sun Feb 08, 2015 2:21 pm
by CyberVillain
FreePIE currently uses directx DirectInput to read the mouse, its probably better to use Raw input beacuse then we could support multiple mice etc

Re: How to dynamically switch on/off a mouse?

Posted: Sun Feb 08, 2015 3:45 pm
by konstantin_lozev
Thanks for the info. I guess that means that FreePIE is unable to swallow a mouse for the desktop, let alone affect FPSs... Still, do you know if it is at all possible to do that?

Re: How to dynamically switch on/off a mouse?

Posted: Sun Feb 08, 2015 5:12 pm
by CyberVillain
SOrry, no, i havent seen any way of doing that sadly. If you find anything let me know

Re: How to dynamically switch on/off a mouse?

Posted: Mon Feb 09, 2015 2:50 pm
by konstantin_lozev
Well, this is the article that gave me hope https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Re: How to dynamically switch on/off a mouse?

Posted: Mon Feb 09, 2015 10:03 pm
by cybereality
@konstantin_lozev: Yes, that does look like the way you would go about doing something like this.

Re: How to dynamically switch on/off a mouse?

Posted: Tue Feb 10, 2015 2:52 am
by CyberVillain

Re: How to dynamically switch on/off a mouse?

Posted: Tue Feb 10, 2015 10:24 am
by konstantin_lozev
CyberVillain wrote:More info with c# code

http://stackoverflow.com/questions/4524 ... de-using-c
Yeah, that same paragraph
"Calling CallNextHookEx is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications."
was the one that I thought is the good news :)
Now, on how to do it, I am no Windows programmer, let alone C#, but I can give it a try from the examples given. Airmice are a nice option to work on since they have become very common and cheap, have good connectivity and low lag. The problem is of course they have drift, so they are best used as an add-on motion control to your HMD for quick intervals of motion control gestures. For that however, they have to be muted for most of the time. This is why I needed the on/off dynamic switching.

Re: How to dynamically switch on/off a mouse?

Posted: Tue Feb 10, 2015 10:50 am
by CyberVillain
Also how do you make sure that your hook is first? More over, you need to let the mouse emulation trigger, so you need to let that hook pass, etc. lots of questions

Re: How to dynamically switch on/off a mouse?

Posted: Tue Feb 10, 2015 11:56 am
by konstantin_lozev
CyberVillain wrote:Also how do you make sure that your hook is first? More over, you need to let the mouse emulation trigger, so you need to let that hook pass, etc. lots of questions
Yeah, I asked myself this question too. If that does not work though, I guess you can still capture the raw mouse movement at that low level and at every hook you input at the same low level the negative of the reported mouse movement. This way all the other programmes that read the airmouse at that low level should get at the same time 0 movement.
I actually tried this with GlovePIE, but it does not work, since it does not rely on the low-level hooks and instead corrects at the whatever the Glovepie framerate is set (default around 60hz, but can get to 500hz apparently, which actually did not make a different for my case) and then at directinput level. So basically you have a "tug of war" between the low-level readings that immediately get captured by the game and the "correction" through directinput, which all results in jitter.
To summarise, I think that even if blocking the passing of the message does not work, I think what can work is correction parallel to the low level mouse messages with the exact negative movement.

Re: How to dynamically switch on/off a mouse?

Posted: Wed Feb 11, 2015 11:19 am
by CyberVillain
To be realistic I wont have time to investigate in this, if you download VS2013 Express I can assist you getting FreePIE to compile etc, also show you have you use Hooks in C#

edit: It might be better to try from a simple console project first though

Re: How to dynamically switch on/off a mouse?

Posted: Wed Feb 11, 2015 3:35 pm
by konstantin_lozev
Yeah, I think best would he to start clean with a simple separate programme that switches off the airmouse on keyboard click. If you point me to the right sources, I can try that in the coming weekends.