Example #1
0
//-----------------------------------------------------------------------------
// Name: OnReadFile2()
// Desc: Reads a file contain a collection of DirectInput force feedback 
//       effects.  It creates each of effect read in and stores it 
//       in the linked list, g_EffectsList.
//-----------------------------------------------------------------------------
HRESULT OnReadFile2( HWND hDlg,const char*file)
{
    HRESULT hr;

     EmptyEffectList2();

    // Enumerate the effects in the file selected, and create them in the callback
    if( FAILED( hr = g_pFFDevice->EnumEffectsInFile( file,EnumAndCreateEffectsCallback2, 
                                                     NULL, DIFEF_MODIFYIFNEEDED ) ) )
        return hr;

    // If list of effects is empty, then we haven't been able to create any effects
    if( g_EffectsList.pNext == &g_EffectsList )
    {
		ctx->OutputToConsole("Unable to create any effects.");

    }
    else
    {
        // We have effects so enable the 'play effects' button

    }

    return S_OK;
}
Example #2
0
//-----------------------------------------------------------------------------
// Name: OnReadFile()
// Desc: Reads a file contain a collection of DirectInput force feedback 
//       effects.  It creates each of effect read in and stores it 
//       in the linked list, g_EffectsList.
//-----------------------------------------------------------------------------
HRESULT OnReadFile( HWND hDlg )
{
    HRESULT hr;

    static TCHAR strFileName[MAX_PATH] = TEXT("");
    static TCHAR strPath[MAX_PATH] = TEXT("");

    // Setup the OPENFILENAME structure
    OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
                         TEXT("FEdit Files\0*.ffe\0All Files\0*.*\0\0"), NULL,
                         0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
                         TEXT("Open FEdit File"),
                         OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
                         TEXT(".ffe"), 0, NULL, NULL };

    // Get the default media path (something like C:\DXSDK\SAMPLES\MULTIMEDIA\DINPUT\MEDIA)
    if( '\0' == strPath[0] )
        _tcscpy( strPath, DXUtil_GetDXSDKMediaPath() );

    // Display the OpenFileName dialog. Then, try to load the specified file
    if( FALSE == GetOpenFileName( &ofn ) )
        return S_OK;

    EmptyEffectList();

    // Enumerate the effects in the file selected, and create them in the callback
    if( FAILED( hr = g_pFFDevice->EnumEffectsInFile( strFileName, 
                                                     EnumAndCreateEffectsCallback, 
                                                     NULL, DIFEF_MODIFYIFNEEDED ) ) )
        return hr;

    // Remember the path for next time
    _tcscpy( strPath, strFileName );
    TCHAR* strLastSlash = _tcsrchr( strPath, '\\' );
    strLastSlash[0] = '\0';

    // If list of effects is empty, then we haven't been able to create any effects
    if( g_EffectsList.pNext == &g_EffectsList )
    {
        // Pop up a box informing the user
        MessageBox( hDlg, _T("Unable to create any effects."),
                          _T("ReadFFE"), MB_ICONEXCLAMATION | MB_OK );
        EnableWindow( GetDlgItem( hDlg, IDC_PLAY_EFFECTS ), FALSE );
    }
    else
    {
        // We have effects so enable the 'play effects' button
        EnableWindow( GetDlgItem( hDlg, IDC_PLAY_EFFECTS ), TRUE );
    }

    return S_OK;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : device - 
//			&map - 
// Output : static void
//-----------------------------------------------------------------------------
static void LoadEffectFile( LPDIRECTINPUTDEVICE8 device, EffectMap_t &map )
{
	LoadEffectContext_t context;
	context.device = device;
	context.map = ↦

	// Pull out of .gcf if needed
	filesystem->GetLocalCopy( map.effectfile );

	char fullpath[ 512 ];
	filesystem->GetLocalPath( map.effectfile, fullpath, sizeof( fullpath ) );

	HRESULT hr = device->EnumEffectsInFile
		( fullpath, 
          EnumEffectsInFileProc,
          (LPVOID)&context, 
          DIFEF_MODIFYIFNEEDED );

	if ( FAILED( hr ) )
	{
		Msg( "EnumEffectsInFile failed for %s\n", map.effectfile );
	}

}
 HRESULT _stdcall EnumEffectsInFile(LPCWSTR a,LPDIENUMEFFECTSINFILECALLBACK b,LPVOID c,DWORD d) {
     return RealDevice->EnumEffectsInFile(a,b,c,d);
 }