Original Post
Does anyone know where the DirectInput Device guids are located in .NET 2.0? They used to be SystemGuid.* but now I have no idea where they are. Thanks
Quote:
Original post by Alpha_ProgDes
Microsoft.DirectX.DirectInput ?
here's a link. hope it helps.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_m/directx/ref/microsoft.directx.directinput.asp
Guid guid = new Guid();InputList<DeviceInstance> inputList = Manager.Devices;foreach ( DeviceInstance d in inputList ){ if ( d.ProductName == "Mouse" ) { guid = d.Product; break; }}Quote:Yeah, I had that problem, you have to set the data format like in unmanaged.
Original post by Maddin
Hi, I actually did the same thing, but I was using the DeviceInstance.Instance property. But it doesen't matter wether I user DeviceInstance.Instance or DeviceInstance.Product I always get an Exception when trying to aquire the device: "Value does not fall within the expected range!".
The code worked flawlessly with the .NET 1.1 MDX-SDK. Anyone else experiencing this kind of problem?
public enum DeviceType { LimitedGameSubtype = 1, Device = 17, Mouse = 18, Keyboard = 19, Joystick = 20, Gamepad = 21, Driving = 22, Flight = 23, FirstPerson = 24, DeviceControl = 25, ScreenPointer = 26, Remote = 27, Supplemental = 28, }Guid keyboardGuid = new Guid();InputList<DeviceInstance> deviceInstances = Manager.GetDevices(DeviceType.Keyboard, EnumDevicesFlags.AllDevices);if (deviceInstances.Count >= 1) keyboardGuid = deviceInstances[0].Instance; public void CreateDevices() { InputList<DeviceInstance> inputlist = Manager.GetDevices(DeviceClass.Keyboard, EnumDevicesFlags.AttachedOnly); if (inputlist.Count > 0) { try { m_keyboard = new Device(inputlist[0].Instance); try { m_keyboard.SetCooperativeLevel(this.Handle, CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background); m_keyboard.Acquire(); MessageBox.Show("Keyboard-Device acquired"); } catch (Exception e2) { MessageBox.Show("Could not acquire device : " + e2.ToString()); } } catch (Exception e) { MessageBox.Show("Could not create device " + inputlist[0] + ": " + e.ToString()); } } }Quote:
Original post by Maddin
Looks like I'm the only one who's not able to acquire the created devices. I use the following code and I still always get an "Value does not fall within the expected range" - exception when trying to acquire the device. The code lies directly within my form-class, so this.Handle points to the handle of the form.
*** Source Snippet Removed ***
Anyone has a solution for this?
Thanks
m_keyboard.SetDataFormat(DeviceDataFormat.Keyboard);This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more