Difference between revisions of "User:Satijas"

From CDOT Wiki
Jump to: navigation, search
Line 8: Line 8:
 
== Force Feedback ==
 
== Force Feedback ==
  
 +
Add this to Configuration.h:
 +
<big>
 +
#define IDC_NOFF //number
 +
</big>
  
 +
In iInput.h, add line 1 in the iJoystick class
 +
In Input.h, add line 2 in the Joystick class
 +
In Input.h, add line 3 in the Joystick class
 +
<big>
 +
1.
 +
public:
 +
    virtual void updateForce(float, double, int) = 0;
 +
2.
 +
  int feedBackOFF;
 +
  LPDIRECTINPUTEFFECT centre;
 +
  LPDIRECTINPUTEFFECT ffEffects;
 +
 +
3.
 +
  public:
 +
      void updateForce(float factor, double time, int direction);
 +
 +
</big>
 +
 +
In Input.cpp, add the following to the Joystick constructor
 +
 +
<big>
 +
  ffEffects = NULL;
 +
  centre = NULL;
 +
  feedBackOFF = 0;
 +
</big>
 +
 +
add this in Joystick::interrogate function:
 +
<big>
 +
  DIDEVCAPS didcaps;
 +
      didcaps.dwSize = sizeof didcaps;
 +
      if(SUCCEEDED(didInter->GetCapabilities(&didcaps)) &&
 +
        (didcaps.dwFlags && DIDC_FOREFEEDBACK){
 +
        EnableWindow(GetDlgItem((HWND)hwnd, IDC_NOFF), TRUE); 
 +
        }
 +
      else{
 +
        EnableWindow(GetDlgItem((HWND)hwnd, IDC_NOFF), FALSE);
 +
      }
 +
</big>
 +
 +
add this in Joystick::setup function:
 +
<big>
 +
  feedBackOFF = !!(flags & 8);
 +
</big>
 +
 +
change the SetCooperativeLevel in setup to check for device exclusivity
 +
<big>
 +
    else if (FAILED(joystick->SetCooperativeLevel((HWND)hwnd,
 +
  (feedBackOFF ? DISCL_NONEXCLUSIVE : DISCL_EXCLUSIVE) | DISCL_FOREGROUND)))
 +
</big>
 +
 +
add this line after (!zAxisOn)
 +
<big>
 +
if(feedBackOFF)
 +
    centre = NULL;
 +
</big>
  
 
[[Category:force feedback]]
 
[[Category:force feedback]]

Revision as of 13:09, 7 April 2011

About Me

Hi, my name is Sasha. I'm in GAM670

Force Feedback

Add this to Configuration.h:

#define IDC_NOFF //number

In iInput.h, add line 1 in the iJoystick class In Input.h, add line 2 in the Joystick class In Input.h, add line 3 in the Joystick class

1.
public:
   virtual void updateForce(float, double, int) = 0;
2.
  int feedBackOFF;
  LPDIRECTINPUTEFFECT centre;
  LPDIRECTINPUTEFFECT ffEffects;
3.
  public:
     void updateForce(float factor, double time, int direction);

In Input.cpp, add the following to the Joystick constructor

 ffEffects = NULL;
 centre = NULL;
 feedBackOFF = 0;

add this in Joystick::interrogate function:

 DIDEVCAPS didcaps;
     didcaps.dwSize = sizeof didcaps;
     if(SUCCEEDED(didInter->GetCapabilities(&didcaps)) &&
       (didcaps.dwFlags && DIDC_FOREFEEDBACK){
        EnableWindow(GetDlgItem((HWND)hwnd, IDC_NOFF), TRUE);   
        }
     else{
        EnableWindow(GetDlgItem((HWND)hwnd, IDC_NOFF), FALSE);
     }

add this in Joystick::setup function:

 feedBackOFF = !!(flags & 8);

change the SetCooperativeLevel in setup to check for device exclusivity

   else if (FAILED(joystick->SetCooperativeLevel((HWND)hwnd,
 (feedBackOFF ? DISCL_NONEXCLUSIVE : DISCL_EXCLUSIVE) | DISCL_FOREGROUND)))

add this line after (!zAxisOn)

if(feedBackOFF)
   centre = NULL;