Sign in to follow this  
Gavin Williams

Mouse.GetCurrentState() producing zero's in fullscreen.

Recommended Posts

Gavin Williams    985
Hi,

When I switch to fullscreen, the mouse delta's become interspersed with zero's. The testing code is as follows (that is producing the graph below)

[CODE]
public void Poll(Screen screen)
{
if (mouse.Acquire().IsFailure)
return;
if (mouse.Poll().IsFailure)
return;
prevState = currState;
mouse.GetCurrentState(ref currState);
if (Result.Last.IsFailure)
return;
// ==================================
Debug.Instance.dataA.Add(currState.X);
// ==================================
[/CODE]

And to visualize what's happening, here is an image of the mouse X values :

[img]http://i49.tinypic.com/2py1e7t.png[/img]

On the left side is the mouse x delta's while in windowed mode, whereas on the right side, in fullscreen mode, it's evident that Mouse.GetCurrentState() is returning no data (in some of the frames).

I found this :

While DirectInput forms a part of the DirectX library, it has not been significantly revised since DirectX 8 (2001-2002). Microsoft recommends that new applications make use of the Windows message loop for keyboard and mouse input instead of DirectInput (as indicated in the Meltdown 2005 slideshow[1]), and to use XInput instead of DirectInput for Xbox 360 controllers.

But I'm not sure what to make of it, because I haven't found anything else warning me against direct-input.

Does anyone know what I might be doing wrong, or is this an issue with GetCurrentState() in fullscreen ? Edited by Gavin Williams

Share this post


Link to post
Share on other sites
Gavin Williams    985
I've rewritten the code to match the SharpDX version of Tut 13 from Rastertek, and it just wont run.

[CODE]
public void Poll(Screen screen)
{
prevState = currState;
currState = new MouseState();
var resultCode = ResultCode.Success;
try
{
var r = mouse.GetCurrentState(ref currState);
if (r.IsFailure)
{
if (r == ResultCode.InputLost || r == ResultCode.NotAcquired)
mouse.Acquire();
else
return;
}
}
catch (SlimDXException ex)
{
resultCode = ex.ResultCode;
}
catch (Exception)
{
return;
}
// ==================================
Debug.Instance.dataA.Add(currState.X);
// ==================================
[/CODE]

GetCurrentState is throwing an exception, i suppose because it's not aquired, but I don't know if this is correct behaviour. Shouldn't it just return a failed result !

If i trim the code down to :

[CODE]
prevState = currState;
currState = new MouseState();
try
{
mouse.GetCurrentState(ref currState);
}
catch
{
mouse.Acquire();
return;
}
[/CODE]

This code only gives 1 exception .. on the first entry into the Poll() method. So GetCurrentState isn't working or something is interfering with it's normal operation. Edited by Gavin Williams

Share this post


Link to post
Share on other sites
Gavin Williams    985
Well, if i start in fullscreen, the input is ok. So that makes me think that the issue is with the way i handle fullscreen toggle. It looks like it's not switching to 'exclusive' fullscreen mode, because I can still see the 2nd monitor, whereas when i start in fullscreen mode, the 2nd monitor is black. My toggle code is :

[CODE]
private void ToggleFullScreen()
{
swapChain.ResizeTarget(modeDescription);
swapChain.SetFullScreenState(!FullScreen, null);

// http://msdn.microsoft.com/en-us/library/windows/desktop/ee417025%28v=vs.85%29.aspx
// seems to suggest that the targets should be resized twice, 2nd time with Refresh rate zeroed out. It doesn't seem to change behaviour in my case.
//modeDescription.RefreshRate = new Rational();
//swapChain.ResizeTarget(modeDescription);
//modeDescription.RefreshRate = swapChain.Description.ModeDescription.RefreshRate;

FullScreen = swapChain.IsFullScreen;
}
[/CODE]

I'm investigating whether i need to specify the output in the SetFullScreenState() call and how to do that.

Edit : If I set displayModeScaling.Centred the render is smaller than HD, so i suspect it's getting the 2nd monitors info / output. But interestingly, when i turn the 2nd monitor off, the input is good for both windowed and fullscreen, but the render is STILL smaller ! Edited by Gavin Williams

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this