PDA

View Full Version : Should a forcefeedback effect play on creation?



mrpascal
29-11-2006, 12:16 PM
Hi,

I'm struggling with FF for my XFX gamepad. It works but it's buggy. I'm using XP, Delphi 2006 and the latest October 2006 DX headers.

Here's my effect creation code:

procedure CreateForceFeedbackEffect;
var
I:IDirectInputEffect;
E:DIEFFECT;
F:array[0..0] of DICONSTANTFORCE;
A:array[0..0] of dword;
D:array[0..0] of longint;
H:HResult;
begin
F[0].lMagnitude:=5000;
A[0]:=DIJOFS_X;
D[0]:=0;
ZeroMemory(@E,sizeof(E));
with E do
begin
dwSize:=sizeof(DIEFFECT);
dwFlags:=DIEFF_CARTESIAN or DIEFF_OBJECTOFFSETS;
dwDuration:=INFINITE;
dwSamplePeriod:=0;
dwGain:=DI_FFNOMINALMAX;
dwTriggerButton:=DIEB_NOTRIGGER;
dwTriggerRepeatInterval:=0;
cAxes:=3;
rgdwAxes:=@A;
rglDirection:=@D;
lpEnvelope:=nil;
cbTypeSpecificParams:=sizeof(F);
lpvTypeSpecificParams:=@F;
dwStartDelay:=0;
end;
if BlahBlah.CreateEffect(GUID_ConstantForce,@E,I,nil) =DI_OK then blah etc.


The pad rumbles for 1 second when CreateEffect is processed. There are no error messages anywhere in my code (all results are checked). I'm sure it's not normal for it to play after creation. Any ideas?

After creation I can use the Start command to start the infinite effect but Stop does nothing (even though it returns DI_OK). I have to use SendForceFeedbackCommand (DISFFC_STOPALL) to stop the rumble. Are these problems linked?

Thanks for any advice - I pulling out what little hair I have!!!

WILL
29-11-2006, 01:39 PM
Hi mrpascal, welcome to PGD! :)

I'm sorry, but I've no experience with Force Feedback myself, but I'm sure that there are a few here that may have worked with it previously. I'd like to ask you to let us know about your progress with it as it's not a topic that has not been covered too much here in the past.

Also, I've edited your post to use our own unique Pascal code highlighting tags, please take advantage of these wonderful tags as it makes reading your code so much nicer than straight HTML. ;)

mrpascal
30-11-2006, 09:40 AM
Hi Will,

Thanks for formatting my code - it's much more readable now! I shall do that in the future as you suggest.

As I mentioned I have found it really hard finding any info on FF in Delphi. There is quite a lot of C out there and I've been converting it but I may be making errors with pointers etc. I'm also confused by how FF is treated with a gamepad. I'm assuming FF was designed for a joystick to push the stick against the users pressure but how does it work in a gamepad? There are no directions or axis involved, just two motors which rumble with varying intensities. I'm hacking my way through using experiments but I'd love to find some real information on it.