[Warning: This article is obsolote. I´d suggest you to read the Refreshed version here.]
Taking the issue where we left it yesterday...
The next step is to make an important choice: Inmediate or Buffered mode? Take into account that DX Action Mapping works in Buffered Mode only. Why? To answer that, let´s describe both modes a little bit:
Inmediate Mode
Take a look at how data is reported under the Inmediate Mode: all you get is a struct of the type JoystickState, MouseState or KeyboardState, which has all the data you need under some default fields, defined by DirectX (like AxisX, AxixY, etc). This fields are always the same, no matter which device you are accesing to. It´s device´s builder (i.e. Logitech) who decides what physical objects are mapped to what DX default fields. An example:
- For a joystick, it´s quite trivial to map it´s objects to fields, because JoystickState was originally designed for that: joysticks (as it´s name states). So, the AxisX field will almost always be mapped to the X-Axis of the joystick.
- What happens for a driving wheel? Ah! that´s different. That´s something DirectInput was not originally designed for, and when this kind of devices came out, instead of adapting DInput for them, DX guys decided to use existing structs to handle new devices. So, there´s no default field in the JoystickState structure for the WheelAxis object. In this way, some device builders will map wheel axis to AxisX, while others will do to the Rx Axis, and so on...
Buffered Mode
Are things different in Buffered Mode? Quite a bit.
In buffered mode, you don´t get access to the whole structure of data. Instead of that, you call the GetBufferedData() method, which retrieves a collection of BufferedData objects, one for each changing object in the device. That means, if the device is absolutely stall, no data will be returned.
One tip: To set the buffered mode, you have to manually change the property:
Device.Properties.BufferSize = 16.
Making the relationship
What we need is a way to save and recover from a file something like this:
and recover it as: DeviceGuid = new Guid( attributeGuidInnerText );
3.- The third attribute.... aaaahhh. This is a little bit more tricky.
more on this later...