bool ChangeInterface(char * filepath, bool silent) { int device = -1; if(!FindDevice(filepath, &device)) return false; return ChangeInterface(device, silent); }
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceOpenPending)(JNIEnv *env, jobject thiz, int nDeviceID) { LOGV( "HIDDeviceOpenPending() id=%d\n", nDeviceID ); hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID ); if ( pDevice ) { pDevice->SetOpenPending(); } }
int ctr_drives_chdrive(const char *drive) { //Check that the drive requested is in the devoptab table int index = FindDevice(drive); if (index == -1) return -1; setDefaultDevice(index); return 0; }
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceOpenResult)(JNIEnv *env, jobject thiz, int nDeviceID, bool bOpened) { LOGV( "HIDDeviceOpenResult() id=%d, result=%s\n", nDeviceID, bOpened ? "true" : "false" ); hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID ); if ( pDevice ) { pDevice->SetOpenResult( bOpened ); } }
bool ChangeInterface(char * filepath, int retryCount ) { int device = -1; if(!FindDevice(filepath, &device)) return false; return ChangeInterface(device, retryCount ); }
// Synchronous operation. Will block until completed. int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length) { LOGV( "hid_get_feature_report id=%d length=%u", device->nId, length ); hid_device_ref<CHIDDevice> pDevice = FindDevice( device->nId ); if ( pDevice ) { return pDevice->GetFeatureReport( data, length ); } return -1; // Controller was disconnected }
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length) { LOGV( "hid_write id=%d length=%u", device->nId, length ); hid_device_ref<CHIDDevice> pDevice = FindDevice( device->nId ); if ( pDevice ) { return pDevice->SendOutputReport( data, length ); } return -1; // Controller was disconnected }
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen) { hid_device_ref<CHIDDevice> pDevice = FindDevice( device->nId ); if ( pDevice ) { wcsncpy( string, pDevice->GetDeviceInfo()->serial_number, maxlen ); return 0; } return -1; }
////////////////////////////////////////////////////////////////////////////////// // CRMEngine CreateWindowed - creates a windowed application ////////////////////////////////////////////////////////////////////////////////// HRESULT CRMEngine::CreateWindowed(CDXScreen* pScreen, void *hWnd, int Width, int Height) { GUID d3dGUID; CDXLOG("START: CRMEngine::CreateWindowed"); CDXLOG("Release our m_RMDevice and Clipper object if we have one"); // first release everything that has been allocated RELEASE(m_RMDevice); RELEASE(m_lpDDClipper); CDXLOG("Save the Screen object and do a CreateWindow"); // create the CDXScreen object m_Screen = pScreen; if(FAILED(m_Screen->CreateWindowed(hWnd, Width, Height))) { CDXLOG("CreateWindow failed"); return D3DRMERR_NOTDONEYET; } CDXLOG("Create a Clipper object"); // create the dd clipper object if(FAILED(DirectDrawCreateClipper(0, &m_lpDDClipper, NULL))) { CDXLOG("Clipper creation failed"); return D3DRMERR_NOTDONEYET; } CDXLOG("Set the hWnd of the clipper to the main window"); // set the clipper objects hWnd if(FAILED(m_lpDDClipper->SetHWnd(0, (HWND)hWnd))) { RELEASE(m_lpDDClipper); return D3DRMERR_NOTDONEYET; } CDXLOG("Do a CreateDeviceFromClipper to setup the 3DRM clipper"); // create the d3d device if(FAILED(m_Direct3DRM->CreateDeviceFromClipper(m_lpDDClipper, FindDevice(m_Screen->GetBPP(), &d3dGUID), Width, Height, &m_RMDevice))) { return D3DRMERR_NOTDONEYET; } CDXLOG("Call SetDefaults"); // start our engine with default values based on color depth SetDefaults(); CDXLOG("END: CRMEngine::CreateWindowed"); return D3DRM_OK; }
// TODO: Implement timeout? int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *device, unsigned char *data, size_t length, int milliseconds) { // LOGV( "hid_read_timeout id=%d length=%u timeout=%d", device->nId, length, milliseconds ); hid_device_ref<CHIDDevice> pDevice = FindDevice( device->nId ); if ( pDevice ) { return pDevice->GetInput( data, length ); } LOGV( "controller was disconnected" ); return -1; // Controller was disconnected }
int OpenProfilesFolder() { sprintf(browser.dir, "%s/profiles/", appPath); int device = 0; FindDevice(browser.dir, &device); CleanupPath(browser.dir); ResetBrowser(); // reset browser return ParseDirectory(); }
void Fl_Canvas::DeleteSelection (void) { if (! m_HaveSelection) return; // show some warning here for (unsigned int i=0; i<m_Selection.m_DeviceIds.size(); i++) { int ID = m_Selection.m_DeviceIds[i]; Fl_DeviceGUI* o = FindDevice(ID); if (o) Fl_DeviceGUI::Kill(o); } m_HaveSelection = false; m_Selection.Clear(); redraw(); }
bool C1WireByOWFS::FindDevice(const std::string inDir, const std::string sID, /*out*/_t1WireDevice& device) const { bool found = false; DIR *d=opendir(inDir.c_str()); if (d != NULL) { struct dirent *de=NULL; // Loop while not NULL or not found while((de=readdir(d)) && !found) { // Check dir if (!IsValidDir(de)) continue; // Get the device from it's dirname GetDevice(inDir, de->d_name, device); // Check if it's the device we are looking for if (device.devid.compare(0,sID.length(),sID)==0) { found=true; continue; } // Else, try to scan hubs (recursively) if (device.family==microlan_coupler) { // Search in "main" and "aux" dir found=FindDevice(inDir + "/" + de->d_name + HUB_MAIN_SUB_PATH, sID, device); if(!found) found=FindDevice(inDir + "/" + de->d_name + HUB_AUX_SUB_PATH, sID, device); } } } closedir(d); return found; }
KSGDeviceNode* KSGDeviceManager::NewDevice( int did, KSGDeviceNode* parent, const std::string& phyid, KSGDevice* devtype) { KSGDeviceNode* ret = FindDevice(did); if(ret) throw DeviceIdAlreadyExists(); ret = _pool.construct(did,parent,devtype); ret->SetPhyId(phyid); SaveDevice(ret); return ret; }
JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceFeatureReport)(JNIEnv *env, jobject thiz, int nDeviceID, jbyteArray value) { jbyte *pBuf = env->GetByteArrayElements(value, NULL); jsize nBufSize = env->GetArrayLength(value); LOGV( "HIDDeviceFeatureReport() id=%d len=%u\n", nDeviceID, nBufSize ); hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID ); if ( pDevice ) { pDevice->ProcessFeatureReport( reinterpret_cast< const uint8_t* >( pBuf ), nBufSize ); } env->ReleaseByteArrayElements(value, pBuf, 0); }
static int MakeX(int help) { char *token, *server; int dpi, device, defDPI; if (help) { p_stderr("gist: display command syntax:\n "); p_stderr("display host:server.screen [dpi]\n"); p_stderr(" Connects to the specified X server.\n"); p_stderr(" Subsequent draw commands will write to server,\n"); p_stderr(" unless the draw to list is modified (see draw).\n"); p_stderr(" If specified, 40<=dpi<=200 (default 100).\n"); return 0; } token= strtok(0, " \t\n"); if (!token) { p_stderr("gist: (SYNTAX) cgmoutput name missing in cgm command\n"); return 0; } server= token; token= strtok(0, " \t\n"); if (token) { char *suffix; dpi= (int)strtol(token, &suffix, 0); if (*suffix) { p_stderr("gist: (SYNTAX) dpi unintelligble in display command\n"); return 0; } if (dpi<40 && dpi>200) { p_stderr( "gist: (SYNTAX) dpi not between 40 and 200 in display command\n"); return 0; } if (CheckEOL("display")) return 0; } else { dpi= 100; } device= FindDevice(); if (device>=8) return 0; defDPI= defaultDPI; defaultDPI= dpi; CreateX(device, server); defaultDPI= defDPI; return 0; }
// nsIDNSServiceResolveListener NS_IMETHODIMP MulticastDNSDeviceProvider::OnServiceResolved(nsIDNSServiceInfo* aServiceInfo) { MOZ_ASSERT(NS_IsMainThread()); if (NS_WARN_IF(!aServiceInfo)) { return NS_ERROR_INVALID_ARG; } nsresult rv; nsAutoCString serviceName; if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceName(serviceName)))) { return rv; } LOG_I("OnServiceResolved: %s", serviceName.get()); nsAutoCString host; if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetHost(host)))) { return rv; } uint16_t port; if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetPort(&port)))) { return rv; } nsAutoCString serviceType; if (NS_WARN_IF(NS_FAILED(rv = aServiceInfo->GetServiceType(serviceType)))) { return rv; } uint32_t index; if (FindDevice(host, index)) { return UpdateDevice(index, serviceName, serviceType, host, port); } else { return AddDevice(serviceName, serviceType, host, port); } return NS_OK; }
bool emuShutdown(const CComBSTR& deviceIdentifier) { CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL; BOOL bFound = FindDevice(deviceIdentifier, &pDevice); if (bFound && pDevice){ HRESULT hr = pDevice->Shutdown(FALSE); if (!SUCCEEDED(hr)) { wprintf(L"Error: Operation Shutdown failed. Hr=0x%x\n", hr); return false; } return true; } return false; }
bool IsWidcommDevice(const TCHAR *name) { TCHAR key[64]; if (!FindDevice(name, key, 64)) return false; RegistryKey registry(HKEY_LOCAL_MACHINE, key, true); if (registry.error()) return false; TCHAR dll[64]; return registry.get_value(_T("Dll"), dll, 64) && _tcscmp(dll, _T("btcedrivers.dll")); }
KSGDeviceNode* KSGDeviceManager::NewDevice( int did, int parentId, const std::string& phyid, NormalDeviceType devtype) { KSGDeviceNode* ret = FindDevice(did); if(ret) throw DeviceIdAlreadyExists(); KSGDevice* dev = FindDeviceType(devtype); ret = _pool.construct<int,int,KSGDevice*>(did,parentId,dev); ret->SetPhyId(phyid); SaveDevice(ret); return ret; }
void Fl_Canvas::ClearConnections(Fl_DeviceGUI* Device) { bool removedall=false; //make sure we don't leave a dangling incomplete wire this will cause errors/seg-faults if (UserMakingConnection() && Device && ((Device->GetID() == m_IncompleteWire.OutputID) || (Device->GetID() == m_IncompleteWire.InputID))) { ClearIncompleteWire(); } while (!removedall) { removedall=true; for (vector<CanvasWire>::iterator i=m_WireVec.begin(); i!=m_WireVec.end(); i++) { if (i->OutputID==Device->GetID() || i->InputID==Device->GetID()) { // Turn off both ports FindDevice(i->OutputID)->RemoveConnection(i->OutputPort+FindDevice(i->OutputID)->GetInfo()->NumInputs); FindDevice(i->InputID)->RemoveConnection(i->InputPort); // send the unconnect callback cb_Unconnect(this,(void*)&(*i)); m_Graph.RemoveConnection(i->OutputID,i->InputID); m_WireVec.erase(i); removedall=false; break; } } } }
bool DownloadUpdate() { bool result = false; if(updateURL[0] == 0 || appPath[0] == 0 || !ChangeInterface(appPath, NOTSILENT)) { ErrorPrompt("Update failed!"); updateFound = false; // updating is finished (successful or not!) return false; } // stop checking if devices were removed/inserted // since we're saving a file HaltDeviceThread(); int device; FindDevice(appPath, &device); char updateFile[50]; sprintf(updateFile, "%s%s Update.zip", pathPrefix[device], APPNAME); FILE * hfile = fopen (updateFile, "wb"); if (hfile) { if(http_request(updateURL, hfile, NULL, (1024*1024*10), NOTSILENT) > 0) { fclose (hfile); result = unzipArchive(updateFile, (char *)pathPrefix[device]); } else { fclose (hfile); } remove(updateFile); // delete update file } // go back to checking if devices were inserted/removed ResumeDeviceThread(); if(result) InfoPrompt("Update successful!"); else ErrorPrompt("Update failed!"); updateFound = false; // updating is finished (successful or not!) return result; }
void KSGDeviceManager::make_device_toplogic(KSGDeviceNode* node) { int pnode_id = node->GetParentId(); if(pnode_id == KSGDeviceNode::NullParentDevId) pnode_id = KSGDeviceNode::LoopDeviceId; KSGDeviceNode *pnode = FindDevice(pnode_id); if(!pnode) { ACE_DEBUG((LM_ERROR,"设备[%d][%s]无法找到上级节点",node->GetDevId(),node->get_name().c_str())); } else { node->SetParent(pnode); } }
inline void Fl_Canvas::cb_OnDrag_i (Fl_Widget* widget, int xoffset, int yoffset) { if ((widget) && (widget->parent())) { int moved_device_id = ((Fl_DeviceGUI*)(widget->parent()))->GetID(); if (m_HaveSelection) { if (m_Selection.m_DeviceIds.size() <= 0) m_HaveSelection = false; for (unsigned int i=0; i<m_Selection.m_DeviceIds.size(); i++) { int ID = Selection().m_DeviceIds[i]; Fl_Widget *o = FindDevice(ID); if ((o) && (m_Selection.m_DeviceIds[i] != moved_device_id)) { o->position (o->x() + xoffset, o->y() + yoffset); } } } } return; }
void C1WireByOWFS::SetLightState(const std::string& sId,int unit,bool value) { _t1WireDevice device; if (!FindDevice(sId, device)) return; switch(device.family) { case Addresable_Switch: { writeData(device,"PIO",value?"yes":"no"); break; } case dual_addressable_switch_plus_1k_memory: case Temperature_IO: case dual_channel_addressable_switch: { if (unit<0 || unit>1) return; writeData(device,std::string("PIO.").append(1,'A'+unit),value?"yes":"no"); break; } case _8_channel_addressable_switch: { if (unit<0 || unit>7) return; writeData(device,std::string("PIO.").append(1,'0'+unit),value?"yes":"no"); break; } case _4k_EEPROM_with_PIO: { if (unit<0 || unit>1) return; writeData(device,std::string("PIO.").append(1,'0'+unit),value?"yes":"no"); break; } case microlan_coupler: { // 1 = Unconditionally off (non-conducting), 2 = Unconditionally on (conducting) writeData(device,"control",value?"2":"1"); break; } default: return; } }
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device) { LOGV( "hid_close id=%d", device->nId ); hid_device_ref<CHIDDevice> pDevice = FindDevice( device->nId ); if ( pDevice ) { pDevice->DecrementDeviceRefCount(); if ( pDevice->GetDeviceRefCount() == 0 ) { pDevice->Close( true ); } } else { // Couldn't find it, it's already closed delete device; } }
bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage) { PARTITION* partition; devoptab_t* devops; char* nameCopy; if(!name || strlen(name) > 8 || !interface) return false; if(!interface->startup()) return false; if(!interface->isInserted()) return false; char devname[10]; strcpy(devname, name); strcat(devname, ":"); if(FindDevice(devname) >= 0) return true; devops = _FAT_mem_allocate (sizeof(devoptab_t) + strlen(name) + 1); if (!devops) { return false; } // Use the space allocated at the end of the devoptab struct for storing the name nameCopy = (char*)(devops+1); // Initialize the file system partition = _FAT_partition_constructor (interface, cacheSize, SectorsPerPage, startSector); if (!partition) { _FAT_mem_free (devops); return false; } // Add an entry for this device to the devoptab table memcpy (devops, &dotab_fat, sizeof(dotab_fat)); strcpy (nameCopy, name); devops->name = nameCopy; devops->deviceData = partition; AddDevice (devops); return true; }
static int Draw(int help) { int i, n; char *token; if (help) { p_stderr("gist: draw command syntax:\n draw [page list]\n"); p_stderr( " Copy the page(s) (default current page) from the current CGM input\n"); p_stderr(" to all display output devices.\n"); p_stderr(" By default, these are all X windows.\n"); p_stderr(" Use alternate syntax:\n draw to [device#1 ...]\n"); p_stderr(" to specify a particular list of devices to be used\n"); p_stderr(" by the draw command. Without any device numbers,\n"); p_stderr(" draw to restores the default list of devices.\n"); p_stderr(" (Use the info command to describe current device numbers.)\n"); p_stderr(" Page list syntax: group1 [group2 ...]\n"); p_stderr(" Page group syntax: n - just page n\n"); p_stderr(" m-n - pages n thru m\n"); p_stderr(" m-n-s - pages n thru m, step s\n"); return 0; } token= strtok(0, " \t\n"); if (token && strcmp(token, "to")==0) { DrawSend(1, token); return 0; } n= 0; for (i=0 ; i<8 ; i++) { if (!outDraw[i]) GpDeactivate(outEngines[i]); if (outDraw[i] && !GpActivate(outEngines[i])) n++; } if (!n && (i= FindDevice())<8) { if (!CreateX(i, 0) && !GpActivate(outEngines[i])) n++; } if (n) DrawSend(0, token); else Warning("no devices active for draw command", ""); return 0; }
/**************************************************************************** * BrowserLoadFile * * Loads the selected ROM ***************************************************************************/ int BrowserLoadFile() { int loaded = 0; int device; if(!FindDevice(browser.dir, &device)) return 0; // check that this is a valid ROM if(!IsValidROM()) goto done; // store the filename (w/o ext) - used for sram/freeze naming StripExt(Memory.ROMFilename, browserList[browser.selIndex].filename); snprintf(GCSettings.LastFileLoaded, MAXPATHLEN, "%s", browserList[browser.selIndex].filename); strncpy(Memory.ROMFilePath, browser.dir, PATH_MAX); SNESROMSize = 0; S9xDeleteCheats(); Memory.LoadROM("ROM"); if (SNESROMSize == 0) { ErrorPrompt("Error loading game!"); } else if(bsxBiosLoadFailed) { ErrorPrompt("BS-X BIOS file not found!"); } else { // load SRAM or snapshot if (GCSettings.AutoLoad == 1) LoadSRAMAuto(SILENT); else if (GCSettings.AutoLoad == 2) LoadSnapshotAuto(SILENT); ResetBrowser(); loaded = 1; } done: CancelAction(); return loaded; }
XN_C_API XnStatus xnUSBOpenDevice(XnUInt16 nVendorID, XnUInt16 nProductID, void* pExtraParam, void* pExtraParam2, XN_USB_DEV_HANDLE* pDevHandlePtr) { XnStatus nRetVal = XN_STATUS_OK; // make sure library was initialized XN_VALIDATE_USB_INIT(); // Validate parameters XN_VALIDATE_OUTPUT_PTR(pDevHandlePtr); libusb_device* pDevice; nRetVal = FindDevice(nVendorID, nProductID, pExtraParam, &pDevice); XN_IS_STATUS_OK(nRetVal); nRetVal = xnUSBOpenDeviceImpl(pDevice, pDevHandlePtr); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }