Example #1
0
void CToxOptionsMultimedia::OnInitDialog()
{
	CToxDlgBase::OnInitDialog();

	CComPtr<IMMDeviceEnumerator> pEnumerator = NULL;
	if (FAILED(CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnumerator)))
		return;

	EnumDevices(m_audioInput, pEnumerator, eCapture, "AudioInputDeviceID");
	EnumDevices(m_audioOutput, pEnumerator, eRender, "AudioOutputDeviceID");
}
Example #2
0
bool DisableDevices(
    PCNC_ENUM_FILTER pFilter,
    PCDevProperties pDevProperties,
    BOOL *pRebootRequired,
    Stack *pDevPropertiesStack)
{
  EnumParams enumParams;

  int res;

  enumParams.pRebootRequired = pRebootRequired;
  enumParams.pDevProperties = pDevProperties;
  enumParams.pStack = pDevPropertiesStack;

  do {
    res = EnumDevices(pFilter, DIGCF_PRESENT, DisableDevice, &enumParams);
  } while (res == IDTRYAGAIN);

  if (res != IDCONTINUE)
    return FALSE;

  if (!WaitNoPendingInstallEvents(10))
    Sleep(1000);

  return TRUE;
}
Example #3
0
VideoCapture::VideoCapture()
{
	cameraInitialized = false;
	

	CoInitialize(NULL);
	ZeroVariables();

	if (EnumDevices()==0) throw -1;
	
	EnumResolutions();
}
Example #4
0
//设置绑定设备
HRESULT CCaptureDevice::BindFilter( REFCLSID clsidDeviceClass, int DeviceIndex )
{
	if( DeviceIndex<0 )
		return S_FALSE;

	BIND_DEVICE_PARAMETER BindDeviceParameter; 
	BindDeviceParameter.DeviceIndex = DeviceIndex;
	BindDeviceParameter.ppBaseFilter = &m_pBaseFilter;

	//枚举绑定
	HRESULT hr;
	hr = EnumDevices( clsidDeviceClass, BindFilterCallback, &BindDeviceParameter );
	if( hr==S_OK )
		AdjustOutput();
	return hr;
}
bool FDirectInputJoystickEnum::Init(FDirectInputDriver& adapter)
{
	vecJoyStickInfo_.Reset();
	auto pDriver = adapter.driver();

	HRESULT r = pDriver->EnumDevices(DI8DEVCLASS_GAMECTRL, &FDirectInputJoystickEnum::OnEnumDevice, this, DIEDFL_ATTACHEDONLY);
	if(FAILED(r))
	{
		UE_LOG(LogDirectInputPadPlugin, Warning, TEXT("Search DirectInputPad Error."));
		return false;
	}

	nXInputDeviceNum_ = RemoveXInputDevice(vecJoyStickInfo_);

	vecJoyStickInfo_.Shrink();
	return true;
}
Example #6
0
VOID
ListDevicesByType(HWND hTreeView,
                  HTREEITEM hRoot,
                  BOOL bShowHidden)
{
    PDEVCLASS_ENTRY pClassArray;
    ULONG ulClassCount;

    ulClassCount = GetClassCount();

    pClassArray = HeapAlloc(GetProcessHeap(),
                            HEAP_ZERO_MEMORY,
                            ulClassCount * sizeof(DEVCLASS_ENTRY));
    if (pClassArray == NULL)
        return;

    EnumDeviceClasses(hTreeView,
                      hRoot,
                      pClassArray,
                      ulClassCount);

    EnumDevices(hTreeView,
                pClassArray,
                ulClassCount,
                bShowHidden);

    CleanupDeviceClasses(hTreeView,
                         pClassArray,
                         ulClassCount);

    if (pClassArray != NULL)
        HeapFree(GetProcessHeap(), 0, pClassArray);

    (void)TreeView_Expand(hTreeView,
                          hRoot,
                          TVE_EXPAND);

    (void)TreeView_SortChildren(hTreeView,
                                hRoot,
                                0);

    (void)TreeView_SelectItem(hTreeView,
                              hRoot);
}
Example #7
0
int EnumDevices(
    PCNC_ENUM_FILTER pFilter,
    PCDevProperties pDevProperties,
    BOOL *pRebootRequired,
    PCNC_DEV_CALLBACK pDevCallBack,
    void *pDevCallBackParam)
{
  EnumParams enumParams;

  enumParams.pDevProperties = pDevProperties;
  enumParams.pRebootRequired = pRebootRequired;
  enumParams.pDevCallBack = pDevCallBack;
  enumParams.pDevCallBackParam = pDevCallBackParam;

  if (EnumDevices(pFilter, DIGCF_PRESENT, EnumDevice, &enumParams) != IDCONTINUE)
    return -1;

  return enumParams.count;
}
CDirectSoundAecCapture::CDirectSoundAecCapture(void)
{
	m_pDSFD = NULL;
	m_pDSCBuffer8 = NULL;
	m_pDSBuffer8 = NULL;

    m_captureIndex = -1;
    m_renderIndex = -1;
	m_samplerate = 0;

	m_NotifySize = 0;
	m_captureBufferSize = 0;
	m_pCaptureDataTemp = NULL;
	m_pEvent = NULL;
	m_runThreadFlag = false;
	m_bUseDefault = FALSE;
	
    EnumDevices();
}
Example #9
0
bool RestartDevices(
    PCNC_ENUM_FILTER pFilter,
    PCDevProperties pDevProperties,
    BOOL *pRebootRequired)
{
  EnumParams enumParams;

  int res;

  enumParams.pRebootRequired = pRebootRequired;
  enumParams.pDevProperties = pDevProperties;

  do {
    res = EnumDevices(pFilter, DIGCF_PRESENT, RestartDevice, &enumParams);
  } while (res == IDTRYAGAIN);

  if (res != IDCONTINUE)
    return FALSE;

  return TRUE;
}
Example #10
0
DInput::DInput(wxEvtHandler *handler, HWND hwnd) :
	_di(nullptr), _hwnd(hwnd), _evtHandler(handler)
{
	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	HINSTANCE hinst = GetModuleHandle(nullptr);
	HRESULT result;
	result = DirectInput8Create(hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID *)&_di, nullptr);
	if (result != DI_OK) {
		Log(Error, "Could not create direct input 8 interface: 0x%08x", result);
		return;
	}

	EnumDevices();

	_devices.clear();
	for (auto &it = _devicesInfo.begin(); it != _devicesInfo.end(); ++it) {
		_devices.emplace_back(this, _di, *it, _hwnd);
	}

}
Example #11
0
bool RemoveDevices(
    PCNC_ENUM_FILTER pFilter,
    PCDevProperties pDevProperties,
    BOOL *pRebootRequired)
{
  EnumParams enumParams;

  int res;

  enumParams.pRebootRequired = pRebootRequired;
  enumParams.pDevProperties = pDevProperties;

  do {
    res = EnumDevices(pFilter, 0, RemoveDevice, &enumParams);
  } while (res == IDTRYAGAIN);

  if (res != IDCONTINUE)
    return FALSE;

  if (!enumParams.count)
    Trace("No devices found\n");

  return TRUE;
}
Example #12
0
HRESULT ZFXD3DEnum::EnumAdapters(void) {
   D3DDISPLAYMODE d3ddspmd;
   HRESULT        hr;
   UINT           nNumAdapters=0;
   UINT           nNumModes=0;

   if (!m_pD3D) return ZFX_INVALIDPARAM;

   // get number of attached adapters
   nNumAdapters = m_pD3D->GetAdapterCount();

   // loop through adapters
   for (UINT nAdapter=0; nAdapter<nNumAdapters; nAdapter++) {
      m_xAdapterInfo[m_dwNumAdapters].nAdapter  = nAdapter;
      m_xAdapterInfo[m_dwNumAdapters].nNumModes = 0;

      // get adapter information struct
      m_pD3D->GetAdapterIdentifier(nAdapter, 0, 
                                   &m_xAdapterInfo[m_dwNumAdapters].
                                   d3dAdapterIdentifier);

      // loop through allowed bpp formats
      for (UINT nFmt=0; nFmt<m_nNumFmt; nFmt++) {
        // get available display modes for this adapter/bpp format
         nNumModes = m_pD3D->GetAdapterModeCount(nAdapter, m_fmtAdapter[nFmt]);
         
         for (UINT nMode=0; nMode<nNumModes; nMode++) {
            // get number of available display modes
            m_pD3D->EnumAdapterModes(nAdapter, m_fmtAdapter[nFmt], 
                                     nMode, &d3ddspmd);

            // don't use less than we asked for
            if (d3ddspmd.Width           < m_nMinWidth  ||
                d3ddspmd.Height          < m_nMinHeight ||
                GetBits(d3ddspmd.Format) < m_nMinBits) {
               continue;
               }
            // else save this mode
            else {
               m_xAdapterInfo[m_dwNumAdapters].d3ddspmd[
                  m_xAdapterInfo[m_dwNumAdapters].nNumModes] = d3ddspmd;
               m_xAdapterInfo[m_dwNumAdapters].nNumModes++;
               }
            } // for [modes]
         } // for [formats]

      // we got the data, now sort it
      qsort(m_xAdapterInfo[m_dwNumAdapters].d3ddspmd, 
            m_xAdapterInfo[m_dwNumAdapters].nNumModes,
            sizeof(D3DDISPLAYMODE),
            SortModesCallback);

      if (FAILED(hr=EnumDevices(m_xAdapterInfo[m_dwNumAdapters]))) 
         return hr;

      // keep this one if any device is found
      if (m_xAdapterInfo[m_dwNumAdapters].nNumDevs > 0)
         m_dwNumAdapters++;
      } // for [adapters]

   return ZFX_OK;
   } //EnumAdapters
