bool Device::Init() { ResetDevice(); if (!Device_Inserted()) return false; SearchConfig(); if(device.ConfigDevice == 0) { SearchBootDevice(); if(GetDeviceCount() >= 2) { if(SearchDolDevice() != 0) device.BootDevice = device.DolDevice; } device.ConfigDevice = device.BootDevice; } device.BootDevice = device.ConfigDevice; device.BrowsedDevice = device.ConfigDevice; device.DeviceCount = GetDeviceCount(); return true; }
/** Check whether enable feature or not. @retval Return the disk number. **/ UINT8 HiiGetNumConfigRequiredOpalDisksCB( VOID ) { UINT8 NumDisks; UINT8 NumLockedOpalDisks; OPAL_DISK *OpalDisk; UINT8 Index; NumLockedOpalDisks = 0; NumDisks = GetDeviceCount(); for (Index = 0; Index < NumDisks; Index++) { OpalDisk = HiiGetOpalDiskCB(Index); if (OpalDisk != NULL) { if (!OpalFeatureEnabled (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature)) { DEBUG ((DEBUG_INFO, "Ignoring disk %u because feature is disabled or health has already been inspected\n", Index)); } else if (OpalDeviceLocked (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature)) { NumLockedOpalDisks++; } } } return NumLockedOpalDisks; }
int OpenOCDDevFTDI::BuildDeviceString(int index, wxString &str) { wxString ds; if (!(index < GetDeviceCount())) return -1; // Device description str = _T("\nft2232_device_desc "); str += _T("\""); str += OpenOCD_ft2232[index].DeviceDesc; str += _T("\""); // Layout str += _T("\nft2232_layout "); str += _T("\""); str += OpenOCD_ft2232[index].Layout; str += _T("\""); // Vid / Pid ds.Printf(_T("\nft2232_vid_pid 0x%04x 0x%04x"), OpenOCD_ft2232[index].Vid, OpenOCD_ft2232[index].Pid); str += ds; return 0; }
/** Returns the opaque pointer to a physical disk context. @param DiskIndex Input the disk index. @retval The device pointer. **/ VOID * HiiGetDiskContextCB( UINT8 DiskIndex ) { OPAL_DRIVER_DEVICE* Dev; UINT8 CurrentDisk; Dev = OpalDriverGetDeviceList(); CurrentDisk = 0; if (DiskIndex >= GetDeviceCount()) { return NULL; } while (Dev != NULL) { if (CurrentDisk == DiskIndex) { return Dev; } else { Dev = Dev->Next; CurrentDisk++; } } return NULL; }
rhi::IDevice * GetPrimaryDevice() override { if (!m_pMainDevice && m_ppAdapters && GetDeviceCount() > 0) { m_pMainDevice = m_ppAdapters[0]->GetDevice(); } return m_pMainDevice; }
/////////////////////////////////////////////////////////////////////////// // CServiceProviderUI::ResetConfiguration // // This dumps all our configuration data and resets all the arrays // as if we had nothing loaded. // void CServiceProviderUI::ResetConfiguration() { // Delete all our objects while (GetDeviceCount() > 0) { CTSPUIDevice* pDevice = GetDeviceByIndex(0); m_arrDevices.RemoveAt(0); delete pDevice; } }// CServiceProviderUI::ResetConfiguration
int OpenOCDDevFTDI::FindItem(wxString item) { int index = -1; int num = GetDeviceCount(); for (int i = 0; i < num; i++) { if (item == OpenOCD_ft2232[i].DeviceDesc) index = i; } return index; }
static int CardIdFromString(int api, const QString& str) { int n = GetDeviceCount(api); for(int i = 0; i < n; ++i) { DeviceInfo devinfo; GetDeviceInfo(api, i, &devinfo); if(str == QString::fromUtf8(devinfo.fName)) { return i; } } return -1; }
APIENTRY DWORD auxMessage(UINT dwId, UINT uMessage, DWORD dwUser, DWORD dwParam1, DWORD dwParam2) { MMRESULT Result; AUX_DD_VOLUME Volume; DPRINT("auxMessage\n"); // the following cases are documented by DDK switch (uMessage) { case AUXDM_GETDEVCAPS: DPRINT("AUXDM_GETDEVCAPS"); return GetDeviceCapabilities(dwId, AuxDevice, (LPBYTE)dwParam1, (DWORD)dwParam2); case AUXDM_GETNUMDEVS: DPRINT("AUXDM_GETNUMDEVS"); return GetDeviceCount(AuxDevice); case AUXDM_GETVOLUME: DPRINT("AUXDM_GETVOLUME"); Result = AuxGetAudio(dwId, (PBYTE) &Volume, sizeof(Volume)); if (Result == MMSYSERR_NOERROR) { *(LPDWORD)dwParam1 = (DWORD)MAKELONG(HIWORD(Volume.Left), HIWORD(Volume.Right)); } return Result; case AUXDM_SETVOLUME: DPRINT("AUXDM_SETVOLUME"); Volume.Right = HIWORD(dwParam1) << 16; Volume.Left = LOWORD(dwParam1) << 16; return AuxSetAudio(dwId, (PBYTE)&Volume, sizeof(Volume)); } return MMSYSERR_NOERROR; }
APIENTRY DWORD midMessage(DWORD dwId, DWORD dwMessage, DWORD dwUser, DWORD dwParam1, DWORD dwParam2) { DPRINT("midMessage\n"); return MMSYSERR_NOERROR; switch (dwMessage) { case MIDM_GETNUMDEVS: DPRINT("MIDM_GETNUMDEVS"); return GetDeviceCount(MidiInDevice); case MIDM_GETDEVCAPS: DPRINT("MIDM_GETDEVCAPS"); return GetDeviceCapabilities(dwId, MidiInDevice, (LPBYTE)dwParam1, (DWORD)dwParam2); case MIDM_OPEN: DPRINT("MIDM_OPEN"); return MMSYSERR_NOERROR; case MIDM_CLOSE: DPRINT("MIDM_CLOSE"); return MMSYSERR_NOERROR; case MIDM_ADDBUFFER: DPRINT("MIDM_ADDBUFFER"); return MMSYSERR_NOERROR; case MIDM_STOP: DPRINT("MIDM_PAUSE"); return MMSYSERR_NOERROR; case MIDM_START: DPRINT("MIDM_RESTART"); return MMSYSERR_NOERROR; case MIDM_RESET: DPRINT("MIDM_RESET"); return MMSYSERR_NOERROR; default: return MMSYSERR_NOTSUPPORTED; } // the function should never get to this point //FIXME: Would it be wise to assert here? return MMSYSERR_NOTSUPPORTED; }
bool CTSProcessor::GetDeviceList(std::vector<String> *pList) const { if (pList == nullptr) return false; pList->clear(); int Count = GetDeviceCount(); for (int i = 0; i < Count; i++) { String Name; if (!GetDeviceName(i, &Name)) { pList->clear(); return false; } pList->push_back(std::move(Name)); } return true; }
APIENTRY DWORD modMessage(DWORD ID, DWORD Message, DWORD User, DWORD Param1, DWORD Param2) { DPRINT("modMessage\n"); switch(Message) { case MODM_GETNUMDEVS: DPRINT("MODM_GETNUMDEVS == %d\n", (int)GetDeviceCount(MidiOutDevice)); return GetDeviceCount(MidiOutDevice); case MODM_GETDEVCAPS: DPRINT("MODM_GETDEVCAPS"); return GetDeviceCapabilities(ID, MidiOutDevice, (LPBYTE)Param1, (DWORD)Param2); case MODM_OPEN : return OpenMidiDevice(MidiOutDevice, ID, User, Param1, Param2); case MODM_CLOSE: DPRINT("MODM_CLOSE"); return MMSYSERR_NOTSUPPORTED; case MODM_DATA: DPRINT("MODM_DATA"); int i; BYTE b[4]; for (i = 0; i < 4; i ++) { b[i] = (BYTE)(Param1 % 256); Param1 /= 256; } return WriteMidi(b, GetMidiLength((PMIDIALLOC)User, b[0]), (PMIDIALLOC)User); case MODM_LONGDATA: DPRINT("MODM_LONGDATA"); return MMSYSERR_NOTSUPPORTED; case MODM_RESET: DPRINT("MODM_RESET"); return MMSYSERR_NOTSUPPORTED; case MODM_SETVOLUME: DPRINT("MODM_SETVOLUME"); return MMSYSERR_NOTSUPPORTED; case MODM_GETVOLUME: DPRINT("MODM_GETVOLUME"); return MMSYSERR_NOTSUPPORTED; case MODM_CACHEPATCHES: DPRINT("MODM_CACHEPATCHES"); return MMSYSERR_NOTSUPPORTED; case MODM_CACHEDRUMPATCHES: DPRINT("MODM_CACHEDRUMPATCHES"); return MMSYSERR_NOTSUPPORTED; }; return MMSYSERR_NOTSUPPORTED; }