mirror of
https://github.com/wiiu-env/NotificationModule.git
synced 2026-04-19 13:37:12 -05:00
Compare commits
No commits in common. "main" and "v0.1.1" have entirely different histories.
10
.github/dependabot.yml
vendored
10
.github/dependabot.yml
vendored
|
|
@ -1,10 +0,0 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -9,7 +9,7 @@ jobs:
|
|||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src
|
||||
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "$GITHUB_SHA")
|
||||
|
|
@ -48,7 +48,7 @@ jobs:
|
|||
- name: zip artifact
|
||||
run: zip -r ${{ env.REPOSITORY_NAME }}_${{ env.DATETIME }}.zip *.wms
|
||||
- name: Create Release
|
||||
uses: "softprops/action-gh-release@v2"
|
||||
uses: "softprops/action-gh-release@v1"
|
||||
with:
|
||||
tag_name: ${{ env.REPOSITORY_NAME }}-${{ env.DATETIME }}
|
||||
draft: false
|
||||
|
|
|
|||
6
.github/workflows/pr.yml
vendored
6
.github/workflows/pr.yml
vendored
|
|
@ -6,7 +6,7 @@ jobs:
|
|||
clang-format:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: clang-format
|
||||
run: |
|
||||
docker run --rm -v ${PWD}:/src ghcr.io/wiiu-env/clang-format:13.0.0-2 -r ./src
|
||||
|
|
@ -14,7 +14,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: build binary with logging
|
||||
run: |
|
||||
docker build . -t builder
|
||||
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
needs: clang-format
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v3
|
||||
- name: create version.h
|
||||
run: |
|
||||
git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,4 +8,3 @@ build/
|
|||
cmake-build-debug/
|
||||
CMakeLists.txt
|
||||
*.wms
|
||||
*.zip
|
||||
|
|
|
|||
10
Dockerfile
10
Dockerfile
|
|
@ -1,8 +1,8 @@
|
|||
FROM ghcr.io/wiiu-env/devkitppc:20260225
|
||||
FROM ghcr.io/wiiu-env/devkitppc:20230621
|
||||
|
||||
COPY --from=ghcr.io/wiiu-env/libnotifications:20260404 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libmappedmemory:20260331 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20260331 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20260418 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libmappedmemory:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
|
||||
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20230719 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR project
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -30,7 +30,7 @@ INCLUDES := src
|
|||
#-------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#-------------------------------------------------------------------------------
|
||||
CFLAGS := -Wall -Wextra -Werror -O2 -ffunction-sections\
|
||||
CFLAGS := -Wall -Wextra -O2 -ffunction-sections\
|
||||
$(MACHDEP)
|
||||
|
||||
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
|
||||
|
|
|
|||
112
src/export.cpp
112
src/export.cpp
|
|
@ -6,31 +6,21 @@
|
|||
#include <wums.h>
|
||||
|
||||
void ExportCleanUp() {
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
gNotificationList.clear();
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
|
||||
// Remove notification in queue that should not survive
|
||||
std::vector<std::shared_ptr<Notification>> keepQueue;
|
||||
for (const auto ¬ification : gOverlayQueueDuringStartup) {
|
||||
if (notification->isKeepUntilShown()) {
|
||||
keepQueue.push_back(notification);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
gOverlayQueueDuringStartup.clear();
|
||||
gOverlayQueueDuringStartup = keepQueue;
|
||||
}
|
||||
|
||||
NotificationModuleStatus NMAddStaticNotificationV2(const char *text,
|
||||
NotificationModuleNotificationType type,
|
||||
float durationBeforeFadeOutInSeconds,
|
||||
float shakeDurationInSeconds,
|
||||
NMColor textColor,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context,
|
||||
bool keepUntilShown) {
|
||||
NotificationModuleStatus NMAddStaticNotification(const char *text,
|
||||
NotificationModuleNotificationType type,
|
||||
float durationBeforeFadeOutInSeconds,
|
||||
float shakeDurationInSeconds,
|
||||
NMColor textColor,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context) {
|
||||
if (!gOverlayFrame) {
|
||||
return NOTIFICATION_MODULE_RESULT_OVERLAY_NOT_READY;
|
||||
}
|
||||
|
||||
NotificationStatus status;
|
||||
switch (type) {
|
||||
|
|
@ -51,37 +41,16 @@ NotificationModuleStatus NMAddStaticNotificationV2(const char *text,
|
|||
(GX2Color){textColor.r, textColor.g, textColor.b, textColor.a},
|
||||
(GX2Color){backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a},
|
||||
finishFunc,
|
||||
context,
|
||||
nullptr,
|
||||
keepUntilShown);
|
||||
context);
|
||||
if (!notification) {
|
||||
return NOTIFICATION_MODULE_RESULT_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard lock(gOverlayFrameMutex);
|
||||
if (gOverlayFrame && gDrawReady) {
|
||||
gOverlayFrame->addNotification(std::move(notification));
|
||||
} else {
|
||||
gOverlayQueueDuringStartup.push_back(std::move(notification));
|
||||
}
|
||||
}
|
||||
gOverlayFrame->addNotification(notification);
|
||||
|
||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NotificationModuleStatus NMAddStaticNotification(const char *text,
|
||||
NotificationModuleNotificationType type,
|
||||
float durationBeforeFadeOutInSeconds,
|
||||
float shakeDurationInSeconds,
|
||||
NMColor textColor,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context) {
|
||||
return NMAddStaticNotificationV2(text, type, durationBeforeFadeOutInSeconds, shakeDurationInSeconds, textColor, backgroundColor, finishFunc, context, false);
|
||||
}
|
||||
|
||||
void NMNotificationRemovedFromOverlay(Notification *notification) {
|
||||
if (notification) {
|
||||
auto handle = notification->getHandle();
|
||||
|
|
@ -91,17 +60,19 @@ void NMNotificationRemovedFromOverlay(Notification *notification) {
|
|||
}
|
||||
}
|
||||
|
||||
NotificationModuleStatus NMAddDynamicNotificationV2(const char *text,
|
||||
NMColor textColor,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context,
|
||||
bool keep_until_shown,
|
||||
NotificationModuleHandle *outHandle) {
|
||||
NotificationModuleStatus NMAddDynamicNotification(const char *text,
|
||||
NMColor textColor,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context,
|
||||
NotificationModuleHandle *outHandle) {
|
||||
if (outHandle == nullptr) {
|
||||
return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
*outHandle = 0;
|
||||
if (!gOverlayFrame) {
|
||||
return NOTIFICATION_MODULE_RESULT_OVERLAY_NOT_READY;
|
||||
}
|
||||
|
||||
auto notification = make_shared_nothrow<Notification>(
|
||||
text,
|
||||
|
|
@ -112,42 +83,25 @@ NotificationModuleStatus NMAddDynamicNotificationV2(const char *text,
|
|||
(GX2Color){backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a},
|
||||
finishFunc,
|
||||
context,
|
||||
NMNotificationRemovedFromOverlay,
|
||||
keep_until_shown);
|
||||
NMNotificationRemovedFromOverlay);
|
||||
if (!notification) {
|
||||
return NOTIFICATION_MODULE_RESULT_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
*outHandle = notification->getHandle();
|
||||
{
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
if (gOverlayFrame) {
|
||||
gOverlayFrame->addNotification(notification);
|
||||
} else {
|
||||
gOverlayQueueDuringStartup.push_back(notification);
|
||||
}
|
||||
}
|
||||
gNotificationList.push_front(std::move(notification));
|
||||
gOverlayFrame->addNotification(notification);
|
||||
gNotificationList.push_front(notification);
|
||||
}
|
||||
|
||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
NotificationModuleStatus NMAddDynamicNotification(const char *text,
|
||||
NMColor textColor,
|
||||
NMColor backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *context),
|
||||
void *context,
|
||||
NotificationModuleHandle *outHandle) {
|
||||
return NMAddDynamicNotificationV2(text, textColor, backgroundColor, finishFunc, context, false, outHandle);
|
||||
}
|
||||
|
||||
NotificationModuleStatus NMUpdateDynamicNotificationText(NotificationModuleHandle handle,
|
||||
const char *text) {
|
||||
NotificationModuleStatus res = NOTIFICATION_MODULE_RESULT_INVALID_HANDLE;
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
for (auto &cur : gNotificationList) {
|
||||
if (cur->getHandle() == handle) {
|
||||
cur->updateText(text);
|
||||
|
|
@ -161,7 +115,7 @@ NotificationModuleStatus NMUpdateDynamicNotificationText(NotificationModuleHandl
|
|||
NotificationModuleStatus NMUpdateDynamicNotificationBackgroundColor(NotificationModuleHandle handle,
|
||||
NMColor backgroundColor) {
|
||||
NotificationModuleStatus res = NOTIFICATION_MODULE_RESULT_INVALID_HANDLE;
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
for (auto &cur : gNotificationList) {
|
||||
if (cur->getHandle() == handle) {
|
||||
cur->updateBackgroundColor((GX2Color){backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a});
|
||||
|
|
@ -175,7 +129,7 @@ NotificationModuleStatus NMUpdateDynamicNotificationBackgroundColor(Notification
|
|||
NotificationModuleStatus NMUpdateDynamicNotificationTextColor(NotificationModuleHandle handle,
|
||||
NMColor textColor) {
|
||||
NotificationModuleStatus res = NOTIFICATION_MODULE_RESULT_INVALID_HANDLE;
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
for (auto &cur : gNotificationList) {
|
||||
if (cur->getHandle() == handle) {
|
||||
cur->updateTextColor((GX2Color){textColor.r, textColor.g, textColor.b, textColor.a});
|
||||
|
|
@ -203,7 +157,7 @@ NotificationModuleStatus NMFinishDynamicNotification(NotificationModuleHandle ha
|
|||
}
|
||||
|
||||
NotificationModuleStatus res = NOTIFICATION_MODULE_RESULT_INVALID_HANDLE;
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
for (auto &cur : gNotificationList) {
|
||||
if (cur->getHandle() == handle) {
|
||||
cur->updateStatus(newStatus);
|
||||
|
|
@ -232,12 +186,10 @@ NotificationModuleStatus NMGetVersion(NotificationModuleAPIVersion *outVersion)
|
|||
if (outVersion == nullptr) {
|
||||
return NOTIFICATION_MODULE_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
*outVersion = 2;
|
||||
*outVersion = 1;
|
||||
return NOTIFICATION_MODULE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
WUMS_EXPORT_FUNCTION(NMAddDynamicNotificationV2);
|
||||
WUMS_EXPORT_FUNCTION(NMAddStaticNotificationV2);
|
||||
WUMS_EXPORT_FUNCTION(NMAddDynamicNotification);
|
||||
WUMS_EXPORT_FUNCTION(NMAddStaticNotification);
|
||||
WUMS_EXPORT_FUNCTION(NMUpdateDynamicNotificationText);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ DECL_FUNCTION(void, GX2SetContextState, GX2ContextState *curContext) {
|
|||
DECL_FUNCTION(void, GX2SetupContextStateEx, GX2ContextState *state, BOOL unk1) {
|
||||
real_GX2SetupContextStateEx(state, unk1);
|
||||
gOriginalContextState = state;
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("gOriginalContextState = %p", state);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("gOriginalContextState = %08X", state);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, GX2SetTVBuffer, void *buffer, uint32_t buffer_size, int32_t tv_render_mode, GX2SurfaceFormat surface_format, GX2BufferingMode buffering_mode) {
|
||||
|
|
@ -71,21 +71,8 @@ void drawScreenshotSavedTexture2(GX2ColorBuffer *colorBuffer, GX2ScanTarget scan
|
|||
drawIntoColorBuffer(colorBuffer, gOverlayFrame, scan_target);
|
||||
}
|
||||
|
||||
static void TryAddFromQueue() {
|
||||
if (!gOverlayFrame) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
// Add notification that had been called before the overlay was ready
|
||||
for (const auto ¬ification : gOverlayQueueDuringStartup) {
|
||||
gOverlayFrame->addNotification(notification);
|
||||
}
|
||||
gOverlayQueueDuringStartup.clear();
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, GX2ScanTarget scan_target) {
|
||||
gDrawReady = true;
|
||||
TryAddFromQueue();
|
||||
if (drawScreenshotSavedTexture(colorBuffer, scan_target)) {
|
||||
// if it returns true we don't need to call GX2CopyColorBufferToScanBuffer
|
||||
return;
|
||||
|
|
@ -123,24 +110,19 @@ bool drawScreenshotSavedTexture(const GX2ColorBuffer *colorBuffer, GX2ScanTarget
|
|||
DECL_FUNCTION(void, GX2Init, uint32_t attributes) {
|
||||
real_GX2Init(attributes);
|
||||
if (!gOverlayInitDone) {
|
||||
std::lock_guard overlay_lock(gOverlayFrameMutex);
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Init Overlay");
|
||||
gOverlayFrame = new (std::nothrow) OverlayFrame(1280.0f, 720.0f);
|
||||
if (!gOverlayFrame) {
|
||||
OSFatal("NotificationModule: Failed to alloc gOverlayFrame");
|
||||
OSFatal("Failed to alloc gOverlayFrame");
|
||||
}
|
||||
|
||||
// Allocate shader.
|
||||
if (ColorShader::instance() == nullptr) {
|
||||
OSFatal("NotificationModule: Failed to alloc ColorShader");
|
||||
}
|
||||
if (Texture2DShader::instance() == nullptr) {
|
||||
OSFatal("NotificationModule: Failed to alloc Texture2DShader");
|
||||
}
|
||||
ColorShader::instance();
|
||||
Texture2DShader::instance();
|
||||
|
||||
// has been allocated in WUMS INIT
|
||||
if (!gContextState) {
|
||||
OSFatal("NotificationModule: Failed to alloc gContextState");
|
||||
OSFatal("Failed to alloc gContextState");
|
||||
}
|
||||
real_GX2SetupContextStateEx(gContextState, GX2_TRUE);
|
||||
DCInvalidateRange(gContextState, sizeof(GX2ContextState)); // Important!
|
||||
|
|
@ -150,7 +132,6 @@ DECL_FUNCTION(void, GX2Init, uint32_t attributes) {
|
|||
|
||||
DECL_FUNCTION(void, GX2MarkScanBufferCopied, GX2ScanTarget scan_target) {
|
||||
gDrawReady = true;
|
||||
TryAddFromQueue();
|
||||
if (scan_target == GX2_SCAN_TARGET_TV) {
|
||||
drawScreenshotSavedTexture2(&lastTVColorBuffer, scan_target);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ GuiText::GuiText(const char *t, int s, const glm::vec4 &c) {
|
|||
blurGlowColor = glm::vec4(0.0f);
|
||||
|
||||
if (t) {
|
||||
std::lock_guard<std::recursive_mutex> textLock(mTextLock);
|
||||
std::lock_guard<std::mutex> textLock(mTextLock);
|
||||
text = SchriftGX2::charToWideChar(t);
|
||||
if (!text) {
|
||||
return;
|
||||
|
|
@ -81,14 +81,14 @@ GuiText::GuiText(const char *t, int s, const glm::vec4 &c) {
|
|||
* Destructor for the GuiText class.
|
||||
*/
|
||||
GuiText::~GuiText() {
|
||||
std::lock_guard<std::recursive_mutex> textLock(mTextLock);
|
||||
std::lock_guard<std::mutex> textLock(mTextLock);
|
||||
delete[] text;
|
||||
|
||||
text = nullptr;
|
||||
}
|
||||
|
||||
void GuiText::setText(const char *t) {
|
||||
std::lock_guard<std::recursive_mutex> textLock(mTextLock);
|
||||
std::lock_guard<std::mutex> textLock(mTextLock);
|
||||
delete[] text;
|
||||
|
||||
text = nullptr;
|
||||
|
|
@ -115,7 +115,7 @@ void GuiText::setPresetFont(SchriftGX2 *f) {
|
|||
}
|
||||
|
||||
void GuiText::setFontSize(int s) {
|
||||
std::lock_guard<std::recursive_mutex> textLock(mTextLock);
|
||||
std::lock_guard<std::mutex> textLock(mTextLock);
|
||||
size = s;
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ void GuiText::setBlurGlowColor(float blur, const glm::vec4 &c) {
|
|||
* Change font
|
||||
*/
|
||||
bool GuiText::setFont(SchriftGX2 *f) {
|
||||
std::lock_guard<std::recursive_mutex> textLock(mTextLock);
|
||||
std::lock_guard<std::mutex> textLock(mTextLock);
|
||||
if (!f) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ void GuiText::draw(bool SRGBConversion) {
|
|||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> textLock(mTextLock);
|
||||
std::lock_guard<std::mutex> textLock(mTextLock);
|
||||
|
||||
color[3] = getAlpha();
|
||||
blurGlowColor[3] = blurAlpha * getAlpha();
|
||||
|
|
|
|||
|
|
@ -100,5 +100,5 @@ protected:
|
|||
float blurAlpha;
|
||||
glm::vec4 blurGlowColor{};
|
||||
|
||||
std::recursive_mutex mTextLock;
|
||||
std::mutex mTextLock;
|
||||
};
|
||||
|
|
@ -8,8 +8,7 @@ Notification::Notification(const std::string &overlayText,
|
|||
GX2Color backgroundColor,
|
||||
void (*finishFunc)(NotificationModuleHandle, void *),
|
||||
void *context,
|
||||
void (*removedFromOverlayCallback)(Notification *),
|
||||
bool keepUntilShown) : GuiFrame(0, 0), mBackground(0, 0, backgroundColor) {
|
||||
void (*removedFromOverlayCallback)(Notification *)) : GuiFrame(0, 0), mBackground(0, 0, backgroundColor) {
|
||||
mFinishFunction = finishFunc;
|
||||
mFinishFunctionContext = context;
|
||||
mRemovedFromOverlayCallback = removedFromOverlayCallback;
|
||||
|
|
@ -21,7 +20,6 @@ Notification::Notification(const std::string &overlayText,
|
|||
mNotificationText.setPosition(0, 0);
|
||||
mNotificationText.setFontSize(20);
|
||||
mNotificationText.setAlignment(ALIGN_CENTERED);
|
||||
mKeepUntilShown = keepUntilShown;
|
||||
|
||||
updateStatus(status);
|
||||
|
||||
|
|
@ -97,4 +95,4 @@ void Notification::updateStatus(NotificationStatus newStatus) {
|
|||
}
|
||||
mWaitForReset = true;
|
||||
this->mStatus = newStatus;
|
||||
}
|
||||
}
|
||||
|
|
@ -35,8 +35,7 @@ public:
|
|||
GX2Color backgroundColor = {100, 100, 100, 255},
|
||||
void (*finishFunc)(NotificationModuleHandle, void *) = nullptr,
|
||||
void *context = nullptr,
|
||||
void (*removedFromOverlayCallback)(Notification *) = nullptr,
|
||||
bool keepUntilShown = false);
|
||||
void (*removedFromOverlayCallback)(Notification *) = nullptr);
|
||||
|
||||
~Notification() override;
|
||||
|
||||
|
|
@ -91,10 +90,6 @@ public:
|
|||
mPositionSet = true;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool isKeepUntilShown() const {
|
||||
return mKeepUntilShown;
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void(NotificationModuleHandle, void *)> mFinishFunction;
|
||||
std::function<void(Notification *)> mRemovedFromOverlayCallback;
|
||||
|
|
@ -111,8 +106,6 @@ private:
|
|||
bool mTextDirty = false;
|
||||
bool mPositionSet = false;
|
||||
|
||||
bool mKeepUntilShown = false;
|
||||
|
||||
NotificationStatus mStatus = NOTIFICATION_STATUS_INFO;
|
||||
NotificationInternalStatus mInternalStatus = NOTIFICATION_STATUS_NOTHING;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ void OverlayFrame::addNotification(std::shared_ptr<Notification> status) {
|
|||
status->setAlignment(ALIGN_TOP_LEFT);
|
||||
status->setEffect(EFFECT_FADE, 55, 255);
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
list.push_front(std::move(status));
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ void OverlayFrame::OnShakeFinished(GuiElement *element) {
|
|||
}
|
||||
|
||||
void OverlayFrame::clearElements() {
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
for (auto &element : list) {
|
||||
remove(element.get());
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ void OverlayFrame::clearElements() {
|
|||
void OverlayFrame::process() {
|
||||
GuiFrame::process();
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(gNotificationListMutex);
|
||||
std::lock_guard<std::mutex> lock(gNotificationListMutex);
|
||||
|
||||
float offset = -25.0f;
|
||||
for (auto &item : list) {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ char *SchriftGX2::wideCharToUTF8(const wchar_t *strChar) {
|
|||
* This routine clears all members of the font map structure and frees all allocated memory back to the system.
|
||||
*/
|
||||
void SchriftGX2::unloadFont() {
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
for (auto &dataForSize : fontData) {
|
||||
for (auto &cur : dataForSize.second.ftgxCharMap) {
|
||||
if (cur.second.texture) {
|
||||
|
|
@ -182,7 +182,7 @@ void SchriftGX2::unloadFont() {
|
|||
* @return A pointer to the allocated font structure.
|
||||
*/
|
||||
ftgxCharData *SchriftGX2::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
auto itr = fontData.find(pixelSize);
|
||||
if (itr != fontData.end()) {
|
||||
auto itr2 = itr->second.ftgxCharMap.find(charCode);
|
||||
|
|
@ -217,7 +217,6 @@ ftgxCharData *SchriftGX2::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
|
|||
textureHeight = mtx.minHeight;
|
||||
|
||||
SFT_Image img = {
|
||||
.pixels = nullptr,
|
||||
.width = textureWidth,
|
||||
.height = textureHeight,
|
||||
};
|
||||
|
|
@ -308,7 +307,7 @@ bool SchriftGX2::loadGlyphData(SFT_Image *bmp, ftgxCharData *charData, ftGX2Data
|
|||
|
||||
auto *src = (uint8_t *) bmp->pixels;
|
||||
auto *dst = (uint32_t *) charData->texture->surface.image;
|
||||
int32_t x, y;
|
||||
uint32_t x, y;
|
||||
|
||||
for (y = 0; y < bmp->height; y++) {
|
||||
for (x = 0; x < bmp->width; x++) {
|
||||
|
|
@ -347,7 +346,7 @@ int16_t SchriftGX2::getStyleOffsetWidth(uint16_t width, uint16_t format) {
|
|||
* @param format Positional format of the string.
|
||||
*/
|
||||
int16_t SchriftGX2::getStyleOffsetHeight(int16_t format, uint16_t pixelSize) {
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
std::map<int16_t, ftGX2Data>::iterator itr = fontData.find(pixelSize);
|
||||
if (itr == fontData.end()) return 0;
|
||||
|
||||
|
|
@ -392,12 +391,11 @@ int16_t SchriftGX2::getStyleOffsetHeight(int16_t format, uint16_t pixelSize) {
|
|||
*/
|
||||
|
||||
uint16_t SchriftGX2::drawText(int16_t x, int16_t y, int16_t z, const wchar_t *text, int16_t pixelSize, const glm::vec4 &color, uint16_t textStyle, uint16_t textWidth, const float &textBlur, const float &colorBlurIntensity, const glm::vec4 &blurColor) {
|
||||
(void) textWidth;
|
||||
if (!text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
|
||||
// uint16_t fullTextWidth = (textWidth > 0) ? textWidth : getWidth(text, pixelSize);
|
||||
uint16_t x_pos = x, printed = 0;
|
||||
|
|
@ -445,7 +443,7 @@ uint16_t SchriftGX2::getWidth(const wchar_t *text, int16_t pixelSize) {
|
|||
if (!text) {
|
||||
return 0;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
|
||||
uint16_t strWidth = 0;
|
||||
int32_t i = 0;
|
||||
|
|
@ -470,7 +468,7 @@ uint16_t SchriftGX2::getWidth(const wchar_t *text, int16_t pixelSize) {
|
|||
* Single char width
|
||||
*/
|
||||
uint16_t SchriftGX2::getCharWidth(const wchar_t wChar, int16_t pixelSize, const wchar_t prevChar) {
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
uint16_t strWidth = 0;
|
||||
ftgxCharData *glyphData = cacheGlyphData(wChar, pixelSize);
|
||||
|
||||
|
|
@ -496,7 +494,7 @@ uint16_t SchriftGX2::getCharWidth(const wchar_t wChar, int16_t pixelSize, const
|
|||
* @return The height of the text string in pixels.
|
||||
*/
|
||||
uint16_t SchriftGX2::getHeight(const wchar_t *text, int16_t pixelSize) {
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
getOffset(text, pixelSize);
|
||||
return fontData[pixelSize].ftgxAlign.max - fontData[pixelSize].ftgxAlign.min;
|
||||
}
|
||||
|
|
@ -515,7 +513,7 @@ void SchriftGX2::getOffset(const wchar_t *text, int16_t pixelSize, uint16_t widt
|
|||
if (!text) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(fontDataMutex);
|
||||
std::lock_guard<std::mutex> lock(fontDataMutex);
|
||||
int16_t strMax = 0, strMin = 9999;
|
||||
uint16_t currWidth = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ private:
|
|||
|
||||
void copyTextureToFramebuffer(GX2Texture *tex, int16_t screenX, int16_t screenY, int16_t screenZ, const glm::vec4 &color, const float &textBlur, const float &colorBlurIntensity, const glm::vec4 &blurColor);
|
||||
|
||||
std::recursive_mutex fontDataMutex;
|
||||
std::mutex fontDataMutex;
|
||||
|
||||
public:
|
||||
SchriftGX2(const uint8_t *fontBuffer, uint32_t bufferSize);
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
class Timer {
|
||||
public:
|
||||
Timer() { clock_gettime(CLOCK_MONOTONIC, &beg_); }
|
||||
Timer() { clock_gettime(CLOCK_REALTIME, &beg_); }
|
||||
|
||||
double elapsed() {
|
||||
clock_gettime(CLOCK_MONOTONIC, &end_);
|
||||
clock_gettime(CLOCK_REALTIME, &end_);
|
||||
return end_.tv_sec - beg_.tv_sec +
|
||||
(end_.tv_nsec - beg_.tv_nsec) / 1000000000.;
|
||||
}
|
||||
|
||||
void reset() { clock_gettime(CLOCK_MONOTONIC, &beg_); }
|
||||
void reset() { clock_gettime(CLOCK_REALTIME, &beg_); }
|
||||
|
||||
private:
|
||||
timespec beg_, end_;
|
||||
};
|
||||
};
|
||||
|
|
@ -1110,11 +1110,11 @@ simple_outline(SFT_Font *font, uint_fast32_t offset, unsigned int numContours, O
|
|||
goto failure;
|
||||
}
|
||||
|
||||
endPts = calloc(numContours, sizeof(uint_fast16_t));
|
||||
endPts = calloc(sizeof(uint_fast16_t), numContours);
|
||||
if (endPts == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
flags = calloc(numPts, sizeof(uint8_t));
|
||||
flags = calloc(sizeof(uint8_t), numPts);
|
||||
if (flags == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
|
|
@ -1435,7 +1435,7 @@ render_outline(Outline *outl, double transform[6], SFT_Image image) {
|
|||
|
||||
numPixels = (unsigned int) image.width * (unsigned int) image.height;
|
||||
|
||||
cells = calloc(numPixels, sizeof(Cell));
|
||||
cells = calloc(sizeof(Cell), numPixels);
|
||||
if (!cells) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
29
src/main.cpp
29
src/main.cpp
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_notifications");
|
||||
|
||||
#define VERSION "v0.1.4"
|
||||
#define VERSION "v0.1.1"
|
||||
|
||||
WUMS_DEPENDS_ON(homebrew_memorymapping);
|
||||
WUMS_DEPENDS_ON(homebrew_functionpatcher);
|
||||
|
|
@ -20,7 +20,7 @@ WUMS_INITIALIZE() {
|
|||
initLogging();
|
||||
|
||||
if (FunctionPatcher_InitLibrary() != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||
OSFatal("NotificationModule: FunctionPatcher_InitLibrary failed");
|
||||
OSFatal("homebrew_notifications: FunctionPatcher_InitLibrary failed");
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Patch NotificationModule functions");
|
||||
for (uint32_t i = 0; i < function_replacements_size; i++) {
|
||||
|
|
@ -38,22 +38,22 @@ WUMS_INITIALIZE() {
|
|||
sizeof(GX2ContextState),
|
||||
GX2_CONTEXT_STATE_ALIGNMENT);
|
||||
if (gContextState == nullptr) {
|
||||
OSFatal("NotificationModule: Failed to allocate gContextState");
|
||||
OSFatal("Failed to allocate gContextState");
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Allocated %d bytes for gContextState", sizeof(GX2ContextState));
|
||||
DEBUG_FUNCTION_LINE("Allocated %d bytes for gCont extState", sizeof(GX2ContextState));
|
||||
}
|
||||
|
||||
void *font = nullptr;
|
||||
uint32_t size = 0;
|
||||
if (OSGetSharedData(OS_SHAREDDATATYPE_FONT_STANDARD, 0, &font, &size) && font && size > 0) {
|
||||
OSGetSharedData(OS_SHAREDDATATYPE_FONT_STANDARD, 0, &font, &size);
|
||||
if (font && size) {
|
||||
gFontSystem = new (std::nothrow) SchriftGX2((uint8_t *) font, (int32_t) size);
|
||||
if (gFontSystem) {
|
||||
GuiText::setPresetFont(gFontSystem);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to init font system");
|
||||
}
|
||||
}
|
||||
if (gFontSystem != nullptr) {
|
||||
GuiText::setPresetFont(gFontSystem);
|
||||
} else {
|
||||
OSFatal("NotificationModule: Failed to init font system");
|
||||
}
|
||||
|
||||
OSMemoryBarrier();
|
||||
deinitLogging();
|
||||
}
|
||||
|
|
@ -65,7 +65,6 @@ WUMS_APPLICATION_STARTS() {
|
|||
}
|
||||
|
||||
WUMS_APPLICATION_ENDS() {
|
||||
gDrawReady = false;
|
||||
if (gOverlayFrame) {
|
||||
gOverlayFrame->clearElements();
|
||||
}
|
||||
|
|
@ -77,9 +76,3 @@ WUMS_APPLICATION_ENDS() {
|
|||
Texture2DShader::destroyInstance();
|
||||
deinitLogging();
|
||||
}
|
||||
|
||||
WUMS_DEINITIALIZE() {
|
||||
delete gOverlayFrame;
|
||||
delete gFontSystem;
|
||||
MEMFreeToMappedMemory(gContextState);
|
||||
}
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
#include "retain_vars.hpp"
|
||||
|
||||
GX2SurfaceFormat gTVSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2SurfaceFormat gDRCSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2ContextState *gContextState = nullptr;
|
||||
GX2ContextState *gOriginalContextState = nullptr;
|
||||
std::recursive_mutex gOverlayFrameMutex = {};
|
||||
std::vector<std::shared_ptr<Notification>> gOverlayQueueDuringStartup = {};
|
||||
OverlayFrame *gOverlayFrame = nullptr;
|
||||
SchriftGX2 *gFontSystem = nullptr;
|
||||
bool gOverlayInitDone = false;
|
||||
bool gDrawReady = false;
|
||||
GX2SurfaceFormat gTVSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2SurfaceFormat gDRCSurfaceFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8;
|
||||
GX2ContextState *gContextState = nullptr;
|
||||
GX2ContextState *gOriginalContextState = nullptr;
|
||||
OverlayFrame *gOverlayFrame = nullptr;
|
||||
SchriftGX2 *gFontSystem = nullptr;
|
||||
bool gOverlayInitDone = false;
|
||||
bool gDrawReady = false;
|
||||
|
|
@ -2,14 +2,11 @@
|
|||
#include "gui/OverlayFrame.h"
|
||||
#include "gui/SchriftGX2.h"
|
||||
#include <gx2/context.h>
|
||||
#include <mutex>
|
||||
|
||||
extern GX2SurfaceFormat gTVSurfaceFormat;
|
||||
extern GX2SurfaceFormat gDRCSurfaceFormat;
|
||||
extern GX2ContextState *gContextState;
|
||||
extern GX2ContextState *gOriginalContextState;
|
||||
extern std::recursive_mutex gOverlayFrameMutex;
|
||||
extern std::vector<std::shared_ptr<Notification>> gOverlayQueueDuringStartup;
|
||||
extern OverlayFrame *gOverlayFrame;
|
||||
extern SchriftGX2 *gFontSystem;
|
||||
extern bool gOverlayInitDone;
|
||||
|
|
|
|||
|
|
@ -8,24 +8,19 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOG_APP_TYPE "M"
|
||||
#define LOG_APP_NAME "notification_module"
|
||||
#define LOG_APP_TYPE "M"
|
||||
#define LOG_APP_NAME "notification_module"
|
||||
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||
|
||||
#define LOG(LOG_FUNC, FMT, ARGS...) LOG_EX_DEFAULT(LOG_FUNC, "", "", "", FMT, ##ARGS)
|
||||
#define LOG(LOG_FUNC, FMT, ARGS...) LOG_EX_DEFAULT(LOG_FUNC, "", "", FMT, ##ARGS)
|
||||
|
||||
#define CONSOLE_COLOR_RED "\033[31m"
|
||||
#define CONSOLE_COLOR_YELLOW "\033[33m"
|
||||
#define CONSOLE_COLOR_CYAN "\033[36m"
|
||||
#define CONSOLE_COLOR_RESET "\033[0m"
|
||||
#define LOG_EX_DEFAULT(LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ARGS...) LOG_EX(__FILENAME__, __FUNCTION__, __LINE__, LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ##ARGS)
|
||||
|
||||
#define LOG_EX_DEFAULT(LOG_FUNC, LOG_COLOR, LOG_LEVEL, LINE_END, FMT, ARGS...) LOG_EX(__FILENAME__, __FUNCTION__, __LINE__, LOG_FUNC, LOG_COLOR, LOG_LEVEL, LINE_END, FMT, ##ARGS)
|
||||
|
||||
#define LOG_EX(FILENAME, FUNCTION, LINE, LOG_FUNC, LOG_COLOR, LOG_LEVEL, LINE_END, FMT, ARGS...) \
|
||||
do { \
|
||||
LOG_FUNC(LOG_COLOR "[(%s)%18s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, FILENAME, FUNCTION, LINE, ##ARGS); \
|
||||
#define LOG_EX(FILENAME, FUNCTION, LINE, LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ARGS...) \
|
||||
do { \
|
||||
LOG_FUNC("[(%s)%18s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, FILENAME, FUNCTION, LINE, ##ARGS); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
@ -42,11 +37,11 @@ extern "C" {
|
|||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) LOG(WHBLogWritef, FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, CONSOLE_COLOR_RED, "## ERROR## ", CONSOLE_COLOR_RESET, FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, CONSOLE_COLOR_YELLOW, "##WARN ## ", CONSOLE_COLOR_RESET, FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, CONSOLE_COLOR_CYAN, "##INFO ## ", CONSOLE_COLOR_RESET, FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##WARN ## ", "", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##INFO ## ", "", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, CONSOLE_COLOR_RED, "##ERROR## ", CONSOLE_COLOR_RESET, FMT, ##ARGS);
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS);
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -58,11 +53,11 @@ extern "C" {
|
|||
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, CONSOLE_COLOR_RED, "##ERROR## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, CONSOLE_COLOR_YELLOW, "##WARN ## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, CONSOLE_COLOR_CYAN, "##INFO ## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##WARN ## ", "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##INFO ## ", "\n", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, CONSOLE_COLOR_RED, "##ERROR## ", CONSOLE_COLOR_RESET "\n", FMT, ##ARGS);
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, "##ERROR## ", "\n", FMT, ##ARGS);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ void dumpHex(const void *data, size_t size) {
|
|||
char ascii[17];
|
||||
size_t i, j;
|
||||
ascii[16] = '\0';
|
||||
DEBUG_FUNCTION_LINE("0x%p (0x0000): ", data);
|
||||
DEBUG_FUNCTION_LINE("0x%08X (0x0000): ", data);
|
||||
for (i = 0; i < size; ++i) {
|
||||
WHBLogWritef("%02X ", ((unsigned char *) data)[i]);
|
||||
if (((unsigned char *) data)[i] >= ' ' && ((unsigned char *) data)[i] <= '~') {
|
||||
|
|
@ -74,5 +74,5 @@ uint8_t SRGBComponentToRGBTable[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0
|
|||
0xBE, 0xC0, 0xC1, 0xC3, 0xC5, 0xC7, 0xC9, 0xCB, 0xCD, 0xCF, 0xD1, 0xD3, 0xD5, 0xD7, 0xDA, 0xDC,
|
||||
0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0xEB, 0xED, 0xEF, 0xF1, 0xF3, 0xF5, 0xF8, 0xFA, 0xFC, 0xFF};
|
||||
|
||||
std::recursive_mutex gNotificationListMutex;
|
||||
std::mutex gNotificationListMutex;
|
||||
std::forward_list<std::shared_ptr<Notification>> gNotificationList;
|
||||
|
|
@ -17,8 +17,8 @@ std::shared_ptr<T> make_shared_nothrow(Args &&...args) noexcept(noexcept(T(std::
|
|||
}
|
||||
|
||||
template<typename T, class Allocator, class Predicate>
|
||||
bool remove_locked_first_if(std::recursive_mutex &mutex, std::forward_list<T, Allocator> &list, Predicate pred) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex);
|
||||
bool remove_locked_first_if(std::mutex &mutex, std::forward_list<T, Allocator> &list, Predicate pred) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
auto oit = list.before_begin(), it = std::next(oit);
|
||||
while (it != list.end()) {
|
||||
if (pred(*it)) {
|
||||
|
|
@ -45,5 +45,5 @@ inline uint8_t RGBComponentToSRGB(uint8_t ci) {
|
|||
return RGBComponentToSRGBTable[ci];
|
||||
}
|
||||
|
||||
extern std::recursive_mutex gNotificationListMutex;
|
||||
extern std::mutex gNotificationListMutex;
|
||||
extern std::forward_list<std::shared_ptr<Notification>> gNotificationList;
|
||||
Loading…
Reference in New Issue
Block a user