FS2_Open
Open source remastering of the Freespace 2 engine
joy_ff.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #include "math/vecmat.h"
13 #include "io/sw_force.h"
14 #include "osapi/osregistry.h"
15 #include "io/joy_ff.h"
16 #include "osapi/osapi.h"
17 
18 
19 
20 typedef struct {
24  DWORD axes[2];
25  LONG direction[2];
26  GUID guid;
28 
32 
35 
37 void joy_ff_stop_effects();
38 
50 
57 
59 
61 void init_periodic_effect_struct(di_periodic_effect_struct *effect, int type, int dur, int per, int ang = 0, int mag = 10000, int att = 0, int fade = 0);
62 
64 {
65  int ff_enabled;
66 
67  Joy_ff_enabled = 0; // Assume no force feedback
68  ff_enabled = os_config_read_uint(NULL, "EnableJoystickFF", 0);
69 
70  if (ff_enabled) {
71  HRESULT hr;
72  TCHAR g_szOutput[256];
73  TCHAR szCodeString[256];
74 
75  Joy_ff_directional_hit_effect_enabled = os_config_read_uint(NULL, "EnableHitEffect", 1);
76 
78  if (FAILED(hr)) {
79  nprintf(("Sandeep", "No FF On Joystick, not using FF\n"));
80  SWFF_ErrorCodeToString(hr, &szCodeString[0]);
81  wsprintf(g_szOutput, "Make sure JOYSTICKID1 has Force Feedback\n"
82  "Code = %lx: %s\n", hr, szCodeString);
83 
84  nprintf(("Sandeep", g_szOutput));
85  return -1;
86 
87  }
88 
89  nprintf(("Sandeep", "There is FF on this joystick! (The peasants cheer)\n"));
92  return -1;
93  Joy_ff_enabled = 1;
94  }
95 
96  return 0;
97 }
98 
100 {
101  if (Joy_ff_enabled) {
102  pSpring->Stop();
105  pDiDevice->Unacquire();
106  pDiDevice->Release();
107  pDi->Release();
108  }
109 }
110 
111 HRESULT joy_ff_handle_error(HRESULT hr, char *eff_name = NULL)
112 {
113  if (FAILED(hr)) {
114  TCHAR szCodeString[256];
115 
116  SWFF_ErrorCodeToString(hr, szCodeString);
117  if (eff_name)
118  nprintf(("Joystick", "FF: Error for %s: %s\n", eff_name, szCodeString));
119  else
120  nprintf(("Joystick", "FF: Error: %s\n", szCodeString));
121  }
122 
123  return hr;
124 }
125 
126 int joy_ff_create_std_periodic(LPDIRECTINPUTEFFECT *eff, int type, int dur, int per, int ang = 0, int mag = 10000, int att = 0, int fade = 0)
127 {
128  joy_ff_handle_error(SWFF_CreatePeriodicEffect(pDiDevice, eff, type, dur, per, ang, mag, 0, att, 0, fade, 0, -1));
129  if (!*eff)
130  return -1;
131 
132  return 0;
133 }
134 
136 {
137  HRESULT hr;
138 
139  nprintf(("Joystick", "FF: Starting effect %s\n", name));
140  hr = joy_ff_handle_error(eff->Start(1, 0));
141  if (hr == DIERR_INPUTLOST) {
143  joy_ff_handle_error(eff->Start(1, 0));
144  }
145 }
146 
148 {
150  pDiDevice,
151  &pHitEffect1,
152  300000, // Duration
153  0, // Angle
154  10000, // Magnitude
155  0, // Attack time
156  10000, // Attack level
157  120000, // Fade time
158  1, // Fade level
159  -1), "HitEffect1");
160 
161  if (pHitEffect1)
162  nprintf(("Joystick", "FF: Hit effect 1 loaded\n"));
163  else { // bail out early if we can't even load this (because rest probably won't either and failing is slow.
164  nprintf(("Joystick", "FF: Hit effect 1 failed to load\n"));
165  return -1;
166  }
167 
169  &pHitEffect2,
170  SINE,
171  300000, // Duration
172  100000, // Period
173  9000, // Angle
174  10000, // Magnitude
175  100000, // Attack time
176  100000); // Fade time
177 
178  if (pHitEffect2)
179  nprintf(("Joystick", "FF: Hit effect 2 loaded\n"));
180  else
181  nprintf(("Joystick", "FF: Hit effect 2 failed to load\n"));
182 
184  pDiDevice,
185  &pShootEffect,
187  160000, // Duration
188  20000, // Period
189  0, // Angle
190  10000, // Magnitude
191  0,
192  0,
193  0,
194  120000,
195  0, -1), "ShootEffect");
196 
197  if (pShootEffect)
198  nprintf(("Joystick", "FF: Fire primary effect loaded\n"));
199  else
200  nprintf(("Joystick", "FF: Fire primary effect failed to load\n"));
201 
203  pDiDevice,
205  200000, // Duration
206  0, // Angle
207  10000, // Magnitude
208  50000, // Attack time
209  10000, // Attack level
210  100000, // Fade time
211  1, // Fade level
212  -1), "SecShootEffect");
213 
214  if (pSecShootEffect)
215  nprintf(("Joystick", "FF: Fire Secondary effect loaded\n"));
216  else
217  nprintf(("Joystick", "FF: Fire Secondary effect failed to load\n"));
218 
220  pDiDevice,
221  &pSpring,
222  SPRING,
223  INFINITE, // uS
224  100, // X Coefficient
225  0, // X Offset
226  100, // Y Coefficient
227  0, // Y Offset
228  -1), // button play mask
229  "Spring");
230 
231  if (pSpring) {
232  nprintf(("Joystick", "FF: Spring effect loaded\n"));
233  joy_ff_start_effect(pSpring, "Spring");
234 
235  } else
236  nprintf(("Joystick", "FF: Spring effect failed to load\n"));
237 
239  &Struct_afterburn1,
240  SINE,
241  INFINITE, // Duration
242  20000, // Period
243  0, // Angle
244  8000); // Magnitude
245 
246  pDiDevice->CreateEffect(Struct_afterburn1.guid, &Struct_afterburn1.effect, &pAfterburn1, NULL);
247  if (pAfterburn1)
248  nprintf(("Joystick", "FF: Afterburner effect 1 loaded\n"));
249  else
250  nprintf(("Joystick", "FF: Afterburner effect 1 failed to load\n"));
251 
253  &Struct_afterburn2,
254  SINE,
255  INFINITE, // Duration
256  120000, // Period
257  9000, // Angle
258  4400); // Magnitude
259 
260  pDiDevice->CreateEffect(Struct_afterburn2.guid, &Struct_afterburn2.effect, &pAfterburn2, NULL);
261  if (pAfterburn2)
262  nprintf(("Joystick", "FF: Afterburner effect 2 loaded\n"));
263  else
264  nprintf(("Joystick", "FF: Afterburner effect 2 failed to load\n"));
265 
267  &Struct_dock,
268  SQUARE_HIGH,
269  125000, // Duration
270  100000, // Period
271  9000, // Angle
272  4000); // Magnitude
273 
274  pDiDevice->CreateEffect(Struct_dock.guid, &Struct_dock.effect, &pDock, NULL);
275  if (pDock)
276  nprintf(("Joystick", "FF: Dock effect loaded\n"));
277  else
278  nprintf(("Joystick", "FF: Dock effect failed to load\n"));
279 
281  &Struct_explode,
283  500000, // Duration
284  20000, // Period
285  9000, // Angle
286  10000, // Magnitude
287  0, // Attack time
288  500000); // Fade time
289 
290  pDiDevice->CreateEffect(Struct_explode.guid, &Struct_explode.effect, &pExplode, NULL);
291  if (pExplode)
292  nprintf(("Joystick", "FF: Explosion effect loaded\n"));
293  else
294  nprintf(("Joystick", "FF: Explosion effect failed to load\n"));
295 
297  &Struct_deathroll1,
298  SINE,
299  INFINITE, // Duration
300  200000, // Period
301  0, // Angle
302  10000, // Magnitude
303  2000000, // Attack time
304  0); // Fade time
305 
306  pDiDevice->CreateEffect(Struct_deathroll1.guid, &Struct_deathroll1.effect, &pDeathroll1, NULL);
307  if (pDeathroll1)
308  nprintf(("Joystick", "FF: Deathroll effect 1 loaded\n"));
309  else
310  nprintf(("Joystick", "FF: Deathroll effect 1 failed to load\n"));
311 
313  &Struct_deathroll2,
314  SINE,
315  INFINITE, // Duration
316  200000, // Period
317  9000, // Angle
318  10000, // Magnitude
319  2000000, // Attack time
320  0); // Fade time
321 
322  pDiDevice->CreateEffect(Struct_deathroll2.guid, &Struct_deathroll2.effect, &pDeathroll2, NULL);
323  if (pDeathroll2)
324  nprintf(("Joystick", "FF: Deathroll effect 2 loaded\n"));
325  else
326  nprintf(("Joystick", "FF: Deathroll effect 2 failed to load\n"));
327 
328  return 0;
329 }
330 
332 {
334 
335  if (pDeathroll1)
336  pDeathroll1->Stop();
337 
338  if (pDeathroll2)
339  pDeathroll2->Stop();
340 }
341 
343 {
344  v.xyz.z = 0.0f;
345 // joy_ff_handling_scaler = (int) ((vm_vec_mag(&v) - 1.3f) * 10.5f);
346  joy_ff_handling_scaler = (int) ((vm_vec_mag(&v) + 1.3f) * 5.0f);
347 // joy_ff_handling_scaler = (int) (vm_vec_mag(&v) * 7.5f);
348 }
349 
350 void joy_ff_adjust_handling(int speed)
351 {
352  int v;
353 
354  v = speed * joy_ff_handling_scaler * 2 / 3;
355 // v += joy_ff_handling_scaler * joy_ff_handling_scaler * 6 / 7 + 250;
356  v += joy_ff_handling_scaler * 45 - 500;
357  if (v > 10000)
358  v = 10000;
359 
360  if (pSpring) {
361  if (Spring_cond_effect.DIConditionStruct[0].lPositiveCoefficient != v) {
362  HRESULT hr;
363 
364  Spring_cond_effect.DIConditionStruct[0].lPositiveCoefficient = v;
365  Spring_cond_effect.DIConditionStruct[0].lNegativeCoefficient = v;
366  Spring_cond_effect.DIConditionStruct[1].lPositiveCoefficient = v;
367  Spring_cond_effect.DIConditionStruct[1].lNegativeCoefficient = v;
368  nprintf(("Joystick", "FF: New handling force = %d\n", v));
369 
370  hr = joy_ff_handle_error(pSpring->SetParameters(&Spring_cond_effect.DIEffectStruct, DIEP_TYPESPECIFICPARAMS), "Spring");
371  if (hr == DIERR_INPUTLOST) {
373  joy_ff_handle_error(pSpring->SetParameters(&Spring_cond_effect.DIEffectStruct, DIEP_TYPESPECIFICPARAMS), "Spring");
374  }
375  }
376  }
377 }
378 
379 void joy_ff_change_effect(di_periodic_effect_struct *s, LPDIRECTINPUTEFFECT eff, int gain = -1, int dur = 0, int flags = -1)
380 {
381  int reload = 0;
382 
383  if ((gain >= 0) && ((int) s->effect.dwGain != gain)) {
384  s->effect.dwGain = gain;
385  nprintf(("Joystick", "FF: Gain reset to %d\n", gain));
386  reload = 1;
387  }
388 
389  if (dur && ((int) s->effect.dwDuration != dur)) {
390  s->effect.dwDuration = dur;
391  nprintf(("Joystick", "FF: Duration reset to %d\n", dur));
392  reload = 1;
393  }
394 
395  if (flags == -1) {
397  nprintf(("Joystick", "FF: Doing full reload of effect\n"));
398  }
399 
400  if (flags != (DIEP_DURATION | DIEP_GAIN))
401  reload = 1;
402 
403  if (reload) {
404  HRESULT hr;
405 
406  nprintf(("Joystick", "FF: Swapping in a new effect\n"));
407  hr = joy_ff_handle_error(eff->SetParameters(&s->effect, flags));
408  if (hr == DIERR_INPUTLOST) {
410  joy_ff_handle_error(eff->SetParameters(&s->effect, flags));
411  }
412 
413  } else
414  nprintf(("Joystick", "FF: Swap effect requested, but nothing changed\n"));
415 }
416 
418 {
419  DWORD flags;
420 
421  eff->GetEffectStatus(&flags);
422  return (flags & DIEGES_PLAYING);
423 }
424 
426 {
427  if (pDock) {
428  pDock->Stop();
429  if (joy_ff_handle_error(SWFF_SetGain(pDock, 10000), "Dock") == DIERR_INPUTLOST) {
431  joy_ff_handle_error(SWFF_SetGain(pDock, 10000), "Dock");
432  }
433 
434  joy_ff_start_effect(pDock, "Dock");
435  }
436 }
437 
439 {
440  if (pDock) {
441  pDock->Stop();
442  if (joy_ff_handle_error(SWFF_SetGain(pDock, 5000), "Dock (Reload)") == DIERR_INPUTLOST) {
444  joy_ff_handle_error(SWFF_SetGain(pDock, 5000), "Dock (Reload)");
445  }
446 
447  joy_ff_start_effect(pDock, "Dock (Reload)");
448  }
449 }
450 
452 
454 {
455  if (pAfterburn1) {
456  pAfterburn1->Stop();
457  joy_ff_change_effect(&Struct_afterburn1, pAfterburn1, 5000, INFINITE, DIEP_DURATION | DIEP_GAIN);
458  joy_ff_start_effect(pAfterburn1, "Afterburn1");
459  }
460 
461  if (pAfterburn2) {
462  pAfterburn2->Stop();
463  joy_ff_change_effect(&Struct_afterburn2, pAfterburn2, 5000, INFINITE, DIEP_DURATION | DIEP_GAIN);
464  joy_ff_start_effect(pAfterburn2, "Afterburn2");
465  }
466 
467  nprintf(("Joystick", "FF: Afterburn started\n"));
469 }
470 
472 {
473  if (!Joy_ff_afterburning)
474  return;
475 
476  if (pAfterburn1) {
477  pAfterburn1->Stop();
478  }
479 
480  if (pAfterburn2) {
481  pAfterburn2->Stop();
482  }
483 
485  nprintf(("Joystick", "FF: Afterburn stopped\n"));
486 }
487 
489 {
490  if (pDeathroll1) {
491  pDeathroll1->Stop();
492  joy_ff_start_effect(pDeathroll1, "Deathroll1");
493  }
494 
495  if (pDeathroll2) {
496  pDeathroll2->Stop();
497  joy_ff_start_effect(pDeathroll2, "Deathroll2");
498  }
499 }
500 
502 {
503  if (pDeathroll1)
504  pDeathroll1->Stop();
505 
506  if (pDeathroll2)
507  pDeathroll2->Stop();
508 
509  if (pExplode) {
510  pExplode->Stop();
511  joy_ff_start_effect(pExplode, "Explode");
512  }
513 }
514 
515 void joy_ff_fly_by(int mag)
516 {
517  int gain;
518 
520  return;
521 
522  gain = mag * 120 + 4000;
523  if (gain > 10000)
524  gain = 10000;
525 
526  if (pAfterburn1) {
527  pAfterburn1->Stop();
528  joy_ff_change_effect(&Struct_afterburn1, pAfterburn1, gain, 6000 * mag + 400000, DIEP_DURATION | DIEP_GAIN);
529  joy_ff_start_effect(pAfterburn1, "Afterburn1 (Fly by)");
530  }
531 
532  if (pAfterburn2) {
533  pAfterburn2->Stop();
534  joy_ff_change_effect(&Struct_afterburn2, pAfterburn2, gain, 6000 * mag + 400000, DIEP_DURATION | DIEP_GAIN);
535  joy_ff_start_effect(pAfterburn2, "Afterburn2 (Fly by)");
536  }
537 }
538 
540 {
541  if (!Joy_ff_enabled)
542  return;
543 
544  nprintf(("Joystick", "FF: Reacquiring\n"));
545  pDiDevice->Acquire();
546  joy_ff_start_effect(pSpring, "Spring");
547 }
548 
550 {
551 }
552 
553 void joy_ff_play_dir_effect(float x, float y)
554 {
555  int idegs, imag;
556  float degs;
557 
558  if (!Joy_ff_enabled)
559  return;
560 
561  if (!pHitEffect1 || !pHitEffect2)
562  return;
563 
565  nprintf(("Joystick", "FF: HitEffect already playing. Skipping\n"));
566  return;
567  }
568 
570  if (x > 8000.0f)
571  x = 8000.0f;
572  else if (x < -8000.0f)
573  x = -8000.0f;
574 
575  if (y > 8000.0f)
576  y = 8000.0f;
577  else if (y < -8000.0f)
578  y = -8000.0f;
579 
580  imag = (int) fl_sqrt(x * x + y * y);
581  if (imag > 10000)
582  imag = 10000;
583 
584  degs = (float)atan2(x, y);
585  idegs = (int) (degs * 18000.0f / PI) + 90;
586  while (idegs < 0)
587  idegs += 36000;
588 
589  while (idegs >= 36000)
590  idegs -= 36000;
591 
592  if (joy_ff_handle_error(SWFF_SetDirectionGain(pHitEffect1, idegs, imag), "HitEffect1") == DIERR_INPUTLOST) {
594  joy_ff_handle_error(SWFF_SetDirectionGain(pHitEffect1, idegs, imag), "HitEffect1");
595  }
596 
597  idegs += 9000;
598  if (idegs >= 36000)
599  idegs -= 36000;
600 
601  if (joy_ff_handle_error(SWFF_SetDirectionGain(pHitEffect2, idegs, imag), "HitEffect2") == DIERR_INPUTLOST) {
603  joy_ff_handle_error(SWFF_SetDirectionGain(pHitEffect2, idegs, imag), "HitEffect2");
604  }
605  }
606 
607  joy_ff_start_effect(pHitEffect1, "HitEffect1");
608  joy_ff_start_effect(pHitEffect2, "HitEffect2");
609  //nprintf(("Joystick", "FF: Dir: %d, Mag = %d\n", idegs, imag));
610 }
611 
612 void joy_ff_play_vector_effect(vec3d *v, float scaler)
613 {
614  vec3d vf;
615  float x, y;
616 
617  nprintf(("Joystick", "FF: vec = { %f, %f, %f } s = %f\n", v->xyz.x, v->xyz.y, v->xyz.z, scaler));
618  vm_vec_copy_scale(&vf, v, scaler);
619  x = vf.xyz.x;
620  vf.xyz.x = 0.0f;
621 
622  if (vf.xyz.y + vf.xyz.z < 0)
623  y = -vm_vec_mag(&vf);
624  else
625  y = vm_vec_mag(&vf);
626 
627  joy_ff_play_dir_effect(-x, -y);
628 }
629 
630 static int secondary_ff_level = 0;
631 
633 {
634  if (!Joy_ff_enabled)
635  return;
636 
637  if (!pSecShootEffect)
638  return;
639 
640  gain = gain * 100 + 2500;
641  if (gain > 10000)
642  gain = 10000;
643 
644  if (gain != secondary_ff_level) {
645  if (joy_ff_handle_error(SWFF_SetGain(pSecShootEffect, gain), "SecShootEffect") == DIERR_INPUTLOST) {
647  joy_ff_handle_error(SWFF_SetGain(pSecShootEffect, gain), "SecShootEffect");
648  }
649 
650  if (joy_ff_handle_error(SWFF_SetDuration(pSecShootEffect, 150000 + gain * 25), "SecShootEffect") == DIERR_INPUTLOST) {
652  joy_ff_handle_error(SWFF_SetDuration(pSecShootEffect, 150000 + gain * 25), "SecShootEffect");
653  }
654 
655  secondary_ff_level = gain;
656  nprintf(("Joystick", "FF: Secondary force = %d\n", gain));
657  }
658 
659  pSecShootEffect->Stop();
660  joy_ff_start_effect(pSecShootEffect, "SecShootEffect");
661 }
662 
663 static int primary_ff_level = 0;
664 
666 {
667  if (!Joy_ff_enabled)
668  return;
669 
670  if (!pShootEffect)
671  return;
672 
673  if (gain > 10000)
674  gain = 10000;
675 
676  if (gain != primary_ff_level) {
677  if (joy_ff_handle_error(SWFF_SetGain(pShootEffect, gain), "ShootEffect") == DIERR_INPUTLOST) {
679  joy_ff_handle_error(SWFF_SetGain(pShootEffect, gain), "ShootEffect");
680  }
681 
682  primary_ff_level = gain;
683  }
684 
685  pShootEffect->Stop();
686  joy_ff_start_effect(pShootEffect, "ShootEffect");
687 }
688 
689 void init_periodic_effect_struct(di_periodic_effect_struct *effect, int type, int dur, int per, int ang, int mag, int att, int fade)
690 {
691  // type-specific stuff
692  DWORD dwPhase = 0;
693  GUID guid = GUID_Square;
694 
695  switch (type) {
696  case SINE:
697  guid = GUID_Sine;
698  break;
699  case COSINE:
700  guid = GUID_Sine;
701  dwPhase = 9000;
702  break;
703  case SQUARE_HIGH:
704  guid = GUID_Square;
705  break;
706  case SQUARE_LOW:
707  guid = GUID_Square;
708  dwPhase = 18000;
709  break;
710  case TRIANGLE_UP:
711  guid = GUID_Triangle;
712  break;
713  case TRIANGLE_DOWN:
714  guid = GUID_Triangle;
715  dwPhase = 18000;
716  break;
717  case SAWTOOTH_UP:
718  guid = GUID_SawtoothUp;
719  break;
720  case SAWTOOTH_DOWN:
721  guid = GUID_SawtoothDown;
722  break;
723  default:
724  Int3(); // illegal
725  break;
726  }
727 
728  effect->guid = guid;
729  effect->periodic_struct.dwMagnitude = mag;
730  effect->periodic_struct.lOffset = 0;
731  effect->periodic_struct.dwPhase = dwPhase;
732  effect->periodic_struct.dwPeriod = per;
733 
734  effect->envelope_struct.dwSize = sizeof(DIENVELOPE);
735  effect->envelope_struct.dwAttackTime = att;
736  effect->envelope_struct.dwAttackLevel = 0;
737  effect->envelope_struct.dwFadeTime = fade;
738  effect->envelope_struct.dwFadeLevel = 0;
739 
740  effect->axes[0] = DIJOFS_X;
741  effect->axes[1] = DIJOFS_Y;
742 
743  effect->direction[0] = ang;
744  effect->direction[1] = 0;
745 
746  effect->effect.dwSize = sizeof(DIEFFECT);
748  effect->effect.dwDuration = dur;
749  effect->effect.dwSamplePeriod = HZ_TO_uS(100);
750  effect->effect.dwGain = 10000;
752  effect->effect.dwTriggerRepeatInterval = 0;
753  effect->effect.cAxes = 2;
754  effect->effect.rgdwAxes = effect->axes;
755  effect->effect.rglDirection = effect->direction;
756  effect->effect.lpEnvelope = &effect->envelope_struct;
757  effect->effect.cbTypeSpecificParams = sizeof(effect->periodic_struct);
758  effect->effect.lpvTypeSpecificParams = &effect->periodic_struct;
759 }
int joy_ff_handling_scaler
Definition: joy_ff.cpp:29
di_periodic_effect_struct Struct_deathroll2
Definition: joy_ff.cpp:52
int Joy_ff_directional_hit_effect_enabled
Definition: joy_ff.cpp:31
void joy_ff_adjust_handling(int speed)
Definition: joy_ff.cpp:350
void * HWND
Definition: config.h:104
#define DIERR_INPUTLOST
Definition: vdinput.h:1649
void joy_ff_play_reload_effect()
Definition: joy_ff.cpp:438
uint os_config_read_uint(const char *section, const char *name, uint default_value)
Definition: osregistry.cpp:372
HRESULT SWFF_DestroyAllEffects(IN LPDIRECTINPUTDEVICE2 pDIDevice)
Definition: swff_lib.cpp:357
float vm_vec_mag(const vec3d *v)
Definition: vecmat.cpp:325
HRESULT SWFF_OpenDefaultFFJoystick(IN HWND hWnd, OUT LPDIRECTINPUT *ppDI, OUT LPDIRECTINPUTDEVICE2 *ppDIDevice2)
HRESULT SWFF_SetGain(IN LPDIRECTINPUTEFFECT pDIEffect, IN DWORD dwGain)
Definition: swff_lib.cpp:389
#define DIEP_DIRECTION
Definition: vdinput.h:222
HRESULT joy_ff_handle_error(HRESULT hr, char *eff_name=NULL)
Definition: joy_ff.cpp:111
DWORD cbTypeSpecificParams
Definition: vdinput.h:205
int Joy_ff_enabled
Definition: joy_ff.cpp:30
Definition: pstypes.h:88
void SWFF_ErrorCodeToString(IN HRESULT hResult, OUT TCHAR *pszCodeString)
void joy_ff_play_dir_effect(float x, float y)
Definition: joy_ff.cpp:553
LPDIRECTINPUTEFFECT pHitEffect2
Definition: joy_ff.cpp:40
DWORD dwAttackLevel
Definition: vdinput.h:186
HRESULT SWFF_CreateConstantForceEffect(IN LPDIRECTINPUTDEVICE2 pDIDevice, IN OUT LPDIRECTINPUTEFFECT *ppDIEffect, IN DWORD dwDuration, IN DWORD dwDirection, IN LONG lMagnitude, IN DWORD dwAttackTime, IN DWORD dwAttackLevel, IN DWORD dwFadeTime, IN DWORD dwFadeLevel, IN LONG lButton)
Definition: swff_lib.cpp:2147
struct vec3d::@225::@227 xyz
GLclampf f
Definition: Glext.h:7097
DWORD dwAttackTime
Definition: vdinput.h:187
LPDIRECTINPUTEFFECT pDeathroll1
Definition: joy_ff.cpp:47
LPDIRECTINPUTDEVICE2 pDiDevice
Definition: joy_ff.cpp:34
LPDIRECTINPUTEFFECT pDock
Definition: joy_ff.cpp:46
LPDIRECTINPUTEFFECT pSpring
Definition: joy_ff.cpp:45
#define SAWTOOTH_UP
Definition: sw_force.h:62
int joy_ff_init()
Definition: joy_ff.cpp:63
#define DIEP_GAIN
Definition: vdinput.h:218
LPDIRECTINPUTEFFECT pExplode
Definition: joy_ff.cpp:49
#define TRIANGLE_DOWN
Definition: sw_force.h:61
#define Int3()
Definition: pstypes.h:292
LPDIRECTINPUTEFFECT pDeathroll2
Definition: joy_ff.cpp:48
void joy_ff_change_effect(di_periodic_effect_struct *s, LPDIRECTINPUTEFFECT eff, int gain=-1, int dur=0, int flags=-1)
Definition: joy_ff.cpp:379
HRESULT SWFF_CreatePeriodicEffect(IN LPDIRECTINPUTDEVICE2 pDIDevice, IN OUT LPDIRECTINPUTEFFECT *ppDIEffect, IN DWORD dwType, IN DWORD dwDuration, IN DWORD dwPeriod, IN DWORD dwDirection, IN DWORD dwMagnitude, IN LONG lOffset, IN DWORD dwAttackTime, IN DWORD dwAttackLevel, IN DWORD dwFadeTime, IN DWORD dwFadeLevel, IN LONG lButton)
Definition: swff_lib.cpp:1533
#define SINE
Definition: sw_force.h:56
void joy_ff_afterburn_off()
Definition: joy_ff.cpp:471
DWORD dwDuration
Definition: vdinput.h:196
GLenum type
Definition: Gl.h:1492
struct IDirectInputDevice2 * LPDIRECTINPUTDEVICE2
Definition: vdinput.h:960
#define DIEP_SAMPLEPERIOD
Definition: vdinput.h:217
void joy_reacquire_ff()
Definition: joy_ff.cpp:539
void joy_ff_fly_by(int mag)
Definition: joy_ff.cpp:515
uint os_get_window()
Definition: osapi.cpp:208
LONG lPositiveCoefficient
Definition: vdinput.h:168
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
#define HZ_TO_uS(HZ)
Definition: sw_force.h:72
int joy_ff_effect_playing(LPDIRECTINPUTEFFECT eff)
Definition: joy_ff.cpp:417
DWORD dwPeriod
Definition: vdinput.h:162
#define DIJOFS_X
Definition: vdinput.h:1260
LPDIRECTINPUTEFFECT pAfterburn2
Definition: joy_ff.cpp:42
LPLONG rglDirection
Definition: vdinput.h:203
#define DIJOFS_Y
Definition: vdinput.h:1261
#define nprintf(args)
Definition: pstypes.h:239
#define DIEP_ENVELOPE
Definition: vdinput.h:223
DWORD dwFadeLevel
Definition: vdinput.h:188
#define DIEP_DURATION
Definition: vdinput.h:216
DWORD dwFlags
Definition: vdinput.h:195
DWORD dwSamplePeriod
Definition: vdinput.h:197
DICONDITION DIConditionStruct[2]
Definition: sw_force.h:461
#define DIEP_TYPESPECIFICPARAMS
Definition: vdinput.h:224
#define COSINE
Definition: sw_force.h:57
HRESULT SWFF_SetDuration(IN LPDIRECTINPUTEFFECT pDIEffect, IN DWORD dwDuration)
Definition: swff_lib.cpp:461
DIPERIODIC periodic_struct
Definition: joy_ff.cpp:22
DWORD dwPhase
Definition: vdinput.h:161
int joy_ff_create_std_periodic(LPDIRECTINPUTEFFECT *eff, int type, int dur, int per, int ang=0, int mag=10000, int att=0, int fade=0)
Definition: joy_ff.cpp:126
LPVOID lpvTypeSpecificParams
Definition: vdinput.h:206
struct IDirectInput * LPDIRECTINPUT
Definition: vdinput.h:1381
struct IDirectInputEffect * LPDIRECTINPUTEFFECT
Definition: vdinput.h:271
GLdouble s
Definition: Glext.h:5321
void init_periodic_effect_struct(di_periodic_effect_struct *effect, int type, int dur, int per, int ang=0, int mag=10000, int att=0, int fade=0)
Definition: joy_ff.cpp:689
unsigned long DWORD
Definition: config.h:90
DWORD dwSize
Definition: vdinput.h:194
HRESULT SWFF_SetDirectionGain(IN LPDIRECTINPUTEFFECT pDIEffect, IN DWORD dwAngle, IN DWORD dwMag)
Definition: swff_lib.cpp:430
#define DIEGES_PLAYING
Definition: vdinput.h:234
void joy_ff_start_effect(LPDIRECTINPUTEFFECT eff, char *name)
Definition: joy_ff.cpp:135
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
struct DIEFFECT DIEFFECT
DWORD dwFadeTime
Definition: vdinput.h:189
long HRESULT
Definition: vddraw.h:115
LPDIRECTINPUTEFFECT pHitEffect1
Definition: joy_ff.cpp:39
HRESULT SWFF_CreateConditionEffectStruct(di_condition_effect_struct *ptr, IN LPDIRECTINPUTDEVICE2 pDIDevice, IN OUT LPDIRECTINPUTEFFECT *ppDIEffect, IN DWORD dwType, IN DWORD dwDuration, IN LONG lXCoefficient, IN LONG lXOffset, IN LONG lYCoefficient, IN LONG lYOffset, IN LONG lButton)
Definition: swff_lib.cpp:1812
DWORD cAxes
Definition: vdinput.h:201
di_condition_effect_struct Spring_cond_effect
Definition: joy_ff.cpp:58
di_periodic_effect_struct Struct_afterburn1
Definition: joy_ff.cpp:54
long LONG
Definition: config.h:95
int joy_ff_create_effects()
Definition: joy_ff.cpp:147
void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s)
Definition: vecmat.cpp:257
di_periodic_effect_struct Struct_afterburn2
Definition: joy_ff.cpp:55
void joy_ff_play_vector_effect(vec3d *v, float scaler)
Definition: joy_ff.cpp:612
GLbitfield flags
Definition: Glext.h:6722
LONG lNegativeCoefficient
Definition: vdinput.h:169
DWORD dwSize
Definition: vdinput.h:185
GLuint const GLchar * name
Definition: Glext.h:5608
LPDWORD rgdwAxes
Definition: vdinput.h:202
void joy_ff_docked()
Definition: joy_ff.cpp:425
void joy_ff_shutdown()
Definition: joy_ff.cpp:99
void joy_ff_play_secondary_shoot(int gain)
Definition: joy_ff.cpp:632
LONG lOffset
Definition: vdinput.h:160
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
di_periodic_effect_struct Struct_explode
Definition: joy_ff.cpp:53
LPDIRECTINPUTEFFECT pSecShootEffect
Definition: joy_ff.cpp:44
#define DIEFF_POLAR
Definition: vdinput.h:213
void joy_ff_afterburn_on()
Definition: joy_ff.cpp:453
struct DIENVELOPE DIENVELOPE
DWORD dwGain
Definition: vdinput.h:198
#define fl_sqrt(fl)
Definition: floating.h:29
int Joy_ff_afterburning
Definition: joy_ff.cpp:451
LPDIRECTINPUT pDi
Definition: joy_ff.cpp:33
DWORD dwTriggerRepeatInterval
Definition: vdinput.h:200
LPDIRECTINPUTEFFECT pShootEffect
Definition: joy_ff.cpp:43
LPDIENVELOPE lpEnvelope
Definition: vdinput.h:204
#define PI
Definition: pstypes.h:303
di_periodic_effect_struct Struct_deathroll1
Definition: joy_ff.cpp:51
#define SAWTOOTH_DOWN
Definition: sw_force.h:63
void joy_ff_mission_init(vec3d v)
Definition: joy_ff.cpp:342
di_periodic_effect_struct Struct_dock
Definition: joy_ff.cpp:56
void joy_ff_stop_effects()
Definition: joy_ff.cpp:331
void joy_unacquire_ff()
Definition: joy_ff.cpp:549
DWORD dwTriggerButton
Definition: vdinput.h:199
void joy_ff_explode()
Definition: joy_ff.cpp:501
DIENVELOPE envelope_struct
Definition: joy_ff.cpp:23
LPDIRECTINPUTEFFECT pAfterburn1
Definition: joy_ff.cpp:41
#define DIEB_NOTRIGGER
Definition: vdinput.h:229
#define SQUARE_LOW
Definition: sw_force.h:59
void joy_ff_deathroll()
Definition: joy_ff.cpp:488
const GLdouble * v
Definition: Glext.h:5322
#define DIEFF_OBJECTOFFSETS
Definition: vdinput.h:211
DWORD dwMagnitude
Definition: vdinput.h:159
#define SQUARE_HIGH
Definition: sw_force.h:58
GLint y
Definition: Gl.h:1505
void joy_ff_play_primary_shoot(int gain)
Definition: joy_ff.cpp:665
#define SPRING
Definition: sw_force.h:66
#define TRIANGLE_UP
Definition: sw_force.h:60