mirror of
https://github.com/wiiu-env/ScreenshotWUPS.git
synced 2024-11-22 14:39:14 +01:00
Move the dir creation into the takeScreenshot function
This commit is contained in:
parent
b5d5b57dbd
commit
47c2de5e43
@ -10,9 +10,9 @@
|
|||||||
#include <vpad/input.h>
|
#include <vpad/input.h>
|
||||||
#include <wups.h>
|
#include <wups.h>
|
||||||
|
|
||||||
static bool takeScreenshotTV = false;
|
static bool takeScreenshotTV = false;
|
||||||
static bool takeScreenshotDRC = false;
|
static bool takeScreenshotDRC = false;
|
||||||
static uint8_t screenshotCoolDown = 0;
|
static uint8_t screenshotCoolDown = 0;
|
||||||
|
|
||||||
DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buffer_size, VPADReadError *error) {
|
DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buffer_size, VPADReadError *error) {
|
||||||
VPADReadError real_error;
|
VPADReadError real_error;
|
||||||
@ -20,9 +20,8 @@ DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buf
|
|||||||
|
|
||||||
if (gEnabled) {
|
if (gEnabled) {
|
||||||
if (result > 0 && real_error == VPAD_READ_SUCCESS && (buffer[0].hold == gButtonCombo) && screenshotCoolDown == 0 && OSIsHomeButtonMenuEnabled()) {
|
if (result > 0 && real_error == VPAD_READ_SUCCESS && (buffer[0].hold == gButtonCombo) && screenshotCoolDown == 0 && OSIsHomeButtonMenuEnabled()) {
|
||||||
takeScreenshotTV = gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV;
|
takeScreenshotTV = gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_TV;
|
||||||
takeScreenshotDRC = gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_DRC;
|
takeScreenshotDRC = gImageSource == IMAGE_SOURCE_TV_AND_DRC || gImageSource == IMAGE_SOURCE_DRC;
|
||||||
|
|
||||||
screenshotCoolDown = 60;
|
screenshotCoolDown = 60;
|
||||||
}
|
}
|
||||||
if (screenshotCoolDown > 0) {
|
if (screenshotCoolDown > 0) {
|
||||||
@ -38,44 +37,13 @@ DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, uint32_t buf
|
|||||||
|
|
||||||
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, GX2ScanTarget scan_target) {
|
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, GX2ScanTarget scan_target) {
|
||||||
if ((takeScreenshotTV || takeScreenshotDRC)) {
|
if ((takeScreenshotTV || takeScreenshotDRC)) {
|
||||||
OSCalendarTime output;
|
if (scan_target == GX2_SCAN_TARGET_TV && colorBuffer != nullptr && takeScreenshotTV) {
|
||||||
OSTicksToCalendarTime(OSGetTime(), &output);
|
DEBUG_FUNCTION_LINE("Lets take a screenshot from TV.");
|
||||||
std::string buffer = string_format("%s%016llX", WIIU_SCREENSHOT_PATH, OSGetTitleID());
|
takeScreenshot((GX2ColorBuffer *) colorBuffer, scan_target, gTVSurfaceFormat, gOutputFormat, gQuality);
|
||||||
if (!gShortNameEn.empty()) {
|
|
||||||
buffer += string_format(" (%s)", gShortNameEn.c_str());
|
|
||||||
}
|
|
||||||
buffer += string_format("/%04d-%02d-%02d/", output.tm_year, output.tm_mon + 1, output.tm_mday);
|
|
||||||
|
|
||||||
bool dirExists = true;
|
|
||||||
auto dir = opendir(buffer.c_str());
|
|
||||||
if (dir) {
|
|
||||||
closedir(dir);
|
|
||||||
} else {
|
|
||||||
if (!FSUtils::CreateSubfolder(buffer.c_str())) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to create dir: %s", buffer.c_str());
|
|
||||||
dirExists = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dirExists) {
|
|
||||||
buffer = string_format("%s%04d-%02d-%02d_%02d.%02d.%02d_",
|
|
||||||
buffer.c_str(), output.tm_year, output.tm_mon + 1,
|
|
||||||
output.tm_mday, output.tm_hour, output.tm_min, output.tm_sec);
|
|
||||||
|
|
||||||
if (scan_target == GX2_SCAN_TARGET_TV && colorBuffer != nullptr && takeScreenshotTV) {
|
|
||||||
DEBUG_FUNCTION_LINE("Lets take a screenshot from TV.");
|
|
||||||
takeScreenshot((GX2ColorBuffer *) colorBuffer, buffer, scan_target, gTVSurfaceFormat, gOutputFormat, gQuality);
|
|
||||||
takeScreenshotTV = false;
|
|
||||||
} else if (scan_target == GX2_SCAN_TARGET_DRC0 && colorBuffer != nullptr && takeScreenshotDRC) {
|
|
||||||
DEBUG_FUNCTION_LINE("Lets take a screenshot from DRC.");
|
|
||||||
takeScreenshot((GX2ColorBuffer *) colorBuffer, buffer, scan_target, gDRCSurfaceFormat, gOutputFormat, gQuality);
|
|
||||||
takeScreenshotDRC = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scan_target == GX2_SCAN_TARGET_TV) {
|
|
||||||
takeScreenshotTV = false;
|
takeScreenshotTV = false;
|
||||||
} else if (scan_target == GX2_SCAN_TARGET_DRC) {
|
} else if (scan_target == GX2_SCAN_TARGET_DRC0 && colorBuffer != nullptr && takeScreenshotDRC) {
|
||||||
|
DEBUG_FUNCTION_LINE("Lets take a screenshot from DRC.");
|
||||||
|
takeScreenshot((GX2ColorBuffer *) colorBuffer, scan_target, gDRCSurfaceFormat, gOutputFormat, gQuality);
|
||||||
takeScreenshotDRC = false;
|
takeScreenshotDRC = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include "screenshot_utils.h"
|
#include "screenshot_utils.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "utils/utils.h"
|
#include "fs/FSUtils.h"
|
||||||
|
#include "retain_vars.hpp"
|
||||||
|
#include "utils/StringTools.h"
|
||||||
|
#include <coreinit/title.h>
|
||||||
#include <gd.h>
|
#include <gd.h>
|
||||||
#include <gx2/event.h>
|
#include <gx2/event.h>
|
||||||
#include <gx2/mem.h>
|
#include <gx2/mem.h>
|
||||||
@ -187,7 +190,7 @@ static bool copyBuffer(GX2ColorBuffer *sourceBuffer, GX2ColorBuffer *targetBuffe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool takeScreenshot(GX2ColorBuffer *srcBuffer, const std::string &path, GX2ScanTarget scanTarget, GX2SurfaceFormat outputBufferSurfaceFormat, ImageOutputFormatEnum outputFormat, int quality) {
|
bool takeScreenshot(GX2ColorBuffer *srcBuffer, GX2ScanTarget scanTarget, GX2SurfaceFormat outputBufferSurfaceFormat, ImageOutputFormatEnum outputFormat, int quality) {
|
||||||
if (srcBuffer == nullptr) {
|
if (srcBuffer == nullptr) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Source buffer was NULL");
|
DEBUG_FUNCTION_LINE_ERR("Source buffer was NULL");
|
||||||
return false;
|
return false;
|
||||||
@ -200,7 +203,27 @@ bool takeScreenshot(GX2ColorBuffer *srcBuffer, const std::string &path, GX2ScanT
|
|||||||
uint32_t width = srcBuffer->surface.width;
|
uint32_t width = srcBuffer->surface.width;
|
||||||
uint32_t height = srcBuffer->surface.height;
|
uint32_t height = srcBuffer->surface.height;
|
||||||
|
|
||||||
std::string fullPath = path;
|
OSCalendarTime output;
|
||||||
|
OSTicksToCalendarTime(OSGetTime(), &output);
|
||||||
|
std::string buffer = string_format("%s%016llX", WIIU_SCREENSHOT_PATH, OSGetTitleID());
|
||||||
|
if (!gShortNameEn.empty()) {
|
||||||
|
buffer += string_format(" (%s)", gShortNameEn.c_str());
|
||||||
|
}
|
||||||
|
buffer += string_format("/%04d-%02d-%02d/", output.tm_year, output.tm_mon + 1, output.tm_mday);
|
||||||
|
|
||||||
|
auto dir = opendir(buffer.c_str());
|
||||||
|
if (dir) {
|
||||||
|
closedir(dir);
|
||||||
|
} else {
|
||||||
|
if (!FSUtils::CreateSubfolder(buffer.c_str())) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to create dir: %s", buffer.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string fullPath = string_format("%s%04d-%02d-%02d_%02d.%02d.%02d_",
|
||||||
|
buffer.c_str(), output.tm_year, output.tm_mon + 1,
|
||||||
|
output.tm_mday, output.tm_hour, output.tm_min, output.tm_sec);
|
||||||
|
|
||||||
if (scanTarget == GX2_SCAN_TARGET_DRC) {
|
if (scanTarget == GX2_SCAN_TARGET_DRC) {
|
||||||
fullPath += "DRC";
|
fullPath += "DRC";
|
||||||
|
@ -10,4 +10,4 @@
|
|||||||
bool saveTextureAsPicture(const std::string &path, uint8_t *sourceBuffer, uint32_t width, uint32_t height, uint32_t pitch, GX2SurfaceFormat format, ImageOutputFormatEnum outputFormat, bool convertRGBtoSRGB, int quality);
|
bool saveTextureAsPicture(const std::string &path, uint8_t *sourceBuffer, uint32_t width, uint32_t height, uint32_t pitch, GX2SurfaceFormat format, ImageOutputFormatEnum outputFormat, bool convertRGBtoSRGB, int quality);
|
||||||
|
|
||||||
|
|
||||||
bool takeScreenshot(GX2ColorBuffer *srcBuffer, const std::string &path, GX2ScanTarget scanTarget, GX2SurfaceFormat outputBufferSurfaceFormat, ImageOutputFormatEnum outputFormat, int quality);
|
bool takeScreenshot(GX2ColorBuffer *srcBuffer, GX2ScanTarget scanTarget, GX2SurfaceFormat outputBufferSurfaceFormat, ImageOutputFormatEnum outputFormat, int quality);
|
||||||
|
Loading…
Reference in New Issue
Block a user