emu_window.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-FileCopyrightText: 2014 Citra Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <mutex>
  4. #include "core/frontend/emu_window.h"
  5. namespace Core::Frontend {
  6. EmuWindow::EmuWindow() {
  7. // TODO: Find a better place to set this.
  8. config.min_client_area_size =
  9. std::make_pair(Layout::MinimumSize::Width, Layout::MinimumSize::Height);
  10. active_config = config;
  11. }
  12. EmuWindow::~EmuWindow() {}
  13. std::pair<f32, f32> EmuWindow::MapToTouchScreen(u32 framebuffer_x, u32 framebuffer_y) const {
  14. std::tie(framebuffer_x, framebuffer_y) = ClipToTouchScreen(framebuffer_x, framebuffer_y);
  15. const float x =
  16. static_cast<float>(framebuffer_x - framebuffer_layout.screen.left) /
  17. static_cast<float>(framebuffer_layout.screen.right - framebuffer_layout.screen.left);
  18. const float y =
  19. static_cast<float>(framebuffer_y - framebuffer_layout.screen.top) /
  20. static_cast<float>(framebuffer_layout.screen.bottom - framebuffer_layout.screen.top);
  21. return std::make_pair(x, y);
  22. }
  23. std::pair<u32, u32> EmuWindow::ClipToTouchScreen(u32 new_x, u32 new_y) const {
  24. new_x = std::max(new_x, framebuffer_layout.screen.left);
  25. new_x = std::min(new_x, framebuffer_layout.screen.right - 1);
  26. new_y = std::max(new_y, framebuffer_layout.screen.top);
  27. new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1);
  28. return std::make_pair(new_x, new_y);
  29. }
  30. void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height) {
  31. NotifyFramebufferLayoutChanged(Layout::DefaultFrameLayout(width, height));
  32. }
  33. } // namespace Core::Frontend