static DeviceIdType GetDeviceID(IOHIDDeviceRef dev) { DeviceIdType device{0}; int vendor = GetIntProperty(dev, CFSTR(kIOHIDVendorIDKey)); int product = GetIntProperty(dev, CFSTR(kIOHIDProductIDKey)); int location = GetIntProperty(dev, CFSTR(kIOHIDLocationIDKey)); device.at(0) = vendor & 0xFF; device.at(1) = (vendor >> 8) & 0xFF; device.at(2) = product & 0xFF; device.at(3) = (product >> 8) & 0xFF; device.at(4) = (location >> 16) & 0xFF; device.at(5) = (location >> 24) & 0xFF; return device; }
void FScriptContextBase::FetchScriptPropertyValues(UScriptBlueprintGeneratedClass* Class, UObject* Obj) { // @todo: optimize this for (auto Property : Class->ScriptProperties) { if (UFloatProperty* FloatProperty = Cast<UFloatProperty>(Property)) { float Value = GetFloatProperty(Property->GetName()); FloatProperty->SetFloatingPointPropertyValue(Property->ContainerPtrToValuePtr<float>(Obj), Value); } else if (UIntProperty* IntProperty = Cast<UIntProperty>(Property)) { int32 Value = GetIntProperty(Property->GetName()); IntProperty->SetPropertyValue(Property->ContainerPtrToValuePtr<int32>(Obj), Value); } else if (UBoolProperty* BoolProperty = Cast<UBoolProperty>(Property)) { bool Value = GetBoolProperty(Property->GetName()); BoolProperty->SetPropertyValue(Property->ContainerPtrToValuePtr<float>(Obj), Value); } else if (UObjectProperty* ObjectProperty = Cast<UObjectProperty>(Property)) { UObject* Value = GetObjectProperty(Property->GetName()); ObjectProperty->SetObjectPropertyValue(Property->ContainerPtrToValuePtr<UObject*>(Obj), Value); } else if (UStrProperty* StringProperty = Cast<UStrProperty>(Property)) { FString Value = GetStringProperty(Property->GetName()); StringProperty->SetPropertyValue(Property->ContainerPtrToValuePtr<FString>(Obj), Value); } } }
XnBool XnSensorDepthGenerator::IsViewPointAs(xn::ProductionNode& OtherNode) { XnUInt64 nValue = FALSE; GetIntProperty(XN_STREAM_PROPERTY_REGISTRATION, nValue); return (nValue == TRUE && IsSensorImageNode(OtherNode)); }
IOHIDReportCallback CInputProviderMacOsHid::GetCallback(IOHIDDeviceRef device) { auto vid = GetIntProperty(device, CFSTR(kIOHIDVendorIDKey)); auto pid = GetIntProperty(device, CFSTR(kIOHIDProductIDKey)); if(vid == 0x54C) { if(pid == 0x9CC || pid == 0x5C4) { return &InputReportCallbackStub_DS4; } else if(pid == 0x268) { return &InputReportCallbackStub_DS3; } } return nullptr; }
XnStatus XnSensorDevice::GetErrorState() { XnUInt64 nValue = XN_STATUS_OK; XnStatus nRetVal = GetIntProperty(XN_MODULE_PROPERTY_ERROR_STATE, nValue); XN_ASSERT(nRetVal == XN_STATUS_OK); return (XnStatus)nValue; }
XnStatus XnSensorImageGenerator::Get( const XnChar* strCap, XnInt32& nValue ) { XnUInt64 nValue64; XnStatus nRetVal = GetIntProperty(strCap, nValue64); XN_IS_STATUS_OK(nRetVal); nValue = (XnInt32)nValue64; return XN_STATUS_OK; }
XnStatus XnSensorImageGenerator::SetPixelFormat(XnPixelFormat Format) { if (GetPixelFormat() == Format) { return (XN_STATUS_OK); } XnUInt64 nCurrentInputFormat; GetIntProperty(XN_STREAM_PROPERTY_INPUT_FORMAT, nCurrentInputFormat); XN_PROPERTY_SET_CREATE_ON_STACK(props); XnStatus nRetVal = XnPropertySetAddModule(&props, m_strModule); XN_IS_STATUS_OK(nRetVal); XnOutputFormats OutputFormat; switch (Format) { case XN_PIXEL_FORMAT_RGB24: OutputFormat = XN_OUTPUT_FORMAT_RGB24; break; case XN_PIXEL_FORMAT_YUV422: OutputFormat = XN_OUTPUT_FORMAT_YUV422; break; case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: OutputFormat = XN_OUTPUT_FORMAT_GRAYSCALE8; break; case XN_PIXEL_FORMAT_MJPEG: OutputFormat = XN_OUTPUT_FORMAT_JPEG; break; default: return XN_STATUS_INVALID_OPERATION; } if (nCurrentInputFormat != XN_IO_IMAGE_FORMAT_JPEG && OutputFormat == XN_OUTPUT_FORMAT_JPEG) { XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_INPUT_FORMAT, (XnUInt64)XN_IO_IMAGE_FORMAT_JPEG); } else if (nCurrentInputFormat == XN_IO_IMAGE_FORMAT_JPEG && OutputFormat != XN_OUTPUT_FORMAT_JPEG) { XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_INPUT_FORMAT, (XnUInt64)XN_IMAGE_STREAM_DEFAULT_INPUT_FORMAT); } XnPropertySetAddIntProperty(&props, m_strModule, XN_STREAM_PROPERTY_OUTPUT_FORMAT, (XnUInt64)OutputFormat); return m_pSensor->BatchConfig(&props); }
XnStatus XnSensorDepthGenerator::UpdateRealWorldTranslationData() { XnStatus nRetVal = XN_STATUS_OK; XnUInt64 nZPD; nRetVal = GetIntProperty(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, nZPD); XN_IS_STATUS_OK(nRetVal); XnDouble fZPPS; nRetVal = GetRealProperty(XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, fZPPS); XN_IS_STATUS_OK(nRetVal); m_FOV.fHFOV = 2*atan(fZPPS*XN_SXGA_X_RES/2/nZPD); m_FOV.fVFOV = 2*atan(fZPPS*XN_VGA_Y_RES*2/2/nZPD); nRetVal = m_fovChangedEvent.Raise(); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
bool CConfigFile::GetBoolProperty(std::string section, std::string key, bool& value) { int intValue = 0; bool result = GetIntProperty(section, key, intValue); if (result) { if (intValue == 0) { value = false; } else if (intValue == 1) { value = true; } else { GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing bool property %s.%s (expected 0 or 1, not %d)\n", section.c_str(), key.c_str(), intValue); return false; } } return result; }
void CInputProviderMacOsHid::OnDeviceMatched(IOReturn result, void* sender, IOHIDDeviceRef device) { m_devices.push_back(DEVICE_INFO()); auto& deviceInfo = *m_devices.rbegin(); deviceInfo.provider = this; deviceInfo.device = device; deviceInfo.deviceId = GetDeviceID(device); auto InputReportCallbackStub = GetCallback(device); if(InputReportCallbackStub) { uint32_t max_input_report_size = GetIntProperty(device, CFSTR(kIOHIDMaxInputReportSizeKey)); uint8_t* report_buffer = static_cast<uint8_t*>(calloc(max_input_report_size, sizeof(uint8_t))); IOHIDDeviceRegisterInputReportCallback(device, report_buffer, max_input_report_size, InputReportCallbackStub, &deviceInfo); } else { if(OnInput) { SetInitialBindValues(device); } IOHIDDeviceRegisterInputValueCallback(device, &InputValueCallbackStub, &deviceInfo); } }
XnUInt32 XnSensorImageGenerator::FindSupportedInputFormat(XnUInt32* anAllowedInputFormats, XnUInt32 nAllowedInputFormats) { // first check if current one is allowed XnUInt64 nCurrentInputFormat; GetIntProperty(XN_STREAM_PROPERTY_INPUT_FORMAT, nCurrentInputFormat); for (XnUInt32 i = 0; i < nAllowedInputFormats; ++i) { if (anAllowedInputFormats[i] == nCurrentInputFormat) { return (XnUInt32)nCurrentInputFormat; } } // current one is not allowed. find a matching mode and take its input format XnMapOutputMode outputMode; GetMapOutputMode(outputMode); // the order in the allowed input formats is the preferred one for (XnUInt32 iInput = 0; iInput < nAllowedInputFormats; ++iInput) { // see if such a mode exists for (XnUInt32 iMode = 0; iMode < m_nSupportedModesCount; ++iMode) { if (m_aSupportedModes[iMode].nInputFormat == anAllowedInputFormats[iInput] && m_aSupportedModes[iMode].OutputMode.nXRes == outputMode.nXRes && m_aSupportedModes[iMode].OutputMode.nYRes == outputMode.nYRes && m_aSupportedModes[iMode].OutputMode.nFPS == outputMode.nFPS) { return anAllowedInputFormats[iInput]; } } } return INVALID_INPUT_FORMAT; }
int mitk::Annotation::GetFontSize() const { int fontSize = 1; GetIntProperty("FontSize", fontSize); return fontSize; }
CFont::CFont(CXMLTreeNode& fontNode, CGUI* gui) : CNamed(fontNode) , m_glyphs( MAX_GLYPHS_BATCH ) , m_gui(gui) , m_textAlign(Rectf::Alignment::TOP_LEFT) { auto mm = CEngine::GetSingleton().getMaterialManager(); auto tm = CEngine::GetSingleton().getTextureManager(); std::string fontFile = fontNode.GetPszProperty("path", "", false); std::string fontName = fontNode.GetPszProperty("name", "", false); DEBUG_ASSERT(fontFile.size() != 0 && fontName.size() != 0); if (fontFile.size() == 0 || fontName.size() == 0) { return; } for (int i = 0; i < fontNode.GetNumChildren(); ++i) { auto matNode = fontNode(i); if (matNode.GetName() == std::string("material")) { std::string matName = "font-material-" + fontName; CMaterial *mat = new CMaterial(matNode); mat->setName(matName); mm->add(matName, mat); m_material = mat; break; } } std::string fontPath; size_t pathEnd = fontFile.find_last_of('\\'); if (pathEnd == fontFile.npos) { pathEnd = fontFile.find_last_of('/'); } if (pathEnd != fontFile.npos) { fontPath = fontFile.substr(0, pathEnd+1); } CXMLTreeNode ff; if (!ff.LoadFile(fontFile.c_str())) { DEBUG_ASSERT(false); return; } CXMLTreeNode font = ff["font"]; CXMLTreeNode common = font["common"]; CXMLTreeNode info = font["info"]; Vect2f pageSize(common.GetFloatProperty("scaleW", 0, false), common.GetFloatProperty("scaleH", 0, false)); m_fontSize = info.GetFloatProperty( "size", 0, false ); DEBUG_ASSERT( m_fontSize != 0); m_lineHeight = common.GetFloatProperty( "lineHeight", m_fontSize, false ); m_base = common.GetFloatProperty( "base", m_fontSize, false ); CXMLTreeNode pages = font["pages"]; for (int i = 0; i < pages.GetNumChildren(); ++i) { auto page = pages(i); if (page.GetName() == std::string("page")) { std::string texFile = page.GetPszProperty("file", "", false); DEBUG_ASSERT(texFile.size() > 0); texFile = fontPath + texFile; CTexture *tex = new CTexture(); tex->load(texFile, false); tm->add(tex->getName(), tex); m_pages.push_back(tex); } } auto chars = font["chars"]; for (int i = 0; i < chars.GetNumChildren(); ++i) { auto ch = chars(i); if (ch.GetName() != std::string("char")) { continue; } uchar chId = ch.GetIntProperty("id"); CharDesc_t cdesc; cdesc.offset = Vect2f(ch.GetFloatProperty("xoffset", 0, false), ch.GetFloatProperty("yoffset", 0, false)); cdesc.page = ch.GetIntProperty("page"); cdesc.size = Vect2f(ch.GetFloatProperty("width", 0, false), ch.GetFloatProperty("height", 0, false)); cdesc.xAdvance = ch.GetFloatProperty("xadvance", 0, false); cdesc.uvRect.position = Vect2f(ch.GetFloatProperty("x", 0, false), ch.GetFloatProperty("y", 0, false)); cdesc.uvRect.position = Vect2f(cdesc.uvRect.position.x / pageSize.x, cdesc.uvRect.position.y / pageSize.y); cdesc.uvRect.size = Vect2f(cdesc.size.x / pageSize.x, cdesc.size.y / pageSize.y); m_chars[chId] = cdesc; } auto kerns = font["kernings"]; if (kerns.Exists()) { for (int i = 0; i < kerns.GetNumChildren(); ++i) { auto k = kerns(i); uchar f = k.GetIntProperty("first", 0, false); uchar s = k.GetIntProperty("second", 0, false); uchar a = k.GetIntProperty("amount", 0, false); m_kernings[std::make_pair(f, s)] = a; } } m_glyphsVtxs = new CPointsListRenderableVertexs<GUI_TEXT_VERTEX>(m_glyphs.data(), MAX_GLYPHS_BATCH, MAX_GLYPHS_BATCH, true); }
/** * Read the transistor information from the .xml transistor characteristics. * For each transistor size, it extracts the: * - transistor node capacitances * - subthreshold leakage * - gate leakage */ static void process_tech_xml_load_transistor_info(ezxml_t parent) { t_transistor_inf * trans_inf; const char * prop; ezxml_t child, prev, grandchild; int i; /* Get transistor type: NMOS or PMOS */ prop = FindProperty(parent, "type", TRUE); if (strcmp(prop, "nmos") == 0) { trans_inf = &g_power_tech->NMOS_inf; } else if (strcmp(prop, "pmos") == 0) { trans_inf = &g_power_tech->PMOS_inf; } else { assert(0); } ezxml_set_attr(parent, "type", NULL); /* Get long transistor information (W=1,L=2) */ trans_inf->long_trans_inf = (t_transistor_size_inf*) my_malloc( sizeof(t_transistor_size_inf)); child = FindElement(parent, "long_size", TRUE); assert(GetIntProperty(child, "L", TRUE, 0) == 2); trans_inf->long_trans_inf->size = GetFloatProperty(child, "W", TRUE, 0); grandchild = FindElement(child, "leakage_current", TRUE); trans_inf->long_trans_inf->leakage_subthreshold = GetFloatProperty( grandchild, "subthreshold", TRUE, 0); FreeNode(grandchild); grandchild = FindElement(child, "capacitance", TRUE); trans_inf->long_trans_inf->C_g = GetFloatProperty(grandchild, "C_g", TRUE, 0); trans_inf->long_trans_inf->C_d = GetFloatProperty(grandchild, "C_d", TRUE, 0); trans_inf->long_trans_inf->C_s = GetFloatProperty(grandchild, "C_s", TRUE, 0); FreeNode(grandchild); /* Process all transistor sizes */ trans_inf->num_size_entries = CountChildren(parent, "size", 1); trans_inf->size_inf = (t_transistor_size_inf*) my_calloc( trans_inf->num_size_entries, sizeof(t_transistor_size_inf)); FreeNode(child); child = FindFirstElement(parent, "size", TRUE); i = 0; while (child) { assert(GetIntProperty(child, "L", TRUE, 0) == 1); trans_inf->size_inf[i].size = GetFloatProperty(child, "W", TRUE, 0); /* Get leakage currents */ grandchild = FindElement(child, "leakage_current", TRUE); trans_inf->size_inf[i].leakage_subthreshold = GetFloatProperty( grandchild, "subthreshold", TRUE, 0); trans_inf->size_inf[i].leakage_gate = GetFloatProperty(grandchild, "gate", TRUE, 0); FreeNode(grandchild); /* Get node capacitances */ grandchild = FindElement(child, "capacitance", TRUE); trans_inf->size_inf[i].C_g = GetFloatProperty(grandchild, "C_g", TRUE, 0); trans_inf->size_inf[i].C_s = GetFloatProperty(grandchild, "C_s", TRUE, 0); trans_inf->size_inf[i].C_d = GetFloatProperty(grandchild, "C_d", TRUE, 0); FreeNode(grandchild); prev = child; child = child->next; FreeNode(prev); i++; } }
/** * Read short-circuit buffer information from the transistor .xml file. * This contains values for buffers of various 1) # Stages 2) Stage strength 3) Input type & capacitance */ static void power_tech_xml_load_sc(ezxml_t parent) { ezxml_t child, prev, gc, ggc; int i, j, k; int num_buffer_sizes; /* Information for buffers, based on # of stages in buffer */ num_buffer_sizes = CountChildren(parent, "stages", 1); g_power_tech->max_buffer_size = num_buffer_sizes; /* buffer size starts at 1, not 0 */ g_power_tech->buffer_size_inf = (t_power_buffer_size_inf*) my_calloc( g_power_tech->max_buffer_size + 1, sizeof(t_power_buffer_size_inf)); child = FindFirstElement(parent, "stages", TRUE); i = 1; while (child) { t_power_buffer_size_inf * size_inf = &g_power_tech->buffer_size_inf[i]; GetIntProperty(child, "num_stages", TRUE, 1); /* For the given # of stages, find the records for the strength of each stage */ size_inf->num_strengths = CountChildren(child, "strength", 1); size_inf->strength_inf = (t_power_buffer_strength_inf*) my_calloc( size_inf->num_strengths, sizeof(t_power_buffer_strength_inf)); gc = FindFirstElement(child, "strength", TRUE); j = 0; while (gc) { t_power_buffer_strength_inf * strength_inf = &size_inf->strength_inf[j]; /* Get the short circuit factor for a buffer with no level restorer at the input */ strength_inf->stage_gain = GetFloatProperty(gc, "gain", TRUE, 0.0); strength_inf->sc_no_levr = GetFloatProperty(gc, "sc_nolevr", TRUE, 0.0); /* Get the short circuit factor for buffers with level restorers at the input */ strength_inf->num_levr_entries = CountChildren(gc, "input_cap", 1); strength_inf->sc_levr_inf = (t_power_buffer_sc_levr_inf*) my_calloc( strength_inf->num_levr_entries, sizeof(t_power_buffer_sc_levr_inf)); ggc = FindFirstElement(gc, "input_cap", TRUE); k = 0; while (ggc) { t_power_buffer_sc_levr_inf * levr_inf = &strength_inf->sc_levr_inf[k]; /* Short circuit factor is depdent on size of mux that drives the buffer */ levr_inf->mux_size = GetIntProperty(ggc, "mux_size", TRUE, 0); levr_inf->sc_levr = GetFloatProperty(ggc, "sc_levr", TRUE, 0.0); prev = ggc; ggc = ggc->next; FreeNode(prev); k++; } prev = gc; gc = gc->next; FreeNode(prev); j++; } prev = child; child = child->next; FreeNode(prev); i++; } }
void MemoryCardDriverThreaded_MacOSX::GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut ) { LockMut( m_ChangedLock ); // First, get all device paths struct statfs *fs; int num = getfsstat( NULL, 0, MNT_NOWAIT ); fs = new struct statfs[num]; num = getfsstat( fs, num * sizeof(struct statfs), MNT_NOWAIT ); ASSERT( num != -1 ); for( int i = 0; i < num; ++i ) { if( strncmp(fs[i].f_mntfromname, _PATH_DEV, strlen(_PATH_DEV)) ) continue; const RString& sDevicePath = fs[i].f_mntfromname; const RString& sDisk = Basename( sDevicePath ); // disk#[[s#] ...] // Now that we have the disk name, look up the IOServices associated with it. CFMutableDictionaryRef dict; if( !(dict = IOBSDNameMatching(kIOMasterPortDefault, 0, sDisk)) ) continue; // Look for certain properties: Leaf, Ejectable, Writable. CFDictionarySetValue( dict, CFSTR(kIOMediaLeafKey), kCFBooleanTrue ); CFDictionarySetValue( dict, CFSTR(kIOMediaEjectableKey), kCFBooleanTrue ); CFDictionarySetValue( dict, CFSTR(kIOMediaWritableKey), kCFBooleanTrue ); // Get the matching iterator. As always, this consumes a reference to dict. io_iterator_t iter; kern_return_t ret = IOServiceGetMatchingServices( kIOMasterPortDefault, dict, &iter ); if( ret != KERN_SUCCESS || iter == 0 ) continue; // I'm not quite sure what it means to have two services with this device. // Iterate over them all. If one contains what we want, stop. io_registry_entry_t device; // This is the same as an io_object_t. while( (device = IOIteratorNext(iter)) ) { // Look at the parent of the device until we see an IOUSBMassStorageClass while( device != MACH_PORT_NULL && !IOObjectConformsTo(device, "IOUSBMassStorageClass") ) { io_registry_entry_t entry; ret = IORegistryEntryGetParentEntry( device, kIOServicePlane, &entry ); IOObjectRelease( device ); device = ret == KERN_SUCCESS? entry:MACH_PORT_NULL; } // Now look for the corresponding IOUSBDevice, it's likely 2 up the tree while( device != MACH_PORT_NULL && !IOObjectConformsTo(device, "IOUSBDevice") ) { io_registry_entry_t entry; ret = IORegistryEntryGetParentEntry( device, kIOServicePlane, &entry ); IOObjectRelease( device ); device = ret == KERN_SUCCESS? entry:MACH_PORT_NULL; } if( device == MACH_PORT_NULL ) continue; // At this point, it is pretty safe to say that we've found a USB device. vDevicesOut.push_back( UsbStorageDevice() ); UsbStorageDevice& usbd = vDevicesOut.back(); LOG->Trace( "Found memory card at path: %s.", fs[i].f_mntonname ); usbd.SetOsMountDir( fs[i].f_mntonname ); usbd.iVolumeSizeMB = int( (uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20 ); // Now we can get some more information from the registry tree. usbd.iBus = GetIntProperty( device, CFSTR("USB Address") ); usbd.iPort = GetIntProperty( device, CFSTR("PortNum") ); // usbd.iLevel ? usbd.sSerial = GetStringProperty( device, CFSTR("USB Serial Number") ); usbd.sDevice = fs[i].f_mntfromname; usbd.idVendor = GetIntProperty( device, CFSTR(kUSBVendorID) ); usbd.idProduct = GetIntProperty( device, CFSTR(kUSBProductID) ); usbd.sVendor = GetStringProperty( device, CFSTR("USB Vendor Name") ); usbd.sProduct = GetStringProperty( device, CFSTR("USB Product Name") ); IOObjectRelease( device ); break; // We found what we wanted } IOObjectRelease( iter ); } m_bChanged = false; delete[] fs; }
XnPowerLineFrequency XnSensorImageGenerator::GetPowerLineFrequency() { XnUInt64 nFlicker; GetIntProperty(XN_STREAM_PROPERTY_FLICKER, nFlicker); return (XnPowerLineFrequency)nFlicker; }