Jump to content
  • Advertisement
Sign in to follow this  
VictorianChance

[SlimDX] How to get SlimDX equivalent of MDX BufferedData?

This topic is 2911 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 all,

I'm currently trying to build a generic action mapper using SlimDX. Previously in DirectX and Managed DirectX I would use the BufferedData class which was the list output of GetBufferedData().

This class is useful since it not only outputs the device object's data value, but also the device object's offset. Thus, in MDX I would use the device offset as a key in the action map, allowing me to generically map device object values to virtual actions.

Using SlimDX, for instance with the Joystick class, there seems to be no easy identifier that I can use for my action map, and no easy way to determine exactly what actions changed and what is their associated key.

An almost equivalent example of what I'm trying to do can be found at: http://www.codeproject.com/Articles/37446/Direct-Input-Custom-Action-Mapping-refresh.aspx

Does anyone have any idea of how this could be approached using SlimDX?

Thanks in advance for all the help

Share this post


Link to post
Share on other sites
Advertisement
Welcome to the forum.

SlimDX has a generic CustomDevice<TDataFormat> which exposes
IList<TDataFormat> GetBufferedData()

You probably can use that.

Share this post


Link to post
Share on other sites
Thanks for the welcome :)

Yes, I did notice the GetBufferedData() method. Unfortunately, its semantics seems to be a bit different from Managed DirectX, since it returns a list of buffered device states, instead of a list of device 'object' changes.

To illustrate the difference, in the Joystick class, the GetBufferedData() method returns a list of 'JoystickState', however the JoystickState class does not by itself indicate which actions have changed, nor does it provide a uniform polymorphic way of identifying an action.

Using JoystickState, if I want to access axis X, I would use the 'X' property, but if I want a slider, I have to use GetSliders() and index the array appropriately, etc.

In Managed DirectX, I merely needed to store the 'Offset' of the device object, for instance I would store 4 corresponding to axis Y, and each 'BufferedData' object from GetBufferedData() would indicate both the value of the object and its offset, so I could know for each device change the corresponding concrete action.

I think I could probably implement a CustomDevice<BufferedData> myself, but since the class constructor is protected internal I would have to build it into a modified version of the SlimDX library itself.

I'm sorry if I'm being a bit confusing. I believe the change is subtle, but still important, and there definitely should be something implementing CustomDevice<BufferedData> to provide the same behavior as the original Managed DirectX APIs.

Share this post


Link to post
Share on other sites
I see. I had a look at the implementation of GetBufferedData, and whereas MDX more or less exposes the underlying DX call, SlimDX abstrahated it away: It uses the offset to fill the TDataFormat through reflection, so your offset is lost.

You are right, I don't see any other way than extend the library for your needs - or consider a different approach on the client side. Maybe you are lucky and get help from the SlimDX team on the issue tracker, but I doubt they will integrate MDX compatibility just for the sake of it.

Share this post


Link to post
Share on other sites
Our goal is to be able to replicate any native callstream from managed code, and if an abstraction is getting in the way of that there's a problem. File an issue.

Share this post


Link to post
Share on other sites
Thanks, I just did that :)
I'm completely in favor of simplifying abstractions, but preserving the original native functionality should be a must too.

Thanks for all the assistance. I'll keep investigating either way for alternative ways to achieve a general action mapper with current SlimDX.

Issue link

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!