当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTINPUTDEVICE8::CreateEffect方法代码示例

本文整理汇总了C++中LPDIRECTINPUTDEVICE8::CreateEffect方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTINPUTDEVICE8::CreateEffect方法的具体用法?C++ LPDIRECTINPUTDEVICE8::CreateEffect怎么用?C++ LPDIRECTINPUTDEVICE8::CreateEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTINPUTDEVICE8的用法示例。


在下文中一共展示了LPDIRECTINPUTDEVICE8::CreateEffect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EnumAndCreateEffectsCallback

//-----------------------------------------------------------------------------
// Name: EnumAndCreateEffectsCallback()
// Desc: Create the effects as they are enumerated and add them to the 
//       linked list, g_EffectsList
//-----------------------------------------------------------------------------
BOOL CALLBACK EnumAndCreateEffectsCallback( LPCDIFILEEFFECT pDIFileEffect, VOID* pvRef )
{   
    HRESULT hr;
    LPDIRECTINPUTEFFECT pDIEffect = NULL;

    // Create the file effect
    if( FAILED( hr = g_pFFDevice->CreateEffect( pDIFileEffect->GuidEffect, 
                                                pDIFileEffect->lpDiEffect, 
                                                &pDIEffect, NULL ) ) )
    {
        OutputDebugString( TEXT("Could not create force feedback effect on this device.\n") );
        return DIENUM_CONTINUE;
    }

    // Create a new effect node
    EFFECTS_NODE* pEffectNode = new EFFECTS_NODE;
    if( NULL == pEffectNode )
        return DIENUM_STOP;

    // Fill the pEffectNode up
    ZeroMemory( pEffectNode, sizeof( EFFECTS_NODE ) );
    pEffectNode->pDIEffect         = pDIEffect;
    pEffectNode->dwPlayRepeatCount = 1;

    // Add pEffectNode to the circular linked list, g_EffectsList
    pEffectNode->pNext  = g_EffectsList.pNext;
    g_EffectsList.pNext = pEffectNode;

    return DIENUM_CONTINUE;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:35,代码来源:readffe.cpp

示例2: Visit

	void Visit( CConstantForceFeedbackEffectDesc& desc )
	{
		DICONSTANTFORCE cf = { 0 };
		cf.lMagnitude = (LONG)desc.magnitude;// 5000; // [-10000,10000]
		m_pDIEffect->cbTypeSpecificParams  = sizeof( DICONSTANTFORCE );
		m_pDIEffect->lpvTypeSpecificParams = &cf;
		m_hr = m_pInputDevice->CreateEffect( GUID_ConstantForce, m_pDIEffect, &m_pCreatedEffect, NULL );
	}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:8,代码来源:DIForceFeedbackEffectImpl.cpp

示例3: InitForceFeedback

    HRESULT InitForceFeedback()
    {

        HRESULT hr;
        DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y };
        LONG rglDirection[2] = { 0, 0 };

        if (FAILED(hr = g_pJoystick->SetCooperativeLevel(GetActiveWindow(), DISCL_EXCLUSIVE | DISCL_BACKGROUND)))
            return hr;

        if (FAILED(hr = g_pJoystick->Acquire()))
            return hr;

        // Autocenter
        ZeroMemory(&g_sAutoCenterConfig, sizeof(g_sAutoCenterConfig));

        g_sAutoCenterConfig.dwStartDelay = 0;

        g_sAutoCenterConfig.dwSize = sizeof(DIEFFECT);
        g_sAutoCenterConfig.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
        g_sAutoCenterConfig.dwDuration = INFINITE;
        g_sAutoCenterConfig.dwSamplePeriod = 0;
        g_sAutoCenterConfig.dwGain = DI_FFNOMINALMAX;
        g_sAutoCenterConfig.dwTriggerButton = DIEB_NOTRIGGER;
        g_sAutoCenterConfig.dwTriggerRepeatInterval = 0;
        g_sAutoCenterConfig.cAxes = 1;
        g_sAutoCenterConfig.rgdwAxes = rgdwAxes;
        g_sAutoCenterConfig.rglDirection = rglDirection;

        g_sAutoCenterConfig.lpEnvelope = 0;
        g_sAutoCenterConfig.dwStartDelay = 0;

        DICONSTANTFORCE cf = { 0 };

        g_sAutoCenterConfig.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
        g_sAutoCenterConfig.lpvTypeSpecificParams = &cf;

        if (FAILED(hr = g_pJoystick->CreateEffect(GUID_ConstantForce, &g_sAutoCenterConfig, &g_pAutoCenterHandle, nullptr)))
            return hr;

        if (FAILED(hr = g_pAutoCenterHandle->Start(INFINITE, 0)))
            return hr;

        // Rumble
        ZeroMemory(&g_sWheelRumbleConfig, sizeof(g_sWheelRumbleConfig));

        g_sWheelRumbleConfig.dwStartDelay = 0;

        g_sWheelRumbleConfig.dwSize = sizeof(DIEFFECT);
        g_sWheelRumbleConfig.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
        g_sWheelRumbleConfig.dwDuration = INFINITE;
        g_sWheelRumbleConfig.dwSamplePeriod = 0;
        g_sWheelRumbleConfig.dwGain = DI_FFNOMINALMAX;
        g_sWheelRumbleConfig.dwTriggerButton = DIEB_NOTRIGGER;
        g_sWheelRumbleConfig.dwTriggerRepeatInterval = 0;
        g_sWheelRumbleConfig.cAxes = 1;
        g_sWheelRumbleConfig.rgdwAxes = rgdwAxes;
        g_sWheelRumbleConfig.rglDirection = rglDirection;

        g_sWheelRumbleConfig.lpEnvelope = 0;
        g_sWheelRumbleConfig.dwStartDelay = 0;

        DIPERIODIC pf = { 0,0,0,0.08 };

        g_sWheelRumbleConfig.cbTypeSpecificParams = sizeof(DIPERIODIC);
        g_sWheelRumbleConfig.lpvTypeSpecificParams = &pf;

        if (FAILED(hr = g_pJoystick->CreateEffect(GUID_Sine, &g_sWheelRumbleConfig, &g_pWheelRumbleHandle, nullptr)))
            return hr;

        if (FAILED(hr = g_pWheelRumbleHandle->Start(INFINITE, 0)))
            return hr;

        return S_OK;
    }
