PDA

View Full Version : DotNET+DirectInput(Joystick) Help needed!


DaXiiD
12-25-2007, 07:35 PM
Hi!
I am trying to get data from an external device (logitech MOMO wheel in this case) by using dotNET and DirectX DirectInput. Well I am stuck at the beginning... almost.

The biggest problem is that I can't get a "productGuID" or a "InstanceGuID" from my device.(or from a keyboard, mouse).

The code:

dotnet.loadAssembly "Microsoft.DirectX.DirectInput"
Manager = dotNetclass "Microsoft.DirectX.DirectInput.Manager"
DeviceClass = dotNetclass "Microsoft.DirectX.DirectInput.DeviceClass"
EnumDevicesFlags = dotNetclass "Microsoft.DirectX.DirectInput.EnumDevicesFlags"
Devicedataformat = dotnetclass "Microsoft.DirectX.DirectInput.Devicedataformat"
gameControllerList=Manager.GetDevices DeviceClass.gamecontrol EnumDevicesFlags.AttachedOnly
gameControllerList.MoveNext()
test=gameControllerList.current
test.productname
test.productGUID
rool=dotNetobject "Microsoft.DirectX.DirectInput.Device" test.productguid
rool.Acquire()


And maxscript response:

dotNetObject:System.Reflection.Assembly
dotNetClass:Microsoft.DirectX.DirectInput.Manager
dotNetClass:Microsoft.DirectX.DirectInput.DeviceClass
dotNetClass:Microsoft.DirectX.DirectInput.EnumDevicesFlags
dotNetClass:Microsoft.DirectX.DirectInput.DeviceDataFormat
dotNetObject:Microsoft.DirectX.DirectInput.DeviceList
true
dotNetObject:Microsoft.DirectX.DirectInput.DeviceInstance
"Logitech MOMO Racing USB"
dotNetObject:System.Guid
dotNetObject:Microsoft.DirectX.DirectInput.Device
undefined


Messy code, sorry about that.

What am I doing wrong. I can't wrap my head around it. Any input on this is much much appreciated.

ypuech
12-25-2007, 09:38 PM
ToString() method is useful to print non-string managed values:
test.ProductGUID.ToString()
The ProductName seems good but if you print the Guid value, does it looks good ?

DaXiiD
12-25-2007, 10:16 PM
Thank you for your input :)



"test.productGUID.ToString()" does the trick and outputs the GUID as needed.

But here comes an other problem probably due to my lack of expereience with dotNET/Directinput via maxscript:
By using "ToString()" it gives me: "ca03046d-0000-0000-0000-504944564944" as a productGuID. But it also gives me an error on the next line where i try to create a new device for the steeringwheel: -- Runtime error: No constructor found which matched argument list: Microsoft.DirectX.DirectInput.Device

By not using "ToString()" i get no errors , and GuiD prints:"dotNetObject:System.Guid" But Acquire() returns undefined :(

Or I think atleast I am trying to create a new device :D In C# it would be like this?:
wheelDevice = new Device(deviceInstance.ProductGuid);
But how do you do it through maxscript? Thank you in advance

ypuech
12-26-2007, 07:47 AM
But here comes an other problem probably due to my lack of experience with dotNET/Directinput via maxscript
Maybe you're the first in the world to use DirecInput in MAXScript :).

You build the Device with dotNetObject so it's good but try to enclose the Guid between ():
rool = dotNetobject "Microsoft.DirectX.DirectInput.Device" (test.ProductGuid)
It's the only solution I can see :D...

DaXiiD
12-26-2007, 09:49 AM
Maybe you're the first in the world to use DirecInput in MAXScript :).

Didn't expect that Then I am probably quite alone on this. :p

Nope brackets don't work either.

By investigating furter I found that "rool" has properties of my wheel, like its name and etc. So a new device is created!! But Acquire() still returns undefined. I'll try to investigate further.

ypuech
12-26-2007, 09:53 AM
By investigating furter I found that "rool" has properties of my wheel, like its name and etc. So a new device is created!! But Acquire() still returns undefined. I'll try to investigate further.
So, it looks that it's not related to the MAXScript code.

DaXiiD
12-26-2007, 10:40 AM
Right you are!
Actually almost everything was working from the beginning. rool.Acquire() returning "undefined" scared me away, but it is correct. I can get some axis data from my wheel by using "rool.Currentjoystickstate.x", yay!

Now the buttons and some UI :)

CGTalk Moderation
12-26-2007, 10:40 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.