Fix for small mouse movements

Official forum for open source FreePIE discussion and development.
Post Reply
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Fix for small mouse movements

Post by CyberVillain »

I think this is the number one feature that needs to be fixed for next release so I created a new thread for it.

See this branch

https://github.com/AndersMalmgren/FreeP ... ePlugin.cs

Problem is that Baggyg's code drift for some plugins while the old solution did not
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Fix for small mouse movements

Post by baggyg »

Code: Select all

// Reset the mouse values
                if ((int) DeltaXOut != 0)
                {
                    DeltaXOut = DeltaXOut - (int) DeltaXOut;
                }
                if ((int) DeltaYOut != 0)
                {
                    DeltaYOut = DeltaYOut - (int) DeltaYOut;
                }
You can remove the conditionals here since no movement would equate to a 0 movement anyway.

Code: Select all

// Reset the mouse values
DeltaXOut = DeltaXOut - (int) DeltaXOut;
DeltaYOut = DeltaYOut - (int) DeltaYOut;
I.e. without the conditional. However we then need to somehow identify when the sensor is drifting of its own accord (its important here to realise this is not a problem with our code, but with the sensor data itself) and negate these readings.

I have a couple of ideas how to achieve this so will download your latest branch and try although probably wont be until sometime next week.
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Fix for small mouse movements

Post by RescueGamer »

so, with this new mouse plugin the small sensors movements are better recognised for mouse purposes?
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Fix for small mouse movements

Post by baggyg »

RescueGamer wrote:so, with this new mouse plugin the small sensors movements are better recognised for mouse purposes?
Yes I have a version working here, that even very small precise movements are shown and feels natural with a Rift or YEI. However CyberVillian is worried about the change affecting the behaviour of some of the other plugins as he has seen some unwanted side effects. We are currently trying to resolve these side issues before a release.
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Fix for small mouse movements

Post by RescueGamer »

Ok, then I don't have to use this with my android device XD
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Fix for small mouse movements

Post by CyberVillain »

Well yes, try to move your phone just slightly, it will not move. So its the same problem for Android.
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Fix for small mouse movements

Post by RescueGamer »

Oks, i'll give it a try, i'll tell you what I get ;)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Fix for small mouse movements

Post by CyberVillain »

Updated the branch, I now use Baggyg's code. I have also added a deadband filter that can be used for devices with small drift. Please try it out, this works pretty well for me and my Android.

Code: Select all

def update():	
	x = filters.deadband(filters.delta(math.degrees(android.yaw)), 0.01)
	y = filters.deadband(filters.delta(math.degrees(android.roll)), 0.01)
	
	if x <> 0:
		diagnostics.watch(x)
		
	if y <> 0:
		diagnostics.watch(y)
		
	mouse.deltaX = x * 5
	mouse.deltaY = y * 5
	
if starting: 
	android.update += update
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Fix for small mouse movements

Post by baggyg »

Hi Cyber,
Tried your code here on the YEI and all working fine. With the right settings on the YEI suite the deadband wasn't needed, but changed the trust levels to emulate a bit of drift and the deadband works well. Its a good tradeoff to let the user decide the deadband level, but keep the accuracy of the <0.5 figures for small mouse movements.

One small efficiency change. Line 92 of MousePlugin.cs

Code: Select all

if ((deltaXOut != 0) || (deltaYOut != 0))
should be

Code: Select all

if ((int)deltaXOut != 0 || (int)deltaYOut != 0)
Since we don't need to send anything to the mouse if there is no movement.

Apart from that I think this is ready to be released. :-D
Post Reply

Return to “FreePIE”