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

This topic is 2169 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 :

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 on other sites
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. Edited by Gavin Williams

##### Share on other sites
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 ! Edited by Gavin Williams

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999986
×