commit
b9c199bce3
16 changed files with 104 additions and 61 deletions
|
@ -60,7 +60,6 @@ namespace
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mySaveOnExit = false;
|
|
||||||
LogFileOutput("Registry: configuration file '%s' not found\n", filename.c_str());
|
LogFileOutput("Registry: configuration file '%s' not found\n", filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +68,14 @@ namespace
|
||||||
{
|
{
|
||||||
if (mySaveOnExit)
|
if (mySaveOnExit)
|
||||||
{
|
{
|
||||||
boost::property_tree::ini_parser::write_ini(myFilename, myINI);
|
try
|
||||||
|
{
|
||||||
|
boost::property_tree::ini_parser::write_ini(myFilename, myINI);
|
||||||
|
}
|
||||||
|
catch(const std::exception& e)
|
||||||
|
{
|
||||||
|
LogFileOutput("Registry: cannot save settings to '%s': %s\n", myFilename.c_str(), e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +110,7 @@ namespace common2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeFileRegistry(const EmulatorOptions & options)
|
std::shared_ptr<Registry> CreateFileRegistry(const EmulatorOptions & options)
|
||||||
{
|
{
|
||||||
const std::string homeDir = getHomeDir();
|
const std::string homeDir = getHomeDir();
|
||||||
|
|
||||||
|
@ -125,7 +131,7 @@ namespace common2
|
||||||
std::shared_ptr<Configuration> config(new Configuration(filename, saveOnExit));
|
std::shared_ptr<Configuration> config(new Configuration(filename, saveOnExit));
|
||||||
config->addExtraOptions(options.registryOptions);
|
config->addExtraOptions(options.registryOptions);
|
||||||
|
|
||||||
Registry::instance = config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class Registry;
|
||||||
|
|
||||||
namespace common2
|
namespace common2
|
||||||
{
|
{
|
||||||
|
@ -8,6 +11,6 @@ namespace common2
|
||||||
struct EmulatorOptions;
|
struct EmulatorOptions;
|
||||||
|
|
||||||
std::string GetConfigFile(const std::string & filename);
|
std::string GetConfigFile(const std::string & filename);
|
||||||
void InitializeFileRegistry(const EmulatorOptions & options);
|
std::shared_ptr<Registry> CreateFileRegistry(const EmulatorOptions & options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,9 +123,9 @@ namespace common2
|
||||||
HD_Destroy();
|
HD_Destroy();
|
||||||
PrintDestroy();
|
PrintDestroy();
|
||||||
CpuDestroy();
|
CpuDestroy();
|
||||||
|
DebugDestroy();
|
||||||
|
|
||||||
GetCardMgr().GetDisk2CardMgr().Destroy();
|
GetCardMgr().GetDisk2CardMgr().Destroy();
|
||||||
LogDone();
|
|
||||||
RiffFinishWriteFile();
|
RiffFinishWriteFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,13 @@ namespace ra2
|
||||||
|
|
||||||
unsigned Game::ourInputDevices[MAX_PADS] = {RETRO_DEVICE_NONE};
|
unsigned Game::ourInputDevices[MAX_PADS] = {RETRO_DEVICE_NONE};
|
||||||
|
|
||||||
Game::Game(const std::shared_ptr<RetroFrame> & frame)
|
Game::Game()
|
||||||
: myFrame(frame), mySpeed(true), myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
: myLogger(true)
|
||||||
|
, myFrame(new ra2::RetroFrame())
|
||||||
|
, mySpeed(true)
|
||||||
|
, myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
||||||
{
|
{
|
||||||
LogInit();
|
Registry::instance = CreateRetroRegistry();
|
||||||
InitialiseRetroRegistry();
|
|
||||||
SetFrame(myFrame);
|
SetFrame(myFrame);
|
||||||
myFrame->Initialize();
|
myFrame->Initialize();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "frontends/common2/speed.h"
|
#include "frontends/common2/speed.h"
|
||||||
#include "frontends/libretro/environment.h"
|
#include "frontends/libretro/environment.h"
|
||||||
|
|
||||||
|
#include "linux/context.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -14,7 +16,7 @@ namespace ra2
|
||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Game(const std::shared_ptr<RetroFrame> & frame);
|
Game();
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
bool loadGame(const std::string & path);
|
bool loadGame(const std::string & path);
|
||||||
|
@ -33,6 +35,7 @@ namespace ra2
|
||||||
static retro_usec_t ourFrameTime;
|
static retro_usec_t ourFrameTime;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const Logger myLogger;
|
||||||
const std::shared_ptr<RetroFrame> myFrame;
|
const std::shared_ptr<RetroFrame> myFrame;
|
||||||
|
|
||||||
common2::Speed mySpeed; // fixed speed
|
common2::Speed mySpeed; // fixed speed
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "frontends/libretro/environment.h"
|
#include "frontends/libretro/environment.h"
|
||||||
#include "frontends/libretro/rdirectsound.h"
|
#include "frontends/libretro/rdirectsound.h"
|
||||||
#include "frontends/libretro/retroregistry.h"
|
#include "frontends/libretro/retroregistry.h"
|
||||||
#include "frontends/libretro/retroframe.h"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -180,8 +179,7 @@ bool retro_load_game(const retro_game_info *info)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::shared_ptr<ra2::RetroFrame> frame(new ra2::RetroFrame());
|
std::unique_ptr<ra2::Game> game(new ra2::Game());
|
||||||
std::unique_ptr<ra2::Game> game(new ra2::Game(frame));
|
|
||||||
|
|
||||||
const std::string snapshotEnding = ".aws.yaml";
|
const std::string snapshotEnding = ".aws.yaml";
|
||||||
const std::string gamePath = info->path;
|
const std::string gamePath = info->path;
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace ra2
|
||||||
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, retroVariables.data());
|
environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, retroVariables.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitialiseRetroRegistry()
|
std::shared_ptr<Registry> CreateRetroRegistry()
|
||||||
{
|
{
|
||||||
const auto registry = std::make_shared<common2::PTreeRegistry>();
|
const auto registry = std::make_shared<common2::PTreeRegistry>();
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ namespace ra2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Registry::instance = registry;
|
return registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class Registry;
|
||||||
|
|
||||||
namespace ra2
|
namespace ra2
|
||||||
{
|
{
|
||||||
|
|
||||||
void SetupRetroVariables();
|
void SetupRetroVariables();
|
||||||
void InitialiseRetroRegistry();
|
std::shared_ptr<Registry> CreateRetroRegistry();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "frontends/common2/utils.h"
|
#include "frontends/common2/utils.h"
|
||||||
#include "frontends/ncurses/world.h"
|
#include "frontends/ncurses/world.h"
|
||||||
#include "frontends/ncurses/nframe.h"
|
#include "frontends/ncurses/nframe.h"
|
||||||
|
#include "frontends/ncurses/evdevpaddle.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -132,7 +133,6 @@ namespace
|
||||||
|
|
||||||
void EnterMessageLoop(const common2::EmulatorOptions & options, const std::shared_ptr<na2::NFrame> & frame)
|
void EnterMessageLoop(const common2::EmulatorOptions & options, const std::shared_ptr<na2::NFrame> & frame)
|
||||||
{
|
{
|
||||||
LogFileTimeUntilFirstKeyReadReset();
|
|
||||||
while (ContinueExecution(options, frame))
|
while (ContinueExecution(options, frame))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -146,16 +146,14 @@ namespace
|
||||||
if (!run)
|
if (!run)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (options.log)
|
const Logger logger(options.log);
|
||||||
{
|
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||||
LogInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeFileRegistry(options);
|
|
||||||
g_nMemoryClearType = options.memclear;
|
g_nMemoryClearType = options.memclear;
|
||||||
|
|
||||||
std::shared_ptr<na2::NFrame> frame(new na2::NFrame(options.paddleDeviceName));
|
const std::shared_ptr<na2::EvDevPaddle> paddle(new na2::EvDevPaddle(options.paddleDeviceName));
|
||||||
Initialisation init(frame);
|
|
||||||
|
const std::shared_ptr<na2::NFrame> frame(new na2::NFrame(paddle));
|
||||||
|
const Initialisation init(registry, frame, paddle);
|
||||||
|
|
||||||
na2::SetCtrlCHandler(options.headless);
|
na2::SetCtrlCHandler(options.headless);
|
||||||
applyOptions(options);
|
applyOptions(options);
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "frontends/ncurses/colors.h"
|
#include "frontends/ncurses/colors.h"
|
||||||
#include "frontends/ncurses/asciiart.h"
|
#include "frontends/ncurses/asciiart.h"
|
||||||
#include "frontends/ncurses/evdevpaddle.h"
|
#include "frontends/ncurses/evdevpaddle.h"
|
||||||
|
|
||||||
#include "Interface.h"
|
#include "Interface.h"
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
@ -39,8 +38,8 @@ namespace na2
|
||||||
std::shared_ptr<GraphicsColors> colors;
|
std::shared_ptr<GraphicsColors> colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
NFrame::NFrame(const std::string & paddleDevice)
|
NFrame::NFrame(const std::shared_ptr<EvDevPaddle> & paddle)
|
||||||
: myPaddleDevice(paddleDevice)
|
: myPaddle(paddle)
|
||||||
, myRows(-1)
|
, myRows(-1)
|
||||||
, myColumns(-1)
|
, myColumns(-1)
|
||||||
{
|
{
|
||||||
|
@ -54,8 +53,6 @@ namespace na2
|
||||||
myTextFlashCounter = 0;
|
myTextFlashCounter = 0;
|
||||||
myTextFlashState = 0;
|
myTextFlashState = 0;
|
||||||
myAsciiArt.reset(new ASCIIArt());
|
myAsciiArt.reset(new ASCIIArt());
|
||||||
myPaddle.reset(new EvDevPaddle(myPaddleDevice));
|
|
||||||
Paddle::instance = myPaddle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NFrame::Destroy()
|
void NFrame::Destroy()
|
||||||
|
@ -67,9 +64,6 @@ namespace na2
|
||||||
myStatus.reset();
|
myStatus.reset();
|
||||||
myAsciiArt.reset();
|
myAsciiArt.reset();
|
||||||
|
|
||||||
myPaddle.reset();
|
|
||||||
Paddle::instance.reset();
|
|
||||||
|
|
||||||
myNCurses.reset();
|
myNCurses.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace na2
|
||||||
class NFrame : public common2::CommonFrame
|
class NFrame : public common2::CommonFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NFrame(const std::string & paddleDevice);
|
NFrame(const std::shared_ptr<EvDevPaddle> & paddle);
|
||||||
|
|
||||||
WINDOW * GetWindow();
|
WINDOW * GetWindow();
|
||||||
WINDOW * GetStatus();
|
WINDOW * GetStatus();
|
||||||
|
@ -35,7 +35,8 @@ namespace na2
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const std::string myPaddleDevice;
|
const std::shared_ptr<EvDevPaddle> myPaddle;
|
||||||
|
|
||||||
int myRows;
|
int myRows;
|
||||||
int myColumns;
|
int myColumns;
|
||||||
int myTextFlashCounter;
|
int myTextFlashCounter;
|
||||||
|
@ -44,7 +45,6 @@ namespace na2
|
||||||
std::shared_ptr<WINDOW> myFrame;
|
std::shared_ptr<WINDOW> myFrame;
|
||||||
std::shared_ptr<WINDOW> myStatus;
|
std::shared_ptr<WINDOW> myStatus;
|
||||||
std::shared_ptr<ASCIIArt> myAsciiArt;
|
std::shared_ptr<ASCIIArt> myAsciiArt;
|
||||||
std::shared_ptr<EvDevPaddle> myPaddle;
|
|
||||||
std::shared_ptr<NCurses> myNCurses;
|
std::shared_ptr<NCurses> myNCurses;
|
||||||
|
|
||||||
LPBYTE myTextBank1; // Aux
|
LPBYTE myTextBank1; // Aux
|
||||||
|
|
|
@ -90,18 +90,11 @@ void run_sdl(int argc, const char * argv [])
|
||||||
if (!run)
|
if (!run)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InitializeFileRegistry(options);
|
const Logger logger(options.log);
|
||||||
|
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||||
if (options.log)
|
|
||||||
{
|
|
||||||
LogInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_nMemoryClearType = options.memclear;
|
g_nMemoryClearType = options.memclear;
|
||||||
Paddle::instance.reset(new sa2::Gamepad(0));
|
|
||||||
|
|
||||||
std::shared_ptr<sa2::SDLFrame> frame;
|
std::shared_ptr<sa2::SDLFrame> frame;
|
||||||
|
|
||||||
if (options.imgui)
|
if (options.imgui)
|
||||||
{
|
{
|
||||||
frame.reset(new sa2::SDLImGuiFrame(options));
|
frame.reset(new sa2::SDLImGuiFrame(options));
|
||||||
|
@ -111,13 +104,14 @@ void run_sdl(int argc, const char * argv [])
|
||||||
frame.reset(new sa2::SDLRendererFrame(options));
|
frame.reset(new sa2::SDLRendererFrame(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Paddle> paddle(new sa2::Gamepad(0));
|
||||||
|
const Initialisation init(registry, frame, paddle);
|
||||||
|
|
||||||
if (SDL_GL_SetSwapInterval(options.glSwapInterval))
|
if (SDL_GL_SetSwapInterval(options.glSwapInterval))
|
||||||
{
|
{
|
||||||
throw std::runtime_error(SDL_GetError());
|
throw std::runtime_error(SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
Initialisation init(frame);
|
|
||||||
|
|
||||||
applyOptions(options);
|
applyOptions(options);
|
||||||
|
|
||||||
const int fps = getRefreshRate();
|
const int fps = getRefreshRate();
|
||||||
|
@ -230,8 +224,6 @@ int main(int argc, const char * argv [])
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this must happen BEFORE the SDL_Quit() as otherwise we have a double free (of the game controller).
|
|
||||||
Paddle::instance.reset();
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
return exit;
|
return exit;
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
|
|
||||||
#include "linux/context.h"
|
#include "linux/context.h"
|
||||||
|
#include "linux/linuxframe.h"
|
||||||
|
#include "linux/registry.h"
|
||||||
|
#include "linux/paddle.h"
|
||||||
|
#include "linux/duplicates/PropertySheet.h"
|
||||||
|
|
||||||
#include "Interface.h"
|
#include "Interface.h"
|
||||||
#include "linux/duplicates/PropertySheet.h"
|
#include "Log.h"
|
||||||
#include "linux/linuxframe.h"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -33,9 +36,16 @@ Video& GetVideo()
|
||||||
return sg_Video;
|
return sg_Video;
|
||||||
}
|
}
|
||||||
|
|
||||||
Initialisation::Initialisation(const std::shared_ptr<FrameBase> & frame)
|
Initialisation::Initialisation(
|
||||||
|
const std::shared_ptr<Registry> & registry,
|
||||||
|
const std::shared_ptr<FrameBase> & frame,
|
||||||
|
const std::shared_ptr<Paddle> & paddle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
Registry::instance = registry;
|
||||||
SetFrame(frame);
|
SetFrame(frame);
|
||||||
|
Paddle::instance = paddle;
|
||||||
|
|
||||||
frame->Initialize();
|
frame->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,4 +53,20 @@ Initialisation::~Initialisation()
|
||||||
{
|
{
|
||||||
GetFrame().Destroy();
|
GetFrame().Destroy();
|
||||||
SetFrame(std::shared_ptr<FrameBase>());
|
SetFrame(std::shared_ptr<FrameBase>());
|
||||||
|
|
||||||
|
Paddle::instance.reset();
|
||||||
|
Registry::instance.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Logger(const bool log)
|
||||||
|
{
|
||||||
|
if (log)
|
||||||
|
{
|
||||||
|
LogInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::~Logger()
|
||||||
|
{
|
||||||
|
LogDone();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,27 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class FrameBase;
|
class FrameBase;
|
||||||
|
class Paddle;
|
||||||
|
class Registry;
|
||||||
|
|
||||||
void SetFrame(const std::shared_ptr<FrameBase> & frame);
|
void SetFrame(const std::shared_ptr<FrameBase> & frame);
|
||||||
|
|
||||||
|
// RAII around Frame Registry and Paddle
|
||||||
class Initialisation
|
class Initialisation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Initialisation(const std::shared_ptr<FrameBase> & frame);
|
Initialisation(
|
||||||
|
const std::shared_ptr<Registry> & registry,
|
||||||
|
const std::shared_ptr<FrameBase> & frame,
|
||||||
|
const std::shared_ptr<Paddle> & paddle
|
||||||
|
);
|
||||||
~Initialisation();
|
~Initialisation();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// RAII around LogInit / LogDone.
|
||||||
|
class Logger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Logger(const bool log);
|
||||||
|
~Logger();
|
||||||
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "linux/linuxframe.h"
|
#include "linux/linuxframe.h"
|
||||||
#include "Interface.h"
|
#include "Interface.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "Core.h"
|
||||||
|
|
||||||
void LinuxFrame::FrameDrawDiskLEDS()
|
void LinuxFrame::FrameDrawDiskLEDS()
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,7 @@ void LinuxFrame::Initialize()
|
||||||
const size_t numberOfBytes = sizeof(bgra_t) * numberOfPixels;
|
const size_t numberOfBytes = sizeof(bgra_t) * numberOfPixels;
|
||||||
myFramebuffer.resize(numberOfBytes);
|
myFramebuffer.resize(numberOfBytes);
|
||||||
video.Initialize(myFramebuffer.data());
|
video.Initialize(myFramebuffer.data());
|
||||||
|
LogFileTimeUntilFirstKeyReadReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinuxFrame::Destroy()
|
void LinuxFrame::Destroy()
|
||||||
|
|
|
@ -22,10 +22,10 @@ DWORD timeGetTime()
|
||||||
/// Returns the number of ticks since an undefined time (usually system startup).
|
/// Returns the number of ticks since an undefined time (usually system startup).
|
||||||
DWORD GetTickCount()
|
DWORD GetTickCount()
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
const uint64_t ticks = (uint64_t)(ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000ull);
|
const uint64_t ticks = (uint64_t)(ts.tv_nsec / 1000000) + ((uint64_t)ts.tv_sec * 1000ull);
|
||||||
return ticks;
|
return ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetLocalTime(SYSTEMTIME *t)
|
void GetLocalTime(SYSTEMTIME *t)
|
||||||
|
@ -48,18 +48,18 @@ void GetLocalTime(SYSTEMTIME *t)
|
||||||
t->wYear = local->tm_year;
|
t->wYear = local->tm_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetDateFormat(LCID Locale, DWORD dwFlags, CONST SYSTEMTIME *lpDate, LPCSTR lpFormat, LPSTR lpDateStr, int cchDate)
|
int GetDateFormat(LCID /* Locale */, DWORD /* dwFlags */, CONST SYSTEMTIME * /* lpDate */, LPCSTR /* lpFormat */, LPSTR lpDateStr, int cchDate)
|
||||||
{
|
{
|
||||||
std::time_t t = std::time(nullptr);
|
std::time_t t = std::time(nullptr);
|
||||||
std::tm tm = *std::localtime(&t);
|
std::tm tm = *std::localtime(&t);
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << std::put_time(&tm, "%D");
|
ss << std::put_time(&tm, "%F");
|
||||||
const std::string str = ss.str();
|
const std::string str = ss.str();
|
||||||
strncpy(lpDateStr, str.c_str(), cchDate);
|
strncpy(lpDateStr, str.c_str(), cchDate);
|
||||||
return cchDate; // not 100% sure, but it is never used
|
return cchDate; // not 100% sure, but it is never used
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetTimeFormat(LCID Locale, DWORD dwFlags, CONST SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpTimeStr, int cchTime)
|
int GetTimeFormat(LCID /* Locale */, DWORD /* dwFlags */, CONST SYSTEMTIME * /* lpTime */, LPCSTR /* lpFormat */, LPSTR lpTimeStr, int cchTime)
|
||||||
{
|
{
|
||||||
std::time_t t = std::time(nullptr);
|
std::time_t t = std::time(nullptr);
|
||||||
std::tm tm = *std::localtime(&t);
|
std::tm tm = *std::localtime(&t);
|
||||||
|
|
Loading…
Add table
Reference in a new issue