Hi Phil,
Unfortunately no. DirectX and SDL are quite a bit different in lots of ways that would make it difficult to support DirectX and SDL at the same time. For example, take something simple like panning a sound to the left or right. DirectSound and SDL Mixer have two completely different methods of handling this. In DirectX DirectSound to pan a sound you merely need to pass the pan control a value from -10000, max left, to 10000, max right. It would look something like this.


// Center the sound in the right speaker.
sound.Pan = 5000;

SDL Mixer doesn't do it that way. You pan sounds by controling the stereo channels independantly of each other. Each channel has a range of 0, silence, to 250, full volume. Anyway, to do what I did above using the SDL Audio support it would look like this.

// Center the sound in the right speaker.
channel.SetPanning(0, 125);

Obviously, the two methods aren't remotely similar, and this is a fairly miner procedure all things considered. When we get into subjects like SDL Input vs DirectInput we are comparing apples and oranges. In my personal opinion SDL input support is much easier to work with than DirectX. Even though SDL Input doesn't yet support force feedback I rather like how they handle joysticks, game pads, and stearing wheels on the Windows side. It is much easier to work with than DirectInput by a long shot. To enable a joystick using SDL Input all I need to do is add the following lines to my engine.

Events.JoystickAxisMotion +=
new EventHandler<JoystickAxisEventArgs>(this.JoystickAxisChanged);
Events.JoystickButtonDown += new EventHandler<JoystickButtonEventArgs>(this.JoystickButtonDown);
joystick = Joysticks.OpenJoystick(0);

This is infinitely easier and less complicated than the way I would do it using DirectInput. With DirectInput to do the same thing it would look something like this.

// Attempt to locate a compatible joystick/game pad.
foreach (DeviceInstance instance in Manager.GetDevices(DeviceClass.GameControl,
EnumDevicesFlags.AttachedOnly))
{

// Grab the first game controller we find.
joystick = new Microsoft.DirectX.DirectInput.Device(instance.InstanceGuid);

// Exit the loop.
break;
}

// If we found a joystick
// proceed with initialization.
if (joystick != null)
{

// Initialize joystick state object.
stickstate = new JoystickState();

// Setup button state array.
buttons = new bool[12];

// Set joystick data format.
joystick.SetDataFormat(DeviceDataFormat.Joystick);

// Set the cooperative level.
joystick.SetCooperativeLevel(this, CooperativeLevelFlags.Background |
CooperativeLevelFlags.NonExclusive);

// Set the axis range.
// Normally a range of 10000 is standard
// for most joystick and game pad devices.
foreach (DeviceObjectInstance doi in joystick.Objects)
{

// If the joystick axis is not 0
// set it to 5000 units per stick direction.
if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
{

// Set axis range.
joystick.Properties.SetRange(ParameterHow.ById,
doi.ObjectId, new InputRange(-5000, 5000));
}
}

// Set joystick axis flag.
joystick.Properties.AxisModeAbsolute = true;

// Aquire the joystick for use.
joystick.Acquire();
}

// If initialization failed
// set joystick to null
// and continue with normal operation.
else
{
joystick = null;
}


Smile. That is just a strait grab any joystick we see piece of code using DirectX. That doesn't have any special features like force feedback or some of the more advanced features of DirectInput. As you can see from a programming point of view DirectX is infinitely more complicated and not at all compatible with SDL. Part of the reason I made the switch is SDL is much much easier to learn, use, and it supports Mac OS and Linux as well as Windows. I think eventually switching to it will pay off as it has its own advantages/disadvantages here.
Cheers!

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gam...@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to