Sign in to follow this  

[SlimDX] Trouble initializing DirectInput

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, The SlimDX WIKI instructed that I post questions here concerning SlimDX but this seems to be an XNA forum, so forgive me if this is offtopic to this forum. I am switching to DirectInput using slimDX. Having a small problem though...well, it's small but I don't know if I'll have to do some recoding to fix it :). I have this code: imports SlimDX.DirectInput imports SlimDX.DirectInput.Key module dxInput public keyboardDev As Device Public Sub DInputInit(ByVal Handle As IntPtr) DirectInput.Initialize() 'initialize DI as instructed from the WIKI diDev = New Device(SystemGuid.Keyboard) diDev.SetCooperativeLevel(Handle, CooperativeLevel.Foreground + CooperativeLevel.Exclusive) diDev.Acquire() End Sub When I compile, I get this error: Too few type arguments to 'SlimDX.DirectInput.Device(Of DataFormat)'. (BC32042) - C:\Documents and Settings\Munawar\My Documents\projects\BPCR2\dxInput.vb:14 The error points to this line: public keyboardDev As Device I'm not doing any construction here, just declaring a device object, so why does the compiler expect some arguments? Also, I can't find record of these parameters anywhere--the only parameter to device is the GUID. Could this be a compiler issue? I have the march 2008 DXSDK installed but it doesn't help. Thanks for any help you can give. This is my first time implementing SlimDX--I just found out about three days ago that Managed DX is no longer supported (wow I'm behind the times :d), and the people at the XNA forums were very helpful in showing me what else I can use. Munawar

Share this post


Link to post
Share on other sites
I'm not too familiar with VB.Net, but I do know that DirectInput devices in SlimDX are generic, and they need a type parameter to specify the kind of data format they will be returning. This is how it would look in C#:


Device<KeyboardState> keyboardDevice = new Device<KeyboardState>(SystemGuid.Keyboard);





I don't think it will be all that hard to translate to VB.

EDIT: That link that UltimaX provided seems to point to some code that uses a very old version of SlimDX. DirectInput in SlimDX has been quite different for a few releases now.

Share this post


Link to post
Share on other sites
Device is a generic class ("Of DataFormat" is a big clue here). You cannot construct the class without providing a generic type parameter. On generic types in VB.

You need to supply the type of some class that represents the data format you're going to use. See the DirectInput sample that is included with SlimDX, that probably does it (although it'll be in C#, you'll have to adapt).

Share this post


Link to post
Share on other sites
Hi,
Thanks for your help, especially the VB article on generic classes. I was able to get the code working by doing this:
Imports SlimDX.DirectInput
public diDev as Device(of KeyboardState)
public sub DInputInit()
DirectInput.Initialize()
diDev=new Device(of KeyboardState)(SystemGuid.Keyboard)
'...
end sub

Again thanks for the article and the quick response!
Munawar

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this