input.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. InputSettings::InputSettings(View* parent) : PanelItem(parent, Size{~0, ~0}) {
  2. setCollapsible().setVisible(false);
  3. driverHeader.setText("Input Settings").setFont(Font().setBold());
  4. driverLabel.setText("Driver:");
  5. for(auto& driver : Input::hasDrivers()) {
  6. ComboButtonItem item{&driverOption};
  7. item.setText(driver);
  8. if(driver == settings.input.driver) item.setSelected();
  9. }
  10. driverOption.onChange([&] {
  11. settings.input.driver = driverOption.selected().text();
  12. });
  13. changeButton.setText("Change").onActivate([&] { eventChange(); });
  14. focusLossHeader.setText("Focus Loss").setFont(Font().setBold());
  15. focusPause.setText("Pause emulation").onActivate([&] {
  16. settings.input.unfocused = "Pause";
  17. });
  18. focusBlock.setText("Block input").onActivate([&] {
  19. settings.input.unfocused = "Block";
  20. });
  21. focusAllow.setText("Allow input").onActivate([&] {
  22. settings.input.unfocused = "Allow";
  23. });
  24. if(settings.input.unfocused == "Pause") focusPause.setChecked();
  25. if(settings.input.unfocused == "Block") focusBlock.setChecked();
  26. if(settings.input.unfocused == "Allow") focusAllow.setChecked();
  27. }
  28. auto InputSettings::show() -> void {
  29. setVisible(true);
  30. }
  31. auto InputSettings::hide() -> void {
  32. setVisible(false);
  33. }
  34. auto InputSettings::refresh() -> void {
  35. emulator.inputUpdate();
  36. }
  37. auto InputSettings::eventChange() -> void {
  38. settings.input.driver = driverOption.selected().text();
  39. refresh();
  40. driverHeader.setText({"Input Driver (", settings.input.driver, ")"});
  41. }