Skip to main content
GameDev.net gamedev.net
🔒 Locked

[SLIMDX] Help With Force Feedback

Started by munawar Oct 20, 2009 at 8:04 PM 4 replies 4.1k views
Original Post
munawar
munawar
Hi, I'm trying to set up force feedback. I enumerate all the devices and first get the joystick. Then I look for a force feedback device--just to see if the joystick accepts force feedback, I use GetDevices(DeviceClass.All, DeviceEnumerationFlags.ForceFeedback) to do this. Next, I create the joystick device, and create a new effect using the joystick device and the ForceFeedbackDriverGuid from the fource feedback DeviceInstance direct input found. However, when I create the effect, I get this error: SlimDX.DirectInput.DirectInputException was unhandled Message="REGDB_E_CLASSNOTREG: Class not registered (-2147221164)" Source="SlimDX" StackTrace: at SlimDX.Result.Throw[T](Object dataKey, Object dataValue) at SlimDX.Result.Record[T](Int32 hr, Boolean failed, Object dataKey, Object dataValue) at SlimDX.DirectInput.Effect..ctor(Device device, Guid guid) at TDV.dxInput.dInputInitFD(Device device, Guid forceFeedbackGuid) in E:\g\projects\TDV\dxInput.cs:line 114 The joystick is created using the guid of the DeviceInstance object for the joystick--I assume I have to pass in a Joystick device to the effects constructor, and give it the force feedback driver guid of that same device. However, that error keeps being thrown. Thanks for any help you can give! Munawar
munawar
munawar
Hi,
Just a quick update--I thought it was some or other DirectX runtime component not being installed with SlimDX hence the class not registered error, but it didn't fix anything when I downloaded the Aug 2009 DirectX SDK and installed it. I've reported this as issue 554, but I'm still not sure if I'm doing something wrong or if it realy is a SlimDX issue so if you can shed some light on that, I'd much appreciate it!

Overall, thanks for yet another amazing SlimDX release, and I'm glad to see force feedback is finally in! I would have used XInput for the joystick control as an alternative in the meantime, but it seems like XInput only supports "game pads", not actual "joysticks" as in flight sim controllers.
jpetrie
jpetrie
As far as I know that error means some COM class isn't registered on the system, which points to an installation problem of some sort, either in the runtimes or the driver for the device?

Can you include with the issue you posted a minimal compilable set of code that will reproduce the issue for you?

Quote:

I would have used XInput for the joystick control as an alternative in the meantime, but it seems like XInput only supports "game pads", not actual "joysticks" as in flight sim controllers.

Yes, XInput is basically for 360-type controllers.
munawar
munawar
Certainly, here it is. Thanks for getting back to me.
using SlimDX.DirectInput;static class InputHandler {private static Effects effect1;private static Joystick JSDevice;public static DirectInput directInput;public static void initInput(){directInput = new DirectInput();}public static void initInput(IntPtr handle, Guid g, Guid forceFeedbackGuid){JSDevice = new Joystick(directInput, g);JSDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Exclusive);initForceFeedback(JSDevice, forceFeedbackGuid); //THIS IS WHERE THE ERROR IS TRIPPEDJSDevice.Acquire();}public static void initForceFeedback(Device device, Guid forceFeedbackGuid)		{            effect1 = new Effect(device, forceFeedbackGuid); //THIS IS THE LINE CAUSING THE ERROR//Pseudocode: setup EffectParameters, and use//effect1.AddEffectParameters() to add it.}}         //class


I have a GUI form that initializes the joystick like this:

using SlimDX.DirectInput;public class GUI : System.Windows.Forms.Form	{    public setupInput(){InputHandler.initInput(); //set up DirectInput.IEnumerable joystickList = directInput.GetDevices(DeviceClass.GameController,                DeviceEnumerationFlags.AttachedOnly);//For our purposes, just grab the first controller we found.if (joystickList == null)return;foreach (DeviceInstance joystickDevice in joystickList) {InputHandler.initInput(this.Handle,joystickDevice.InstanceGuid,joystickDevice.ForceFeedbackDriverGuid);			break; //just init the first stick} //foreach} //method} //class


Hope this helps,
Munawar
munawar
munawar
Also, that's interesting about XInput. Do you know if this will remain the case for the lifetime of XInput--that it only supports game pads? If so, it seems like it is more of a limitation than a real motive to take advantage of the new API. I remember SlimDX Group mentioned this on their website, that since XBox is the "limiting agent" most of the API has been watered down to prevent compatibility issues. The way I understand it, that is the ONLY reason XAudio2 was invented--because XAudio was less powerful than DirectSound. Seems like that's the same case with XInput.
Mike.Popoloski
Mike.Popoloski
The problem is that ForceFeedbackDriverGuid is not ever going to be a valid parameter with which to create an effect. Valid values for that parameter are guids from SlimDX.DirectInput.EffectGuid or guids obtained from Device.GetEffects().

As far as XInput goes, the API is only designed to target Xbox360 gamepads. This isn't a limitation; that's the whole goal of the API. If you want input from a different device, you need to use another API, such as DirectInput or RawInput.
Mike Popoloski | Journal | SlimDX

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.