Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] DirectInput Problem

Started by Mr_Fhqwhgads Jun 4, 2006 at 12:36 AM 3 replies 800+ views
Original Post
Mr_Fhqwhgads
Mr_Fhqwhgads
I get this exception
Quote:
System.ArgumentException was unhandled Message="Value does not fall within the expected range." Source="Microsoft.DirectX" StackTrace: at Microsoft.DirectX.DirectInput.Device.Acquire() at SoC.Core.Input.cMouse..ctor(Form window) in C:\Documents and Settings\ryan\Desktop\soc\SoC\Core\Input\cMouse.cs:line 24 at SoC.Core.cDirectX..ctor(Form window) in C:\Documents and Settings\ryan\Desktop\soc\SoC\Core\cDirectX.cs:line 27 at SoC.cKernel..ctor() in C:\Documents and Settings\ryan\Desktop\soc\SoC\cKernel.cs:line 35 at SoC.main.Main(String[] args) in C:\Documents and Settings\ryan\Desktop\soc\SoC\main.cs:line 18 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
With this code. I have no idea how to fix it.
_mouse = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);
_mouse.SetCooperativeLevel(_window.Handle, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.NonExclusive);
_mouse.Acquire();
Blupix Games
Enselic
Enselic
Did you even read your own code? [rolleyes]

_mouse = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);   ^                                                            ^ mouse                                                       keyboard wtf?


If you change to SystemGuid.Mouse you have a better chance of not getting an exception.
Mr_Fhqwhgads
Mr_Fhqwhgads
My variable is named _mouse. I put the underscore to sya that its a private variable. And The SystemGuid shouldn't matter, I changed and I still get an exception.
Blupix Games
Mr_Fhqwhgads
Mr_Fhqwhgads
Quote:
Original post by Enselic
Try to call
 _mouse.SetDataFormat(DeviceDataFormat.Mouse);
before you acquire.


Thanks!
Blupix Games

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.