开发者ID:Jinwei1,项目名称:AirSim,代码行数:75,代码来源:DirectInputJoyStick.cpp

示例4: InitForceFeedback

bool ForceFeedbackDevice::InitForceFeedback(const LPDIRECTINPUTDEVICE8 device, int axis_count)
{
  if (axis_count == 0)
    return false;

  // We just use the X axis (for wheel left/right).
  // Gamepads seem to not care which axis you use.
  // These are temporary for creating the effect:
  std::array<DWORD, 1> rgdwAxes = {DIJOFS_X};
  std::array<LONG, 1> rglDirection = {-200};

  DIEFFECT eff{};
  eff.dwSize = sizeof(eff);
  eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
  eff.dwDuration = DI_SECONDS / 1000 * RUMBLE_LENGTH_MS;
  eff.dwSamplePeriod = 0;
  eff.dwGain = DI_FFNOMINALMAX;
  eff.dwTriggerButton = DIEB_NOTRIGGER;
  eff.dwTriggerRepeatInterval = 0;
  eff.cAxes = DWORD(rgdwAxes.size());
  eff.rgdwAxes = rgdwAxes.data();
  eff.rglDirection = rglDirection.data();
  eff.dwStartDelay = 0;

  // Initialize parameters with zero force (their current state).
  DICONSTANTFORCE diCF{};
  diCF.lMagnitude = 0;
  DIRAMPFORCE diRF{};
  diRF.lStart = diRF.lEnd = 0;
  DIPERIODIC diPE{};
  diPE.dwMagnitude = 0;
  diPE.lOffset = 0;
  diPE.dwPhase = 0;
  diPE.dwPeriod = DI_SECONDS / 1000 * RUMBLE_PERIOD_MS;

  for (auto& f : force_type_names)
  {
    if (f.guid == GUID_ConstantForce)
    {
      eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
      eff.lpvTypeSpecificParams = &diCF;
    }
    else if (f.guid == GUID_RampForce)
    {
      eff.cbTypeSpecificParams = sizeof(DIRAMPFORCE);
      eff.lpvTypeSpecificParams = &diRF;
    }
    else
    {
      // All other forces need periodic parameters:
      eff.cbTypeSpecificParams = sizeof(DIPERIODIC);
      eff.lpvTypeSpecificParams = &diPE;
    }

    LPDIRECTINPUTEFFECT pEffect;
    if (SUCCEEDED(device->CreateEffect(f.guid, &eff, &pEffect, nullptr)))
    {
      if (f.guid == GUID_ConstantForce)
        AddOutput(new ForceConstant(this, f.name, pEffect, diCF));
      else if (f.guid == GUID_RampForce)
        AddOutput(new ForceRamp(this, f.name, pEffect, diRF));
      else
        AddOutput(new ForcePeriodic(this, f.name, pEffect, diPE));
    }
  }

  // Disable autocentering:
  if (Outputs().size())
  {
    DIPROPDWORD dipdw;
    dipdw.diph.dwSize = sizeof(DIPROPDWORD);
    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
    dipdw.diph.dwObj = 0;
    dipdw.diph.dwHow = DIPH_DEVICE;
    dipdw.dwData = DIPROPAUTOCENTER_OFF;
    device->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph);

    m_run_thread.Set();
    m_update_thread = std::thread(&ForceFeedbackDevice::ThreadFunc, this);
  }

  return true;
}
开发者ID:AdmiralCurtiss,项目名称:dolphin,代码行数:83,代码来源:ForceFeedbackDevice.cpp

