public bool sfxAutodetect() { // Get all the available devices. string devices = Util.sfxGetAvailableDevices(); // Collect and sort the devices by preferentiality. int count = Util.getRecordCount(devices); coArrayObject deviceTrySequence = new Torque_Class_Helper("ArrayObject").Create().AsString(); for (int i = 0; i < count; i++) { string info = Util.getRecord(devices, i); string provider = Util.getField(info, 0); deviceTrySequence.push_back(provider, info); } deviceTrySequence.sortfk("sfxCompareProvider"); // Try the devices in order. count = deviceTrySequence.count(); for (int i = 0; i < count; i++) { string provider = deviceTrySequence.getKey(i); string info = deviceTrySequence.getValue(i); sGlobal["$pref::SFX::provider"] = provider; sGlobal["$pref::SFX::device"] = Util.getField(info, 1); sGlobal["$pref::SFX::useHardware"] = Util.getField(info, 2); // By default we've decided to avoid hardware devices as // they are buggy and prone to problems. bGlobal["$pref::SFX::useHardware"] = false; if (!sfxInit()) continue; bGlobal["$pref::SFX::autoDetect"] = false; deviceTrySequence.delete(); return true; } // Found no suitable device. console.error("sfxAutodetect - Could not initialize a valid SFX device."); sGlobal["$pref::SFX::provider"] = ""; sGlobal["$pref::SFX::device"] = ""; sGlobal["$pref::SFX::useHardware"] = ""; deviceTrySequence.delete(); return false; }