rpcs3/rpcs3/main.cpp
Megamouse 662fe8cc95 [Qt/Input] Improve pad_settings_dialog a bit (#3611)
* Input: further work on remapping Xinput and begin work on remapping DS4

* Input: Improve pad_settings_dialog a bit and begin Remapping for XInput

* Input: begin evdev remapping and change all handlers to use cfg::string

* Input: finish work on remapping evdev

and some more crap

* Input: finish work on remapping Xinput and DS4

* Input: add DS4 Colors to DS4 config

* Input: Improve DS4 deadzone scaling

Jarves made some mistakes, so I'll fix them in the follow up commit

* Input: fix Jarves fixes on DS4 deadzone

and remove unnecessary usage of toUtf8

* Input: add primitive batterychecks to XInput and DS4

* Input: add mmjoystick remapping

* Input: Fix evdev and some Vibration issues

* Input: adjust capabilities to fix stick input for games like LoS 2

also fix threshold slider minimum
also add ps button to all the handlers

* Input: Further evdev work

based on danilaml code review and own debugging:
Fixed path issue, <= 0 issue, some captures, const, axis with same codes.
Adds a map to each device that differentiates negative and positive axis mappings.
adjusted rest of the file to tabs (ListDevices and beginning of threadProc)

* Input: use 20ms vibration update time for xbox one elite controllers.

* Input: Fix return type of Clamp()

* Input: Evdev Fix

* Input: Evdev Optional GetNextButtonPress

presumably better than the other

* Input: review changes

* Input: evdev: fix wrong index in axis handling

move bindpadtodevice down to keep consistency between handlers and not get crazy

* Input: evdev: fix expensive add_device in GetNextButtonPress

* cleanup

* Input: mmjoy: fix type

* Input: evdev: final fixes

* Input: evdev: exclude unnecessary buttons while mapping Xbox 360 or DS4

* Input: add deadzone preview by passing necessary values in callback

use 0.5 of max value for threshold in pad dialog

* Input: get rid of all-uppercase variables
2017-11-28 01:31:15 +04:00

133 lines
3.1 KiB
C++

// Qt5.2+ frontend implementation for rpcs3. Known to work on Windows, Linux, Mac
// by Sacha Refshauge
#include <QApplication>
#include <QCommandLineParser>
#include <QFileInfo>
#include <QTimer>
#include <QObject>
#include "rpcs3_app.h"
#include "Utilities/sema.h"
#ifdef _WIN32
#include <windows.h>
#endif
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
template <typename... Args>
inline auto tr(Args&&... args)
{
return QObject::tr(std::forward<Args>(args)...);
}
namespace logs
{
void set_init();
}
static semaphore<> s_init{0};
static semaphore<> s_qt_init{0};
static semaphore<> s_qt_mutex{};
[[noreturn]] extern void report_fatal_error(const std::string& text)
{
s_qt_mutex.wait();
if (!s_qt_init.try_wait())
{
s_init.wait();
static int argc = 1;
static char arg1[] = {"ERROR"};
static char* argv[] = {arg1};
static QApplication app0{argc, argv};
}
QMessageBox msg;
msg.setWindowTitle(tr("RPCS3: Fatal Error"));
msg.setIcon(QMessageBox::Critical);
msg.setTextFormat(Qt::RichText);
msg.setText(QString(R"(
<p style="white-space: nowrap;">
%1<br>
%2<br>
<a href='https://github.com/RPCS3/rpcs3/wiki/How-to-ask-for-Support'>https://github.com/RPCS3/rpcs3/wiki/How-to-ask-for-Support</a><br>
%3<br>
</p>
)")
.arg(Qt::convertFromPlainText(QString::fromStdString(text)))
.arg(tr("HOW TO REPORT ERRORS:"))
.arg(tr("Please, don't send incorrect reports. Thanks for understanding.")));
msg.layout()->setSizeConstraint(QLayout::SetFixedSize);
msg.exec();
std::abort();
}
int main(int argc, char** argv)
{
logs::set_init();
#ifdef _WIN32
// use this instead of SetProcessDPIAware if Qt ever fully supports this on windows
// at the moment it can't display QCombobox frames for example
// I think there was an issue with gsframe if I recall correctly, so look out for that
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
SetProcessDPIAware();
timeBeginPeriod(1);
atexit([]
{
timeEndPeriod(1);
});
#else
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
#endif
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
s_init.post();
s_qt_mutex.wait();
rpcs3_app app(argc, argv);
// Command line args
QCommandLineParser parser;
parser.setApplicationDescription("Welcome to RPCS3 command line.");
parser.addPositionalArgument("(S)ELF", "Path for directly executing a (S)ELF");
parser.addPositionalArgument("[Args...]", "Optional args for the executable");
parser.addHelpOption();
parser.parse(QCoreApplication::arguments());
app.Init();
QStringList args = parser.positionalArguments();
if (args.length() > 0)
{
// Propagate command line arguments
std::vector<std::string> argv;
if (args.length() > 1)
{
argv.emplace_back();
for (std::size_t i = 1; i < args.length(); i++)
{
argv.emplace_back(args[i].toStdString());
}
}
// Ugly workaround
QTimer::singleShot(2, [path = sstr(QFileInfo(args.at(0)).canonicalFilePath()), argv = std::move(argv)]() mutable
{
Emu.argv = std::move(argv);
Emu.SetForceBoot(true);
Emu.BootGame(path, true);
});
}
s_qt_init.post();
s_qt_mutex.post();
return app.exec();
}