Example #13
0
bool Device::EnumAudioDevices(vector<AudioDevice> &devices)
{
	devices.clear();
	return EnumDevices(CLSID_AudioInputDeviceCategory,
			EnumDeviceCallback(EnumAudioDevice), &devices);
}
Example #14
0
bool Device::EnumVideoDevices(std::vector<VideoDevice> &devices)
{
	devices.clear();
	return EnumDevices(CLSID_VideoInputDeviceCategory,
			EnumDeviceCallback(EnumVideoDevice), &devices);
}
Example #15
0
BOOL INPUTCLASS::Init(HWND hParentWnd, INPUTPROC inputProc)
{
	if (hParentWnd == NULL) return FALSE;
	if (inputProc == NULL) return FALSE;

	this->hParentWnd = hParentWnd;

	pDI = NULL;
	pKeyboard = NULL;
	pJoystick = NULL;
	Feedback = FALSE;
	memset(cDIBuf, 0, sizeof(cDIBuf));
	memset(JoystickName, 0, sizeof(JoystickName));

	if(FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&pDI,NULL)))
		return FALSE;

	if (!FAILED(pDI->CreateDevice(GUID_SysKeyboard,&pKeyboard,NULL)))
	{
		if (!FAILED(pKeyboard->SetDataFormat(&c_dfDIKeyboard)))
		{
			if (FAILED(pKeyboard->SetCooperativeLevel(hParentWnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE)))
			{
				pKeyboard->Release();
				pKeyboard = NULL;
			}
		}
		else
		{
			pKeyboard->Release();
			pKeyboard = NULL;
		}
	}

	pJoystick = EnumDevices(pDI);

	if (pJoystick)
	{
		if(!FAILED(pJoystick->SetDataFormat(&c_dfDIJoystick2)))
		{
			if(FAILED(pJoystick->SetCooperativeLevel(hParentWnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE)))
			{
				pJoystick->Release();
				pJoystick = NULL;
			}
			else
			{
				tmp_Joystick = pJoystick;
				pJoystick->EnumObjects(::EnumObjects, (VOID*)hParentWnd, DIDFT_ALL);
				memset(&DIJoycap,0,sizeof(DIDEVCAPS));
				DIJoycap.dwSize=sizeof(DIDEVCAPS);
				pJoystick->GetCapabilities(&DIJoycap);
			}
		}
		else
		{
			pJoystick->Release();
			pJoystick = NULL;
		}
	}

	if (pJoystick)
	{
		DIPROPDWORD dipdw;
		dipdw.diph.dwSize = sizeof(DIPROPDWORD);
		dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
		dipdw.diph.dwObj = 0;
		dipdw.diph.dwHow = DIPH_DEVICE;
		dipdw.dwData = 0;
		if ( !FAILED( pJoystick->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph) ) )
		{
			DWORD		rgdwAxes[1] = { DIJOFS_Y };
			LONG		rglDirection[2] = { 0 };
			DICONSTANTFORCE		cf = { 0 };
			DIEFFECT	eff;

			cf.lMagnitude = (DI_FFNOMINALMAX * 100);
			
			memset(&eff, 0, sizeof(eff));
			eff.dwSize = sizeof(DIEFFECT);
			eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
			eff.dwDuration = INFINITE;
			eff.dwSamplePeriod = 0;
			eff.dwGain = DI_FFNOMINALMAX;
			eff.dwTriggerButton = DIEB_NOTRIGGER;
			eff.dwTriggerRepeatInterval = 0;
			eff.cAxes = 1;
			eff.rgdwAxes = rgdwAxes;
			eff.rglDirection = rglDirection;
			eff.lpEnvelope = 0;
			eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE );
			eff.lpvTypeSpecificParams = &cf;
			eff.dwStartDelay = 0;

			if( FAILED( pJoystick->CreateEffect(GUID_ConstantForce, &eff, &pEffect, NULL) ) )
				Feedback = FALSE;
		}
		else
			Feedback = FALSE;
	}

	if (pKeyboard == NULL && pJoystick == NULL) return FALSE;

	this->inputProc = inputProc;

	INFO("DirectX Input: \n");
	if (pKeyboard != NULL) INFO("   - keyboard successfully inited\n");
	if (pJoystick != NULL)
	{
		INFO("   - gamecontrol successfully inited: %s\n", JoystickName);
		if (Feedback) INFO("\t\t\t\t      (with FeedBack support)\n");
	}

	paused = FALSE;

	return TRUE;
}