bool CGUIDialogPeripheralManager::OpenSettingsDialog(void) { CGUIDialogPeripheralSettings *dialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS); if (dialog) { dialog->SetFileItem(GetCurrentListItem()); dialog->DoModal(); return true; } return false; }
void CPeripherals::OnSettingAction(const CSetting *setting) { if (setting == NULL) return; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_INPUT_PERIPHERALS) { CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); CFileItemList items; GetDirectory("peripherals://all/", items); int iPos = -1; do { pDialog->Reset(); pDialog->SetHeading(CVariant{35000}); pDialog->SetUseDetails(true); pDialog->SetItems(items); pDialog->SetSelected(iPos); pDialog->Open(); iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedLabel() : -1; if (iPos >= 0) { CFileItemPtr pItem = items.Get(iPos); CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS); if (pItem && pSettingsDialog) { // pass peripheral item properties to settings dialog so skin authors // can use it to show more detailed information about the device pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor")); pSettingsDialog->SetProperty("product", pItem->GetProperty("product")); pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus")); pSettingsDialog->SetProperty("location", pItem->GetProperty("location")); pSettingsDialog->SetProperty("class", pItem->GetProperty("class")); pSettingsDialog->SetProperty("version", pItem->GetProperty("version")); // open settings dialog pSettingsDialog->SetFileItem(pItem.get()); pSettingsDialog->Open(); } } } while (pDialog->IsConfirmed()); } }
void CPeripherals::OnSettingAction(const CSetting *setting) { if (setting == nullptr) return; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_INPUT_PERIPHERALS) { CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); CFileItemList items; GetDirectory("peripherals://all/", items); int iPos = -1; do { pDialog->Reset(); pDialog->SetHeading(CVariant{35000}); pDialog->SetUseDetails(true); pDialog->SetItems(items); pDialog->SetSelected(iPos); pDialog->Open(); iPos = pDialog->IsConfirmed() ? pDialog->GetSelectedItem() : -1; if (iPos >= 0) { CFileItemPtr pItem = items.Get(iPos); // show an error if the peripheral doesn't have any settings PeripheralPtr peripheral = GetByPath(pItem->GetPath()); if (!peripheral || peripheral->GetSettings().empty()) { CGUIDialogOK::ShowAndGetInput(CVariant{35000}, CVariant{35004}); continue; } CGUIDialogPeripheralSettings *pSettingsDialog = (CGUIDialogPeripheralSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_SETTINGS); if (pItem && pSettingsDialog) { // pass peripheral item properties to settings dialog so skin authors // can use it to show more detailed information about the device pSettingsDialog->SetProperty("vendor", pItem->GetProperty("vendor")); pSettingsDialog->SetProperty("product", pItem->GetProperty("product")); pSettingsDialog->SetProperty("bus", pItem->GetProperty("bus")); pSettingsDialog->SetProperty("location", pItem->GetProperty("location")); pSettingsDialog->SetProperty("class", pItem->GetProperty("class")); pSettingsDialog->SetProperty("version", pItem->GetProperty("version")); // open settings dialog pSettingsDialog->SetFileItem(pItem.get()); pSettingsDialog->Open(); } } } while (pDialog->IsConfirmed()); } else if (settingId == CSettings::SETTING_INPUT_CONTROLLERCONFIG) g_windowManager.ActivateWindow(WINDOW_DIALOG_GAME_CONTROLLERS); else if (settingId == CSettings::SETTING_INPUT_TESTRUMBLE) TestFeature(FEATURE_RUMBLE); }