Example #1
0
AudioSettings::AudioSettings(TabFrame* parent) : TabFrameItem(parent) {
  setIcon(Icon::Device::Speaker);
  setText("Audio");

  layout.setMargin(5);

  driverLabel.setFont(Font().setBold()).setText("Driver Settings");

  latencyLabel.setText("Latency:");
  latencyCombo.append(ComboButtonItem().setText("0ms"));
  latencyCombo.append(ComboButtonItem().setText("20ms"));
  latencyCombo.append(ComboButtonItem().setText("40ms"));
  latencyCombo.append(ComboButtonItem().setText("60ms"));
  latencyCombo.append(ComboButtonItem().setText("80ms"));
  latencyCombo.append(ComboButtonItem().setText("100ms"));
  switch(settings["Audio/Latency"].natural()) {
  case   0: latencyCombo.item(0)->setSelected(); break;
  case  20: latencyCombo.item(1)->setSelected(); break;
  case  40: latencyCombo.item(2)->setSelected(); break;
  case  60: latencyCombo.item(3)->setSelected(); break;
  case  80: latencyCombo.item(4)->setSelected(); break;
  case 100: latencyCombo.item(5)->setSelected(); break;
  }
  latencyCombo.onChange([&] { updateDriver(); });

  frequencyLabel.setText("Frequency:");
  auto frequencyValue = audio->get(Audio::Frequency).get<uint>(44100);
  frequencyCombo.append(ComboButtonItem().setText({frequencyValue, "hz"}));
  frequencyCombo.setEnabled(false);

  resamplerLabel.setText("Resampler:");
  resamplerCombo.append(ComboButtonItem().setText("IIR - Biquad"));
  resamplerCombo.setEnabled(false);

  exclusiveMode.setText("Exclusive Mode");
  exclusiveMode.setChecked(settings["Audio/Exclusive"].boolean()).onToggle([&] { updateDriver(); });
  if(!audio->cap(Audio::Exclusive)) exclusiveMode.remove();

  effectsLabel.setFont(Font().setBold()).setText("Effects");

  volumeLabel.setText("Volume:");
  volumeValue.setAlignment(0.5);
  volumeSlider.setLength(501).setPosition(settings["Audio/Volume"].natural()).onChange([&] { updateEffects(); });

  balanceLabel.setText("Balance:");
  balanceValue.setAlignment(0.5);
  balanceSlider.setLength(101).setPosition(settings["Audio/Balance"].natural()).onChange([&] { updateEffects(); });

  reverbEnable.setText("Reverb").setChecked(settings["Audio/Reverb/Enable"].boolean()).onToggle([&] { updateEffects(); });

  updateDriver();
  updateEffects();
}
Example #2
0
InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) {
  setIcon(Icon::Device::Joypad);
  setText("Input");

  layout.setMargin(5);
  focusLabel.setText("When Focus is Lost:");
  pauseEmulation.setText("Pause Emulation").setChecked(settings["Input/FocusLoss/Pause"].boolean()).onToggle([&] {
    settings["Input/FocusLoss/Pause"].setValue(pauseEmulation.checked());
    allowInput.setEnabled(!pauseEmulation.checked());
  }).doToggle();
  allowInput.setText("Allow Input").setChecked(settings["Input/FocusLoss/AllowInput"].boolean()).onToggle([&] {
    settings["Input/FocusLoss/AllowInput"].setValue(allowInput.checked());
  });
  for(auto& emulator : inputManager->emulators) {
    emulatorList.append(ComboButtonItem().setText(emulator.name));
  }
  emulatorList.onChange([&] { reloadPorts(); });
  portList.onChange([&] { reloadDevices(); });
  deviceList.onChange([&] { reloadMappings(); });
  mappingList.onActivate([&] { assignMapping(); });
  mappingList.onChange([&] { updateControls(); });
  assignMouse1.setVisible(false).onActivate([&] { assignMouseInput(0); });
  assignMouse2.setVisible(false).onActivate([&] { assignMouseInput(1); });
  assignMouse3.setVisible(false).onActivate([&] { assignMouseInput(2); });
  resetButton.setText("Reset").onActivate([&] {
    if(MessageDialog("Are you sure you want to erase all mappings for this device?").setParent(*settingsManager).question() == "Yes") {
      for(auto& mapping : activeDevice().mappings) mapping->unbind();
      refreshMappings();
    }
  });
  eraseButton.setText("Erase").onActivate([&] {
    if(auto mapping = mappingList.selected()) {
      activeDevice().mappings[mapping->offset()]->unbind();
      refreshMappings();
    }
  });

  reloadPorts();
}