本文整理汇总了C++中OSBoolean::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ OSBoolean::getValue方法的具体用法?C++ OSBoolean::getValue怎么用?C++ OSBoolean::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSBoolean
的用法示例。
在下文中一共展示了OSBoolean::getValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadConfiguration
void SuperIO::LoadConfiguration(IOService* provider) {
m_Service = provider;
OSBoolean* fanControl = OSDynamicCast(OSBoolean, provider->getProperty("Enable Fan Control"));
m_FanControl = fanControl->getValue();
OSBoolean* alternateRegisters = OSDynamicCast(OSBoolean, provider->getProperty("Register number alternative variant"));
m_AlternateRegisters = alternateRegisters->getValue();
OSArray* fanIDs = OSDynamicCast(OSArray, provider->getProperty("Fan Names"));
if (fanIDs) fanIDs = OSArray::withArray(fanIDs);
if (fanIDs) {
UInt32 count = fanIDs->getCount();
if(count > 5)
count = 5;
for (UInt32 i = 0; i < count; i++) {
OSString* name = OSDynamicCast(OSString, fanIDs->getObject(i));
FanName[i] = name->getCStringNoCopy();
}
fanIDs->release();
}
}
示例2: OSDynamicCast
// GetPlistValue
UInt32
VoodooPState::getPlistValue(OSDictionary * dictionary,
const char * symbol)
{
OSObject * object = 0;
OSBoolean * boolean = false;
OSNumber * number = 0;
OSString * string = 0;
object = dictionary->getObject(symbol);
if (object && (OSTypeIDInst(object) == OSTypeID(OSBoolean)))
{
boolean = OSDynamicCast(OSBoolean, object);
return boolean->getValue();
}
if (object && (OSTypeIDInst(object) == OSTypeID(OSNumber)))
{
number = OSDynamicCast(OSNumber, object);
return number->unsigned32BitValue();
}
if (object && (OSTypeIDInst(object) == OSTypeID(OSString)))
{
string = OSDynamicCast(OSString, object);
// Implement string to number conversion
}
return 0;
}
示例3: checkACStatusThread
static void checkACStatusThread(thread_call_param_t param0,
thread_call_param_t param1)
{
int i=0;
const int retryTimes = 10;
while (!isStatusThreadCanCancel && i<retryTimes) {
if(NULL == commmonBatteryDevice)
{
IOLog("Can't find battery device, retry %d...\n", retryTimes-i);
commmonBatteryDevice = getBatteryDevice();
IOSleep(3000);
i++;
continue;
}
OSObject * obj = commmonBatteryDevice->getProperty("ExternalConnected");
OSBoolean * status = OSDynamicCast(OSBoolean, obj);
if (!status)
{
IOLog("Battery status get failed.\n");
break;
}
if(ACStatusChangedCallback)
{
bool batStatus = status->getValue();
if(batStatus != ACStatus)
{
//IOLog("Battery status changed.\n");
ACStatus = batStatus;
ACStatusChangedCallback(batStatus);
}
}
else
ACStatus = status->getValue();
IOSleep(ACStatus?1000:5000);//1s=1000ms
}
if(i == 10)
IOLog("Can't find battery device, exit.\n");
else
IOLog("Battery thread cancelled.\n");
isStatusThreadCancelled = true;
}
示例4: getACStatus
bool ACPIBacklightPanel::getACStatus()
{
DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
IOService * batteryDevice = getBatteryDevice();
if (NULL != batteryDevice)
{
OSObject * obj = batteryDevice->getProperty("ExternalConnected");
OSBoolean * status = OSDynamicCast(OSBoolean, obj);
if (status)
{
DbgLog("%s: getACStatus() AC is %d\n", this->getName(), status->getValue());
return status->getValue();
}
else
DbgLog("%s: getACStatus() unable to get \"ExternalConnected\" property\n", this->getName());
}
return true;
}
示例5: OSDynamicCast
// Read the settings from the registry
void Xbox360Peripheral::readSettings(void)
{
OSBoolean *value = NULL;
OSNumber *number = NULL;
OSDictionary *dataDictionary = OSDynamicCast(OSDictionary, getProperty(kDriverSettingKey));
if (dataDictionary == NULL) return;
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftX"));
if (value != NULL) invertLeftX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftY"));
if (value != NULL) invertLeftY = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightX"));
if (value != NULL) invertRightX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightY"));
if (value != NULL) invertRightY = value->getValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneLeft"));
if (number != NULL) deadzoneLeft = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneRight"));
if (number != NULL) deadzoneRight = number->unsigned32BitValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeLeft"));
if (value != NULL) relativeLeft = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeRight"));
if (value != NULL) relativeRight=value->getValue();
#if 0
IOLog("Xbox360Peripheral preferences loaded:\n invertLeft X: %s, Y: %s\n invertRight X: %s, Y:%s\n deadzone Left: %d, Right: %d\n\n",
invertLeftX?"True":"False",invertLeftY?"True":"False",
invertRightX?"True":"False",invertRightY?"True":"False",
deadzoneLeft,deadzoneRight);
#endif
}
示例6: getACStatus
bool getACStatus()
{
IOService * batteryDevice = getBatteryDevice();
if (NULL != batteryDevice)
{
OSObject * obj = batteryDevice->getProperty("ExternalConnected");
OSBoolean * status = OSDynamicCast(OSBoolean, obj);
if (status)
return status->getValue();
}
return true;
}
示例7: init
//==============================================================================
// USB Stuff (Mainly...)
//==============================================================================
bool com_milvich_driver_Thrustmaster::init(OSDictionary *properties)
{
IOLog("%s: init\n", NAME);
if(!super::init(properties))
{
return false;
}
fIface = NULL;
fPipe = NULL;
fBuffer = NULL;
fOutstandingIOOps = 0;
fNeedToClose = false;
fFinishedInit = false;
for(unsigned int i = 0; i < sizeof(fControlData); i++)
{
fControlData[i] = 0;
}
OSBoolean *result;
int count;
// create the buffer for the reports
fReport = IOBufferMemoryDescriptor::withCapacity(kReportSize, kIODirectionOutIn, true);
if(!fReport)
{
IOLog("%s: Failed to create the MemoryDescriptor for our report\n", NAME);
return false;
}
// I need to know this info to create the device descriptor, but I can't
// dynamicly look this up until I finish initing the iMate, but that blocks...
// So we be stupid and just read from a config file.
fHasRudders = false;
fHasThrottle = true;
result = OSDynamicCast(OSBoolean, getProperty("HasRudder"));
if(result)
{
fHasRudders = result->getValue();
}
result = OSDynamicCast(OSBoolean, getProperty("HasThrottle"));
if(result)
{
fHasThrottle = result->getValue();
}
// check to see if the rocker switch should act as a modifier
if(fHasThrottle)
{
result = OSDynamicCast(OSBoolean, getProperty("RockerIsModifier"));
if(!result)
{
IOLog("%s: Failed to find an entry for RockerIsModifier, assuming false.\n", NAME);
fRockerIsModifier = false;
}
else
{
fRockerIsModifier = result->getValue();
}
}
else
{
fRockerIsModifier = false;
}
// setup buttons
if(fHasThrottle)
{
count = kNumOfButtons;
}
else
{
count = kNumOfFCSButtons;
}
OSArray *buttonArray = OSDynamicCast(OSArray, getProperty("Buttons"));
if(fRockerIsModifier && buttonArray)
{
for(int i = 0; i < count; i++)
{
result = OSDynamicCast(OSBoolean, buttonArray->getObject(i));
if(result && result->getValue())
{
for(int j = 0; j < kNumModifiers; j++)
{
fButtonShifts[i * kNumModifiers + j] = fNumButtons;
fNumButtons++;
}
}
else
{
for(int j = 0; j < kNumModifiers; j++)
{
fButtonShifts[i * kNumModifiers + j] = fNumButtons;
}
fNumButtons++;
//.........这里部分代码省略.........
示例8: OSDynamicCast
// Read the settings from the registry
void Xbox360Peripheral::readSettings(void)
{
OSBoolean *value = NULL;
OSNumber *number = NULL;
OSDictionary *dataDictionary = OSDynamicCast(OSDictionary, getProperty(kDriverSettingKey));
if (dataDictionary == NULL) return;
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftX"));
if (value != NULL) invertLeftX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftY"));
if (value != NULL) invertLeftY = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightX"));
if (value != NULL) invertRightX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightY"));
if (value != NULL) invertRightY = value->getValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneLeft"));
if (number != NULL) deadzoneLeft = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneRight"));
if (number != NULL) deadzoneRight = number->unsigned32BitValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeLeft"));
if (value != NULL) relativeLeft = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeRight"));
if (value != NULL) relativeRight=value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("DeadOffLeft"));
if (value != NULL) deadOffLeft = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("DeadOffRight"));
if (value != NULL) deadOffRight = value->getValue();
// number = OSDynamicCast(OSNumber, dataDictionary->getObject("ControllerType")); // No use currently.
number = OSDynamicCast(OSNumber, dataDictionary->getObject("rumbleType"));
if (number != NULL) rumbleType = number->unsigned8BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingUp"));
if (number != NULL) mapping[0] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingDown"));
if (number != NULL) mapping[1] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingLeft"));
if (number != NULL) mapping[2] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingRight"));
if (number != NULL) mapping[3] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingStart"));
if (number != NULL) mapping[4] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingBack"));
if (number != NULL) mapping[5] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingLSC"));
if (number != NULL) mapping[6] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingRSC"));
if (number != NULL) mapping[7] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingLB"));
if (number != NULL) mapping[8] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingRB"));
if (number != NULL) mapping[9] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingGuide"));
if (number != NULL) mapping[10] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingA"));
if (number != NULL) mapping[11] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingB"));
if (number != NULL) mapping[12] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingX"));
if (number != NULL) mapping[13] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingY"));
if (number != NULL) mapping[14] = number->unsigned32BitValue();
#if 0
IOLog("Xbox360Peripheral preferences loaded:\n invertLeft X: %s, Y: %s\n invertRight X: %s, Y:%s\n deadzone Left: %d, Right: %d\n\n",
invertLeftX?"True":"False",invertLeftY?"True":"False",
invertRightX?"True":"False",invertRightY?"True":"False",
deadzoneLeft,deadzoneRight);
#endif
}
示例9: init
bool com_reidburke_air_IntelEnhancedSpeedStep::init(OSDictionary* dict) {
bool res = super::init(dict);
info("Initializing xnu-speedstep-air\n");
// read data
cpuid_update_generic_info();
/* Allocate our spinlock for later use */
Lock = IOSimpleLockAlloc();
/* Check for a patched kernel which properly implements rtc_clock_stepped() */
uint64_t magic = -1; // means autodetect
OSBoolean* debugMsgs = (OSBoolean*) dict->getObject("DebugMessages");
if (debugMsgs != 0)
DebugOn = debugMsgs->getValue();
else
DebugOn = false;
OSNumber* kernelFeatures = (OSNumber*) dict->getObject("KernelFeatures");
if (kernelFeatures != 0)
magic = kernelFeatures->unsigned8BitValue();
if (magic == 255) nanoseconds_to_absolutetime(~(0), &magic); //255uint = -1 int
if (magic == 1) {
RtcFixKernel = true;
Below1Ghz = false;
} else if (magic == 2) {
RtcFixKernel = true;
Below1Ghz = true;
} else if (magic == 3) {
RtcFixKernel = false;
Below1Ghz = true;
} else {
RtcFixKernel = false;
Below1Ghz = false;
}
checkForNby2Ratio(); // check and store in global variable before loading pstate override
if (getFSB() == false)
return false;
OSArray* overrideTable = (OSArray*) dict->getObject("PStateTable");
if (overrideTable != 0 )
loadPStateOverride(overrideTable);
OSNumber* defaultState = (OSNumber*) dict->getObject("DefaultPState");
if (defaultState != 0)
DefaultPState = defaultState->unsigned8BitValue();
else
DefaultPState = -1; // indicate no default state
OSNumber* maxLatency = (OSNumber*) dict->getObject("Latency");
if (maxLatency != 0)
MaxLatency = maxLatency->unsigned32BitValue();
else
MaxLatency = 0;
/* Make preliminary check */
if ( (strcmp(cpuid_info()->cpuid_vendor, CPUID_VID_INTEL) == 0) // Check it's actually Intel
&& ( cpuid_info()->cpuid_features & CPUID_FEATURE_EST) ) { // Check it supports EST
autostart = (OSNumber*) dict->getObject("AutoStart");
info( "do autostart %d \n", autostart->unsigned8BitValue() );
if ( autostart != 0 && autostart->unsigned8BitValue() == 1 ) {
Throttler = new AutoThrottler;
if (Throttler) {
dbg("Throttler instantiated.\n");
OSNumber* targetload = (OSNumber*) dict->getObject("TargetCPULoad");
if (targetload != 0)
Throttler->targetCPULoad = (targetload->unsigned16BitValue()) * 10;
else
Throttler->targetCPULoad = 700;
}
}
}
totalThrottles = 0;
frequencyUsage[0] = '\0';
/* Return whatever the superclass returned */
return res;
}
示例10: start
bool RadeonController::start( IOService * provider )
{
if (!super::start(provider)) return false;
device = OSDynamicCast(IOPCIDevice, provider);
if (device == NULL) return false;
//get user options
OSBoolean *prop;
OSDictionary *dict = OSDynamicCast(OSDictionary, getProperty("UserOptions"));
bzero(&options, sizeof(UserOptions));
options.HWCursorSupport = FALSE;
options.enableGammaTable = FALSE;
options.enableOSXI2C = FALSE;
options.lowPowerMode = FALSE;
if (dict) {
prop = OSDynamicCast(OSBoolean, dict->getObject("enableHWCursor"));
if (prop) options.HWCursorSupport = prop->getValue();
prop = OSDynamicCast(OSBoolean, dict->getObject("debugMode"));
if (prop) options.debugMode = prop->getValue();
if (options.debugMode) options.HWCursorSupport = FALSE;
prop = OSDynamicCast(OSBoolean, dict->getObject("enableGammaTable"));
if (prop) options.enableGammaTable = prop->getValue();
prop = OSDynamicCast(OSBoolean, dict->getObject("lowPowerMode"));
if (prop) options.lowPowerMode = prop->getValue();
}
options.verbosity = 1;
#ifdef DEBUG
if (0 == getRegistryRoot()->getProperty("RadeonDumpReady")) {
getRegistryRoot()->setProperty("RadeonDumpReady", kOSBooleanTrue);
DumpMsg.mVerbose = 1;
DumpMsg.client = 1;
DumpMsg.mMsgBufferSize = 65535;
if (dict) {
OSNumber *optionNum;
optionNum = OSDynamicCast(OSNumber, dict->getObject("verboseLevel"));
if (optionNum) DumpMsg.mVerbose = optionNum->unsigned32BitValue();
optionNum = OSDynamicCast(OSNumber, dict->getObject("MsgBufferSize"));
if (optionNum) DumpMsg.mMsgBufferSize = max(65535, optionNum->unsigned32BitValue());
}
DumpMsg.mMsgBufferEnabled = false;
DumpMsg.mMsgBufferPos = 0;
DumpMsg.mMessageLock = IOLockAlloc();
DumpMsg.mMsgBuffer = (char *) IOMalloc(DumpMsg.mMsgBufferSize);
if (!DumpMsg.mMsgBuffer) {
IOLog("error: couldn't allocate message buffer (%ld bytes)\n", DumpMsg.mMsgBufferSize);
return false;
}
enableMsgBuffer(true);
} else DumpMsg.client += 1;
options.verbosity = DumpMsg.mVerbose;
#endif
device->setMemoryEnable(true);
IOMap = device->mapDeviceMemoryWithRegister( kIOPCIConfigBaseAddress2 );
if (IOMap == NULL) return false;
FBMap = device->mapDeviceMemoryWithRegister( kIOPCIConfigBaseAddress0 );
if (FBMap == NULL) return false;
memoryMap.MMIOBase = (pointer) IOMap->getVirtualAddress();
memoryMap.MMIOMapSize = IOMap->getLength();
memoryMap.FbBase = (pointer) FBMap->getVirtualAddress();
memoryMap.FbMapSize = FBMap->getLength();
memoryMap.FbPhysBase = (unsigned long)FBMap->getPhysicalAddress();
memoryMap.bitsPerPixel = 32;
memoryMap.bitsPerComponent = 8;
memoryMap.colorFormat = 0; //0 for non-64 bit
memoryMap.BIOSCopy = NULL;
memoryMap.BIOSLength = 0;
IOMemoryDescriptor * mem;
mem = IOMemoryDescriptor::withPhysicalAddress((IOPhysicalAddress) RHD_VBIOS_BASE, RHD_VBIOS_SIZE, kIODirectionOut);
if (mem) {
memoryMap.BIOSCopy = (unsigned char *)IOMalloc(RHD_VBIOS_SIZE);
if (memoryMap.BIOSCopy) {
mem->prepare(kIODirectionOut);
if (!(memoryMap.BIOSLength = mem->readBytes(0, memoryMap.BIOSCopy, RHD_VBIOS_SIZE))) {
LOG("Cannot read BIOS image\n");
memoryMap.BIOSLength = 0;
}
if ((unsigned int)memoryMap.BIOSLength != RHD_VBIOS_SIZE)
LOG("Read only %d of %d bytes of BIOS image\n", memoryMap.BIOSLength, RHD_VBIOS_SIZE);
mem->complete(kIODirectionOut);
}
}
if (dict) {
const char typeKey[2][8] = {"@0,TYPE", "@1,TYPE"};
const char EDIDKey[2][8] = {"@0,EDID", "@1,EDID"};
const char fixedModesKey[2][17] = {"@0,UseFixedModes", "@1,UseFixedModes"};
OSString *type;
OSData *edidData;
OSBoolean *boolData;
int i;
for (i = 0;i < 2;i++) {
type = OSDynamicCast(OSString, dict->getObject(typeKey[i]));
if (!type) continue;
//.........这里部分代码省略.........
示例11: OSDynamicCast
// Read the settings from the registry
void Wireless360Controller::readSettings(void)
{
OSBoolean *value;
OSNumber *number;
OSDictionary *dataDictionary = OSDynamicCast(OSDictionary, getProperty(kDriverSettingKey));
if(dataDictionary==NULL) return;
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftX"));
if (value != NULL) invertLeftX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftY"));
if (value != NULL) invertLeftY = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightX"));
if (value != NULL) invertRightX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightY"));
if (value != NULL) invertRightY = value->getValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneLeft"));
if (number != NULL) deadzoneLeft = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneRight"));
if (number != NULL) deadzoneRight = number->unsigned32BitValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeLeft"));
if (value != NULL) relativeLeft = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeRight"));
if (value != NULL) relativeRight=value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("DeadOffLeft"));
if (value != NULL) deadOffLeft = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("DeadOffRight"));
if (value != NULL) deadOffRight = value->getValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("RumbleType"));
if (number != NULL) rumbleType = number->unsigned8BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingUp"));
if (number != NULL) mapping[0] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingDown"));
if (number != NULL) mapping[1] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingLeft"));
if (number != NULL) mapping[2] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingRight"));
if (number != NULL) mapping[3] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingStart"));
if (number != NULL) mapping[4] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingBack"));
if (number != NULL) mapping[5] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingLSC"));
if (number != NULL) mapping[6] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingRSC"));
if (number != NULL) mapping[7] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingLB"));
if (number != NULL) mapping[8] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingRB"));
if (number != NULL) mapping[9] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingGuide"));
if (number != NULL) mapping[10] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingA"));
if (number != NULL) mapping[11] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingB"));
if (number != NULL) mapping[12] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingX"));
if (number != NULL) mapping[13] = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("BindingY"));
if (number != NULL) mapping[14] = number->unsigned32BitValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("SwapSticks"));
if (value != NULL) swapSticks = value->getValue();
noMapping = true;
UInt8 normalMapping[15] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15 };
for (int i = 0; i < 15; i++)
{
if (normalMapping[i] != mapping[i])
{
noMapping = false;
break;
}
}
#if 0
IOLog("Xbox360ControllerClass preferences loaded:\n invertLeft X: %s, Y: %s\n invertRight X: %s, Y:%s\n deadzone Left: %d, Right: %d\n\n",
invertLeftX?"True":"False",invertLeftY?"True":"False",
invertRightX?"True":"False",invertRightY?"True":"False",
deadzoneLeft,deadzoneRight);
#endif
}
示例12: createAudioStreams
bool PhantomAudioEngine::createAudioStreams(IOAudioSampleRate *initialSampleRate)
{
bool result = false;
OSNumber *number;
UInt32 numStreams, streamNum;
OSArray *formatArray, *sampleRateArray;
UInt32 startingChannelID = 1;
IOAudioControl *control;
OSString *desc;
OSBoolean *boolean;
bool separateStreamBuffers = FALSE, separateInputBuffers = FALSE;
desc = OSDynamicCast(OSString, getProperty(DESCRIPTION_KEY));
if (desc) {
setDescription(desc->getCStringNoCopy());
}
number = OSDynamicCast(OSNumber, getProperty(NUM_STREAMS_KEY));
if (number) {
numStreams = number->unsigned32BitValue();
} else {
numStreams = NUM_STREAMS;
}
formatArray = OSDynamicCast(OSArray, getProperty(FORMATS_KEY));
if (formatArray == NULL) {
goto Done;
}
sampleRateArray = OSDynamicCast(OSArray, getProperty(SAMPLE_RATES_KEY));
if (sampleRateArray == NULL) {
goto Done;
}
boolean = OSDynamicCast(OSBoolean, getProperty(SEPARATE_STREAM_BUFFERS_KEY));
if (boolean != NULL) {
separateStreamBuffers = boolean->getValue();
}
boolean = OSDynamicCast(OSBoolean, getProperty(SEPARATE_INPUT_BUFFERS_KEY));
if (boolean != NULL) {
separateInputBuffers = boolean->getValue();
}
if (separateStreamBuffers) {
IOLog("PhantomAudioEngine::createAudioStreams() - Creating a separate buffer for each stream.\n");
} else {
IOLog("PhantomAudioEngine::createAudioStreams() - Sharing one buffer among all streams.\n");
}
if (separateInputBuffers) {
IOLog("PhantomAudioEngine::createAudioStreams() - Creating separate buffers for input and output.\n");
} else {
IOLog("PhantomAudioEngine::createAudioStreams() - Sharing input and output buffers.\n");
}
for (streamNum = 0; streamNum < numStreams; streamNum++) {
IOAudioStream *inputStream = NULL, *outputStream = NULL;
UInt32 maxBitWidth = 0;
UInt32 maxNumChannels = 0;
OSCollectionIterator *formatIterator = NULL, *sampleRateIterator = NULL;
OSDictionary *formatDict;
IOAudioSampleRate sampleRate;
IOAudioStreamFormat initialFormat;
bool initialFormatSet;
UInt32 channelID;
char outputStreamName[20], inputStreamName[20];
UInt32 streamBufferSize;
initialFormatSet = false;
sampleRate.whole = 0;
sampleRate.fraction = 0;
inputStream = new IOAudioStream;
if (inputStream == NULL) {
goto Error;
}
outputStream = new IOAudioStream;
if (outputStream == NULL) {
goto Error;
}
sprintf(inputStreamName, "Input Stream #%ld", streamNum + 1);
sprintf(outputStreamName, "Output Stream #%ld", streamNum + 1);
if (!inputStream->initWithAudioEngine(this, kIOAudioStreamDirectionInput, startingChannelID, inputStreamName) ||
!outputStream->initWithAudioEngine(this, kIOAudioStreamDirectionOutput, startingChannelID, outputStreamName)) {
goto Error;
}
formatIterator = OSCollectionIterator::withCollection(formatArray);
if (!formatIterator) {
goto Error;
}
sampleRateIterator = OSCollectionIterator::withCollection(sampleRateArray);
if (!sampleRateIterator) {
goto Error;
//.........这里部分代码省略.........
示例13: start
bool ACPIProbe::start(IOService * provider)
{
ACPISensorsDebugLog("starting...");
if (!super::start(provider))
return false;
if (!(acpiDevice = OSDynamicCast(IOACPIPlatformDevice, provider))) {
ACPISensorsFatalLog("ACPI device not ready");
return false;
}
profiles = OSDictionary::withCapacity(0);
profileList = OSArray::withCapacity(0);
OSObject *object = NULL;
// Try to load configuration provided by ACPI device
if (kIOReturnSuccess == acpiDevice->evaluateObject("LIST", &object) && object) {
if (OSArray *list = OSDynamicCast(OSArray, object)) {
for (unsigned int i = 0; i < list->getCount(); i++) {
if (OSString *method = OSDynamicCast(OSString, list->getObject(i))) {
if (kIOReturnSuccess == acpiDevice->evaluateObject(method->getCStringNoCopy(), &object) && object) {
if (OSArray *config = OSDynamicCast(OSArray, object)) {
if (config->getCount() > 4) {
OSString *pName = OSDynamicCast(OSString, config->getObject(0));
OSNumber *pInterval = OSDynamicCast(OSNumber, config->getObject(1));
OSNumber *pTimeout = OSDynamicCast(OSNumber, config->getObject(2));
OSNumber *pVerbose = OSDynamicCast(OSNumber, config->getObject(3));
OSArray *pMethods = OSArray::withCapacity(config->getCount() - 4);
for (unsigned int offset = 4; offset < config->getCount(); offset++) {
if (OSString *methodName = OSDynamicCast(OSString, config->getObject(offset))) {
pMethods->setObject(methodName);
}
}
addProfile(pName, pMethods, pInterval, pTimeout, pVerbose);
}
}
OSSafeRelease(object);
}
}
}
OSSafeRelease(list);
}
}
else {
ACPISensorsErrorLog("profile definition table (LIST) not found");
}
// Try to load configuration from info.plist
if (profiles->getCount() == 0) {
if (OSDictionary *configuration = getConfigurationNode())
{
OSString *pName = OSDynamicCast(OSString, configuration->getObject("ProfileName"));
OSNumber *pInterval = OSDynamicCast(OSNumber, configuration->getObject("PollingInterval"));
OSNumber *pTimeout = OSDynamicCast(OSNumber, configuration->getObject("PollingTimeout"));
OSBoolean *pVerboseBool = OSDynamicCast(OSBoolean, configuration->getObject("VerboseLog"));
OSNumber *pVerbose = OSNumber::withNumber(pVerboseBool->getValue() ? 1 : 0, 8);
OSArray *pMethods = OSDynamicCast(OSArray, configuration->getObject("MethodsToPoll"));
addProfile(pName, pMethods, pInterval, pTimeout, pVerbose);
}
}
if (this->profiles->getCount()) {
// Parse active profile
if (kIOReturnSuccess == acpiDevice->evaluateObject("ACTV", &object) && object) {
if (OSString *method = OSDynamicCast(OSString, object)) {
if (kIOReturnSuccess == acpiDevice->evaluateObject(method->getCStringNoCopy(), &object) && object) {
if (OSArray *config = OSDynamicCast(OSArray, object)) {
if (config->getCount() > 4) {
if (OSString *profile = OSDynamicCast(OSString, config->getObject(0))) {
if (!(activeProfile = (ACPIProbeProfile *)profiles->getObject(profile))) {
activeProfile = (ACPIProbeProfile *)profileList->getObject(0);
}
}
}
}
OSSafeRelease(object);
}
OSSafeRelease(method);
}
}
// woorkloop
if (!(workloop = getWorkLoop())) {
HWSensorsFatalLog("Failed to obtain workloop");
return false;
}
//.........这里部分代码省略.........