File: GBAHost.cpp

package info (click to toggle)
dolphin-emu 5.0-17995-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 68,196 kB
  • sloc: cpp: 528,500; ansic: 74,478; sh: 2,477; javascript: 1,773; python: 1,116; makefile: 773; asm: 726; pascal: 257; perl: 97; objc: 75; xml: 4
file content (49 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2021 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "DolphinQt/GBAHost.h"

#include <QApplication>

#include "Core/HW/GBACore.h"
#include "DolphinQt/GBAWidget.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"

GBAHost::GBAHost(std::weak_ptr<HW::GBA::Core> core)
{
  m_widget_controller = new GBAWidgetController();
  m_widget_controller->moveToThread(qApp->thread());
  m_core = std::move(core);
  auto core_ptr = m_core.lock();
  HW::GBA::CoreInfo info = core_ptr->GetCoreInfo();
  QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, core = m_core,
                                      info] { widget_controller->Create(core, info); });
}

GBAHost::~GBAHost()
{
  m_widget_controller->deleteLater();
}

void GBAHost::GameChanged()
{
  auto core_ptr = m_core.lock();
  if (!core_ptr || !core_ptr->IsStarted())
    return;
  HW::GBA::CoreInfo info = core_ptr->GetCoreInfo();
  QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, info] {
    widget_controller->GameChanged(info);
  });
}

void GBAHost::FrameEnded(const std::vector<u32>& video_buffer)
{
  QueueOnObject(m_widget_controller, [widget_controller = m_widget_controller, video_buffer] {
    widget_controller->FrameEnded(video_buffer);
  });
}

std::unique_ptr<GBAHostInterface> Host_CreateGBAHost(std::weak_ptr<HW::GBA::Core> core)
{
  return std::make_unique<GBAHost>(core);
}