emu_window.cpp 1.6 KB

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