Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Gavin Williams   Members   -  Reputation: 708

Like
0Likes
Like

Posted 13 July 2012 - 05:25 PM

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 :

Posted Image

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, 13 July 2012 - 05:27 PM.


Sponsor:

#2 Gavin Williams   Members   -  Reputation: 708

Like
0Likes
Like

Posted 14 July 2012 - 08:05 PM

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, 15 July 2012 - 09:16 AM.


#3 Gavin Williams   Members   -  Reputation: 708

Like
0Likes
Like

Posted 15 July 2012 - 02:05 PM

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, 15 July 2012 - 02:57 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS