How to dynamically switch on/off a mouse?

Official forum for open source FreePIE discussion and development.
Post Reply
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

How to dynamically switch on/off a mouse?

Post 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 :)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

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

Post 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
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

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

Post 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?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

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

Post by CyberVillain »

SOrry, no, i havent seen any way of doing that sadly. If you find anything let me know
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

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

Post by konstantin_lozev »

Well, this is the article that gave me hope https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

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

Post by cybereality »

@konstantin_lozev: Yes, that does look like the way you would go about doing something like this.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

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

Post by CyberVillain »

konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

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

Post 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.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

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

Post 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
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

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

Post 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.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

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

Post 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
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

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

Post 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.
Post Reply

Return to “FreePIE”