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

Started by
1 comment, last by Gavin Williams 11 years, 9 months ago
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)


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);
// ==================================


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

2py1e7t.png

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 ?
Advertisement
I've rewritten the code to match the SharpDX version of Tut 13 from Rastertek, and it just wont run.


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);
// ==================================


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 :


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


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.
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 :


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;
}


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 !

This topic is closed to new replies.

Advertisement