示例5: Game_Init


//.........这里部分代码省略.........
DIEFFECT   diEffect;        // general parameters

// setup the periodic structure
diPeriodic.dwMagnitude = DI_FFNOMINALMAX; 
diPeriodic.lOffset = 0; 
diPeriodic.dwPhase = 0; 
diPeriodic.dwPeriod = (DWORD) (0.05 * DI_SECONDS); 

// set the modulation envelope 
diEnvelope.dwSize = sizeof(DIENVELOPE);
diEnvelope.dwAttackLevel = 0; 
diEnvelope.dwAttackTime = (DWORD) (0.01 * DI_SECONDS); 
diEnvelope.dwFadeLevel = 0; 
diEnvelope.dwFadeTime = (DWORD) (3.0 * DI_SECONDS); 
 
// set up the effect structure itself
diEffect.dwSize = sizeof(DIEFFECT); 
diEffect.dwFlags = DIEFF_POLAR | DIEFF_OBJECTOFFSETS; 
diEffect.dwDuration = (DWORD) INFINITE; // (1 * DI_SECONDS);
 
// set up details of effect
diEffect.dwSamplePeriod = 0;               // = default 
diEffect.dwGain = DI_FFNOMINALMAX;         // no scaling
diEffect.dwTriggerButton = DIJOFS_BUTTON0; // connect effect to trigger button
diEffect.dwTriggerRepeatInterval = 0;      
diEffect.cAxes = 2; 
diEffect.rgdwAxes = dwAxes; 
diEffect.rglDirection = &lDirection[0]; 
diEffect.lpEnvelope = &diEnvelope; 
diEffect.cbTypeSpecificParams = sizeof(diPeriodic);
diEffect.lpvTypeSpecificParams = &diPeriodic;  
 
// create the effect and get the interface to it 
lpdijoy->CreateEffect(GUID_Square,  // standard GUID 
                     &diEffect,      // where the data is
                     &lpdieffect,    // where to put interface pointer
                     NULL);          // no aggregation


///////////////////////////////////////////////////////////

// load the background
Load_Bitmap_File(&bitmap16bit, "MUSH_24.BMP");

// load in the four frames of the mushroom
for (index=0; index<4; index++)
    {
    // create mushroom bitmaps
    Create_Bitmap(&mushrooms[index],0,0,32,32,16);
    Load_Image_Bitmap16(&mushrooms[index],&bitmap16bit,index,0,BITMAP_EXTRACT_MODE_CELL);  
    } // end for index

// now create the bug blaster bob
Create_BOB(&blaster,0,0,32,32,3,
           BOB_ATTR_VISIBLE | BOB_ATTR_MULTI_ANIM | BOB_ATTR_ANIM_ONE_SHOT,
           DDSCAPS_SYSTEMMEMORY,0,16);

// load in the four frames of the mushroom
for (index=0; index<3; index++)
     Load_Frame_BOB16(&blaster,&bitmap16bit,index,index,1,BITMAP_EXTRACT_MODE_CELL);  

// unload the bitmap file
Unload_Bitmap_File(&bitmap16bit);

// set the animation sequences for bug blaster
Load_Animation_BOB(&blaster,0,5,blaster_anim);
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:67,代码来源:demo9_4_16b.cpp

示例6: CreateEffect

 HRESULT _stdcall CreateEffect(REFGUID a,LPCDIEFFECT b,LPDIRECTINPUTEFFECT *c,LPUNKNOWN d) {
     return RealDevice->CreateEffect(a,b,c,d);
 }
