|
|
|
|
@ -48,6 +48,7 @@
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <condition_variable>
|
|
|
|
|
#include <csignal>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
|
|
LOG_CHANNEL(Host);
|
|
|
|
|
@ -57,8 +58,8 @@ namespace MiniHost {
|
|
|
|
|
/// Use two async worker threads, should be enough for most tasks.
|
|
|
|
|
static constexpr u32 NUM_ASYNC_WORKER_THREADS = 2;
|
|
|
|
|
|
|
|
|
|
//static constexpr u32 DEFAULT_WINDOW_WIDTH = 1280;
|
|
|
|
|
//static constexpr u32 DEFAULT_WINDOW_HEIGHT = 720;
|
|
|
|
|
// static constexpr u32 DEFAULT_WINDOW_WIDTH = 1280;
|
|
|
|
|
// static constexpr u32 DEFAULT_WINDOW_HEIGHT = 720;
|
|
|
|
|
static constexpr u32 DEFAULT_WINDOW_WIDTH = 1920;
|
|
|
|
|
static constexpr u32 DEFAULT_WINDOW_HEIGHT = 1080;
|
|
|
|
|
|
|
|
|
|
@ -1375,6 +1376,64 @@ bool Host::CopyTextToClipboard(std::string_view text)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Host::FormatNumber(NumberFormatType type, s64 value)
|
|
|
|
|
{
|
|
|
|
|
std::string ret;
|
|
|
|
|
|
|
|
|
|
if (type >= NumberFormatType::ShortDate && type <= NumberFormatType::LongDateTime)
|
|
|
|
|
{
|
|
|
|
|
const char* format;
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case NumberFormatType::ShortDate:
|
|
|
|
|
format = "%x";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NumberFormatType::LongDate:
|
|
|
|
|
format = "%A %B %e %Y";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NumberFormatType::ShortTime:
|
|
|
|
|
case NumberFormatType::LongTime:
|
|
|
|
|
format = "%X";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NumberFormatType::ShortDateTime:
|
|
|
|
|
format = "%X %x";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NumberFormatType::LongDateTime:
|
|
|
|
|
format = "%c";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
DefaultCaseIsUnreachable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct tm ttime = {};
|
|
|
|
|
const std::time_t tvalue = static_cast<std::time_t>(value);
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
localtime_s(&ttime, &tvalue);
|
|
|
|
|
#else
|
|
|
|
|
localtime_r(&tvalue, &ttime);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
char buf[128];
|
|
|
|
|
std::strftime(buf, std::size(buf), "%x", &ttime);
|
|
|
|
|
ret.assign(buf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = fmt::format("{}", value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Host::FormatNumber(NumberFormatType type, double value)
|
|
|
|
|
{
|
|
|
|
|
return fmt::format("{}", value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::optional<u32> InputManager::ConvertHostKeyboardStringToCode(std::string_view str)
|
|
|
|
|
{
|
|
|
|
|
return SDLKeyNames::GetKeyCodeForName(str);
|
|
|
|
|
|