Open main menu

CDOT Wiki β

Changes

User:Satijas

96 bytes added, 13:43, 7 April 2011
no edit summary
== Force Feedback ==
Add this to '''WindowSettings.h''':
<big>
</big>
Add this in typedef enum Integerin '''Configuration.h''':
<big>
GF_CT_RMBL
</big>
In '''iInput.h''', add line 1 in the iJoystick classIn '''Input.h''', add line 2 in the Joystick classIn '''Input.h''', add line 3 in the Joystick class
<big>
1.
</big>
In '''Input.cpp''', add the following to the Joystick constructor
<big>
ffEffects = NULL;
DIPERIODIC dip;
DIENVELOPE die;
// if both x & y have FF, make shake come at 45 degree angle
// otherwise just shake the x axis.
dif.lpvTypeSpecificParams = &dip;
dif.dwStartDelay = 3 * DI_SECONDS; // 3 secs
dip.dwMagnitude = 3 * DI_FFNOMINALMAX / 10;
dip.lOffset = 0;
dip.dwPhase = 0;
dip.dwPeriod = DI_SECONDS / 10; // 1/10th second
die.dwSize = sizeof die;
die.dwAttackLevel = factor;
die.dwFadeTime = DI_SECONDS / 2;
HRESULT hr = joystick->CreateEffect(GUID_Square, &dif, &ffEffects, NULL);
// create a ramp force
DIRAMPFORCE dirf;
dif.lpvTypeSpecificParams = &dirf;
dif.dwStartDelay = 0.01 * DI_SECONDS;
dirf.lStart = DI_FFNOMINALMAX / 2;
dirf.lEnd = - DI_FFNOMINALMAX / 2;
die.dwSize = sizeof die;
die.dwAttackLevel = DI_FFNOMINALMAX / 50;
die.dwFadeLevel = DI_FFNOMINALMAX / 10;
die.dwFadeTime = time * DI_SECONDS / 2;
if (SUCCEEDED(joystick->CreateEffect(GUID_RampForce, &dif,
&ffEffects, NULL))){
</big>
In '''UserDialog.cpp''':
In the saveUserChoices function, add another bool called ff:
<big>
bool y, z, <b>'''ff</b>''', none;
</big>
Change the flags being set after:
<big>
flags = ((y ? 1 : 0) << 2) | ((z ? 1 : 0) << 1) <b>'''| ((ff ? 0 : 1) << 3)</b> ''' | (none ? 1 : 0);
</big>
in '''iDesign.h''', add these to the iDesign class:
<big>
virtual bool sendForce(bool) = 0;
</big>
in '''Design.h''', add these to the Design class:
<big>
private:
</big>
In '''Design.cpp ''' constructor, add these default values:
<big>
fTime = 0.1;
</big>
Add these functions in '''Design.cpp'''
<big>
bool Design::sendForce(bool force)
</big>
In '''Engine.cpp''', add this to run:
<big>
joystick->updateForce(design->getForceFactor(), design->getForceTime(), design->getForceDir());
1
edit