Jump to content
  • Advertisement
Sign in to follow this  
rkagerer

DataFormat struct for custom device

This topic is 2636 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

I need some help defining the DataFormat for a CustomDevice.

This works:

[font="'Courier New"] [[color="#2b91af"]StructLayout([color="#2b91af"]LayoutKind.Sequential, Size=4)]
[SlimDX.DirectInput.[color="#2b91af"]DataFormat([color="#2b91af"]DataFormatFlag.AbsoluteAxis)]
[color="blue"]public [color="blue"]struct [color="#2b91af"]X52DataFormat {
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber=-1)]
[color="blue"]public [color="blue"]byte Trigger;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte Fire;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte A;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte B;
}[/font]
[font="arial, verdana, tahoma, sans-serif"]
[/font][font="arial, verdana, tahoma, sans-serif"]But when I try to add additional fields it breaks down. i.e. The following gives an E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809) exception when trying to create the device. [/font][font="arial, verdana, tahoma, sans-serif"]
[/font]
[font="'Courier New"] [[color="#2b91af"]StructLayout([color="#2b91af"]LayoutKind.Sequential, Size=8)]
[SlimDX.DirectInput.[color="#2b91af"]DataFormat([color="#2b91af"]DataFormatFlag.AbsoluteAxis)]
[color="blue"]public [color="blue"]struct [color="#2b91af"]X52DataFormat {
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber=-1)]
[color="blue"]public [color="blue"]byte Trigger;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte Fire;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte A;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte B;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte C;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte Pinkie;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte D;
[SlimDX.DirectInput.[color="#2b91af"]DataObject(Type = [color="#2b91af"]ObjectDeviceType.Button, InstanceNumber = -1)]
[color="blue"]public [color="blue"]byte E;
}[/font]
[font="'Courier New"] ...
joy = [color="blue"]new SlimDX.DirectInput.[color="#2b91af"]CustomDevice<[color="#2b91af"]X52DataFormat>(di,[/font]
[font="'Courier New"] [color="blue"]new [color="#2b91af"]Guid([color="#a31515"]"{2b3e26d0-484d-11e0-8001-444553540000}"));[/font]


I've noticed that depending on whether or not it likes my struct definition, sometimes I instead get a failure when calling [font="consolas"]joy.GetCurrentState()[/font].

Any tips on how to set up my struct? I got this working using MDX (all int fields) but would rather use SlimDX to avoid loader locks, etc.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!