A bit more clang-format
This commit is contained in:
@@ -31,23 +31,22 @@
|
||||
|
||||
#ifdef QT_STATIC
|
||||
/* Static builds need plugin imports */
|
||||
#include <QtPlugin>
|
||||
# include <QtPlugin>
|
||||
Q_IMPORT_PLUGIN(QICOPlugin)
|
||||
#ifdef Q_OS_WINDOWS
|
||||
# ifdef Q_OS_WINDOWS
|
||||
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
|
||||
Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin)
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include "qt_winrawinputfilter.hpp"
|
||||
#include "qt_winmanagerfilter.hpp"
|
||||
#include <86box/win.h>
|
||||
#include <Shobjidl.h>
|
||||
# include "qt_winrawinputfilter.hpp"
|
||||
# include "qt_winmanagerfilter.hpp"
|
||||
# include <86box/win.h>
|
||||
# include <Shobjidl.h>
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/config.h>
|
||||
#include <86box/plat.h>
|
||||
@@ -69,15 +68,15 @@ extern "C"
|
||||
#include "qt_unixmanagerfilter.hpp"
|
||||
|
||||
// Void Cast
|
||||
#define VC(x) const_cast<wchar_t*>(x)
|
||||
#define VC(x) const_cast<wchar_t *>(x)
|
||||
|
||||
extern QElapsedTimer elapsed_timer;
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
extern "C" {
|
||||
#include <86box/timer.h>
|
||||
#include <86box/nvr.h>
|
||||
extern int qt_nvr_save(void);
|
||||
extern int qt_nvr_save(void);
|
||||
}
|
||||
|
||||
void qt_set_sequence_auto_mnemonic(bool b);
|
||||
@@ -86,11 +85,11 @@ void
|
||||
main_thread_fn()
|
||||
{
|
||||
uint64_t old_time, new_time;
|
||||
int drawits, frames;
|
||||
int drawits, frames;
|
||||
|
||||
QThread::currentThread()->setPriority(QThread::HighestPriority);
|
||||
framecountx = 0;
|
||||
//title_update = 1;
|
||||
// title_update = 1;
|
||||
old_time = elapsed_timer.elapsed();
|
||||
drawits = frames = 0;
|
||||
while (!is_quit && cpu_thread_run) {
|
||||
@@ -98,10 +97,10 @@ main_thread_fn()
|
||||
new_time = elapsed_timer.elapsed();
|
||||
#ifdef USE_GDBSTUB
|
||||
if (gdbstub_next_asap && (drawits <= 0))
|
||||
drawits = 10;
|
||||
drawits = 10;
|
||||
else
|
||||
#endif
|
||||
drawits += (new_time - old_time);
|
||||
drawits += (new_time - old_time);
|
||||
old_time = new_time;
|
||||
if (drawits > 0 && !dopause) {
|
||||
/* Yes, so do one frame now. */
|
||||
@@ -117,8 +116,8 @@ main_thread_fn()
|
||||
|
||||
#ifdef USE_INSTRUMENT
|
||||
if (instru_enabled) {
|
||||
uint64_t elapsed_us = (elapsed_timer.nsecsElapsed() - start_time) / 1000;
|
||||
uint64_t total_elapsed_ms = (uint64_t)((double)tsc / cpu_s->rspeed * 1000);
|
||||
uint64_t elapsed_us = (elapsed_timer.nsecsElapsed() - start_time) / 1000;
|
||||
uint64_t total_elapsed_ms = (uint64_t) ((double) tsc / cpu_s->rspeed * 1000);
|
||||
printf("[instrument] %llu, %llu\n", total_elapsed_ms, elapsed_us);
|
||||
if (instru_run_ms && total_elapsed_ms >= instru_run_ms)
|
||||
break;
|
||||
@@ -128,7 +127,7 @@ main_thread_fn()
|
||||
if (++frames >= 200 && nvr_dosave) {
|
||||
qt_nvr_save();
|
||||
nvr_dosave = 0;
|
||||
frames = 0;
|
||||
frames = 0;
|
||||
}
|
||||
} else {
|
||||
/* Just so we dont overload the host OS. */
|
||||
@@ -137,12 +136,14 @@ main_thread_fn()
|
||||
}
|
||||
|
||||
is_quit = 1;
|
||||
QTimer::singleShot(0, QApplication::instance(), [] () { QApplication::instance()->quit(); });
|
||||
QTimer::singleShot(0, QApplication::instance(), []() { QApplication::instance()->quit(); });
|
||||
}
|
||||
|
||||
static std::thread* main_thread;
|
||||
static std::thread *main_thread;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
@@ -168,8 +169,7 @@ int main(int argc, char* argv[]) {
|
||||
#endif
|
||||
elapsed_timer.start();
|
||||
|
||||
if (!pc_init(argc, argv))
|
||||
{
|
||||
if (!pc_init(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -182,16 +182,14 @@ int main(int argc, char* argv[]) {
|
||||
QApplication::setFont(QFont(font_name, font_size.toInt()));
|
||||
SetCurrentProcessExplicitAppUserModelID(L"86Box.86Box");
|
||||
#endif
|
||||
if (! pc_init_modules()) {
|
||||
ui_msgbox_header(MBX_FATAL, (void*)IDS_2121, (void*)IDS_2056);
|
||||
if (!pc_init_modules()) {
|
||||
ui_msgbox_header(MBX_FATAL, (void *) IDS_2121, (void *) IDS_2056);
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (settings_only)
|
||||
{
|
||||
if (settings_only) {
|
||||
Settings settings;
|
||||
if (settings.exec() == QDialog::Accepted)
|
||||
{
|
||||
if (settings.exec() == QDialog::Accepted) {
|
||||
settings.save();
|
||||
config_save();
|
||||
}
|
||||
@@ -212,22 +210,21 @@ int main(int argc, char* argv[]) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
/* Setup VM-manager messages */
|
||||
std::unique_ptr<WindowsManagerFilter> wmfilter;
|
||||
if (source_hwnd)
|
||||
{
|
||||
HWND main_hwnd = (HWND)main_window->winId();
|
||||
if (source_hwnd) {
|
||||
HWND main_hwnd = (HWND) main_window->winId();
|
||||
|
||||
wmfilter.reset(new WindowsManagerFilter());
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::showsettings, main_window, &MainWindow::showSettings);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::pause, main_window, &MainWindow::togglePause);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::reset, main_window, &MainWindow::hardReset);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::request_shutdown, main_window, &MainWindow::close);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::force_shutdown, [](){
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::force_shutdown, []() {
|
||||
do_stop();
|
||||
emit main_window->close();
|
||||
});
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::ctrlaltdel, [](){ pc_send_cad(); });
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::dialogstatus, [main_hwnd](bool open){
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDDLGSTATUS, (WPARAM)(open ? 1 : 0), (LPARAM)main_hwnd);
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::ctrlaltdel, []() { pc_send_cad(); });
|
||||
QObject::connect(wmfilter.get(), &WindowsManagerFilter::dialogstatus, [main_hwnd](bool open) {
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDDLGSTATUS, (WPARAM) (open ? 1 : 0), (LPARAM) main_hwnd);
|
||||
});
|
||||
|
||||
/* Native filter to catch VM-managers commands */
|
||||
@@ -237,41 +234,39 @@ int main(int argc, char* argv[]) {
|
||||
main_window->installEventFilter(wmfilter.get());
|
||||
|
||||
/* Send main window HWND to manager */
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_SENDHWND, (WPARAM)unique_id, (LPARAM)main_hwnd);
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_SENDHWND, (WPARAM) unique_id, (LPARAM) main_hwnd);
|
||||
|
||||
/* Send shutdown message to manager */
|
||||
QObject::connect(&app, &QApplication::destroyed, [main_hwnd](QObject*) {
|
||||
PostMessage((HWND)(uintptr_t)source_hwnd, WM_HAS_SHUTDOWN, (WPARAM)0, (LPARAM)main_hwnd);
|
||||
QObject::connect(&app, &QApplication::destroyed, [main_hwnd](QObject *) {
|
||||
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) main_hwnd);
|
||||
});
|
||||
}
|
||||
|
||||
/* Setup raw input */
|
||||
auto rawInputFilter = WindowsRawInputFilter::Register(main_window);
|
||||
if (rawInputFilter)
|
||||
{
|
||||
if (rawInputFilter) {
|
||||
app.installNativeEventFilter(rawInputFilter.get());
|
||||
QObject::disconnect(main_window, &MainWindow::pollMouse, 0, 0);
|
||||
QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter*)rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection);
|
||||
QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter *) rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection);
|
||||
main_window->setSendKeyboardInput(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
UnixManagerSocket socket;
|
||||
if (qgetenv("86BOX_MANAGER_SOCKET").size())
|
||||
{
|
||||
if (qgetenv("86BOX_MANAGER_SOCKET").size()) {
|
||||
QObject::connect(&socket, &UnixManagerSocket::showsettings, main_window, &MainWindow::showSettings);
|
||||
QObject::connect(&socket, &UnixManagerSocket::pause, main_window, &MainWindow::togglePause);
|
||||
QObject::connect(&socket, &UnixManagerSocket::resetVM, main_window, &MainWindow::hardReset);
|
||||
QObject::connect(&socket, &UnixManagerSocket::request_shutdown, main_window, &MainWindow::close);
|
||||
QObject::connect(&socket, &UnixManagerSocket::force_shutdown, [](){
|
||||
QObject::connect(&socket, &UnixManagerSocket::force_shutdown, []() {
|
||||
do_stop();
|
||||
emit main_window->close();
|
||||
});
|
||||
QObject::connect(&socket, &UnixManagerSocket::ctrlaltdel, [](){ pc_send_cad(); });
|
||||
QObject::connect(&socket, &UnixManagerSocket::ctrlaltdel, []() { pc_send_cad(); });
|
||||
main_window->installEventFilter(&socket);
|
||||
socket.connectToServer(qgetenv("86BOX_MANAGER_SOCKET"));
|
||||
}
|
||||
//pc_reset_hard_init();
|
||||
// pc_reset_hard_init();
|
||||
|
||||
/* Set the PAUSE mode depending on the renderer. */
|
||||
// plat_pause(0);
|
||||
@@ -297,13 +292,12 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
/* Initialize the rendering window, or fullscreen. */
|
||||
QTimer::singleShot(0, &app, []
|
||||
{
|
||||
QTimer::singleShot(0, &app, [] {
|
||||
pc_reset_hard_init();
|
||||
main_thread = new std::thread(main_thread_fn);
|
||||
});
|
||||
|
||||
auto ret = app.exec();
|
||||
auto ret = app.exec();
|
||||
cpu_thread_run = 0;
|
||||
main_thread->join();
|
||||
pc_close(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user