How to dynamically switch on/off a mouse?
-
- Cross Eyed!
- Posts: 192
- Joined: Fri Jul 04, 2014 1:43 am
How to dynamically switch on/off a mouse?
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
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
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: How to dynamically switch on/off a mouse?
FreePIE currently uses directx DirectInput to read the mouse, its probably better to use Raw input beacuse then we could support multiple mice etc
-
- Cross Eyed!
- Posts: 192
- Joined: Fri Jul 04, 2014 1:43 am
Re: How to dynamically switch on/off a mouse?
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?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: How to dynamically switch on/off a mouse?
SOrry, no, i havent seen any way of doing that sadly. If you find anything let me know
-
- Cross Eyed!
- Posts: 192
- Joined: Fri Jul 04, 2014 1:43 am
Re: How to dynamically switch on/off a mouse?
Well, this is the article that gave me hope https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
- cybereality
- 3D Angel Eyes (Moderator)
- Posts: 11407
- Joined: Sat Apr 12, 2008 8:18 pm
Re: How to dynamically switch on/off a mouse?
@konstantin_lozev: Yes, that does look like the way you would go about doing something like this.
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
-
- Cross Eyed!
- Posts: 192
- Joined: Fri Jul 04, 2014 1:43 am
Re: How to dynamically switch on/off a mouse?
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.
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: How to dynamically switch on/off a mouse?
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
-
- Cross Eyed!
- Posts: 192
- Joined: Fri Jul 04, 2014 1:43 am
Re: How to dynamically switch on/off a mouse?
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.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
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.
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: How to dynamically switch on/off a mouse?
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
edit: It might be better to try from a simple console project first though
-
- Cross Eyed!
- Posts: 192
- Joined: Fri Jul 04, 2014 1:43 am
Re: How to dynamically switch on/off a mouse?
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.