开发者ID:europop,项目名称:morrgraphext,代码行数:3,代码来源:DInput+(mouse+combat).cpp

示例7: CreateEffectHandle

// Create a force feedback effect handle and downloads the effect.  Parameters are self-explanatory.
bool CreateEffectHandle( HWND hWnd, LPDIRECTINPUTDEVICE8 lpDirectInputDevice, LPDIRECTINPUTEFFECT &pDIEffect, BYTE bRumbleTyp, long lStrength )
{
	if( pDIEffect )
		ReleaseEffect( pDIEffect );

	if( !lpDirectInputDevice || bRumbleTyp == RUMBLE_DIRECT )
		return false;	

	DWORD nAxes = 0;
	DWORD rgdwAxes[] = { DIJOFS_X, DIJOFS_Y };

	HRESULT hResult;

	// count the FF - axes of the joystick
	lpDirectInputDevice->EnumObjects( EnumCountFFAxes, &nAxes, DIDFT_FFACTUATOR | DIDFT_AXIS );

	if( nAxes == 0 )
		return false;
	nAxes = min( nAxes, 2 );


	// Must be unaquired for setting stuff like Co-op Level
	hResult = lpDirectInputDevice->Unacquire();
	//FF Requires EXCLUSIVE LEVEL, took me hours to find the reason why it wasnt working
	hResult = lpDirectInputDevice->SetCooperativeLevel( hWnd, DIB_FF );

	// fail if we can't set coop level --rabid
	if (hResult != DI_OK)
	{
		DebugWriteA("CreateEffectHandle: couldn't set coop level: %08X\n", hResult);
		return false;
	}

    // Since we will be playing force feedback effects, we should disable the
    // auto-centering spring.
	DIPROPDWORD dipdw;
    dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
    dipdw.diph.dwObj        = 0;
    dipdw.diph.dwHow        = DIPH_DEVICE;
    dipdw.dwData            = FALSE;
	
	hResult = lpDirectInputDevice->SetProperty( DIPROP_AUTOCENTER, &dipdw.diph );

	long rglDirection[] = { 1, 1 };
	LPGUID EffectGuid;
    DIEFFECT eff;
    ZeroMemory( &eff, sizeof(eff) );

	eff.dwSize                  = sizeof(DIEFFECT);
	eff.dwFlags                 = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
	eff.dwGain                  = lStrength * 100;
    eff.dwTriggerButton         = DIEB_NOTRIGGER;
    eff.dwTriggerRepeatInterval = 0;
    eff.cAxes                   = nAxes; //Number of Axes
    eff.rgdwAxes                = rgdwAxes;
    eff.rglDirection            = rglDirection;
    eff.lpEnvelope              = NULL;
	eff.dwStartDelay            = 0;

	DICONSTANTFORCE cf;
	DIRAMPFORCE rf;
	DIPERIODIC pf;

	switch( bRumbleTyp )
	{
	case RUMBLE_CONSTANT:
		EffectGuid = (GUID*)&GUID_ConstantForce;

		eff.dwDuration              = 150000; // microseconds
		eff.dwSamplePeriod          = 0;
		eff.cbTypeSpecificParams    = sizeof(DICONSTANTFORCE);
		eff.lpvTypeSpecificParams   = &cf;

		cf.lMagnitude = 10000;
		break;
	case RUMBLE_RAMP:
		EffectGuid = (GUID*)&GUID_RampForce;
		
		eff.dwDuration              = 300000; // microseconds
		eff.dwSamplePeriod          = 0;
		eff.cbTypeSpecificParams    = sizeof(DIRAMPFORCE);
		eff.lpvTypeSpecificParams   = &rf;

		rf.lStart = 10000;
		rf.lEnd = 2000;
		break;
	
	case RUMBLE_CONDITION:
	case RUMBLE_PERIODIC:
		EffectGuid = (GUID*)&GUID_Sine;

		eff.dwDuration              = 150000; // microseconds
		eff.dwSamplePeriod          = 0;
		eff.cbTypeSpecificParams    = sizeof(DIPERIODIC);
		eff.lpvTypeSpecificParams   = &pf;

		pf.dwMagnitude = 10000;
		pf.lOffset = 0;
//.........这里部分代码省略.........
开发者ID:Anonymous2,项目名称:project64,代码行数:101,代码来源:DirectInput.cpp


注:本文中的LPDIRECTINPUTDEVICE8::CreateEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。