overlay: toast notifications (#704)

## Link to GitHub Issue or related Pull Request, if one exists
n/a

## Description of change
Adds toast notifications to the overlay.

Toast notifications are transient windows (shown for about 4 seconds).
These are drawn on top of the game even when the overlay is inactive
(i.e., when no window is open), and does not cause any input sink
behavior.

Add toasts for some common user-driven actions that could use a
notification, such as:

* screenshot
* card insert
* PIN macro
* API client connect/disconnect
* virtual printer
* screen resize toggle / scene switch

Add an option to change where the toasts are displayed, or to turn it
off entirely.

Add SDK function for it, and add it to the samples.

## Testing
Tested DDR (shown at bottom right, as is for most games) and RB (shown
top right by default).
This commit is contained in:
bicarus
2026-05-27 00:45:27 -07:00
committed by GitHub
parent d929cdf7c8
commit 311404f56b
20 changed files with 574 additions and 43 deletions
+37 -1
View File
@@ -14,14 +14,16 @@
#include "util/time.h"
#include "util/utils.h"
#include "overlay/overlay.h"
#include "overlay/notifications.h"
#include "bt5api.h"
// state
static constexpr double NOTIFICATION_THROTTLE_SECONDS = 3.0;
static bool CARD_INSERT[2] = {false, false};
static double CARD_INSERT_TIME[2] = {0, 0};
static double CARD_INSERT_TIMEOUT = 2.0;
static char CARD_INSERT_UID[2][8];
static char CARD_INSERT_UID[2][8] = {{0}, {0}};
static char CARD_INSERT_UID_ENABLE[2] = {false, false};
static int COIN_STOCK = 0;
static bool COIN_BLOCK = false;
@@ -119,6 +121,12 @@ bool eamuse_get_card(const std::filesystem::path &path, uint8_t *card, int index
"{} card override contains an invalid character sequence at byte {} (16 characters, 0-9/A-F only)",
card_override, n);
overlay::notifications::add_throttled(
overlay::notifications::Severity::Error,
fmt::format("eamuse.card_override_error.p{}", index + 1),
NOTIFICATION_THROTTLE_SECONDS,
fmt::format("[P{}] invalid card override", index + 1));
return false;
}
}
@@ -149,6 +157,11 @@ bool eamuse_get_card_from_file(const std::filesystem::path &path, uint8_t *card,
std::ifstream f(path);
if (!f) {
log_warning("eamuse", "{} can not be opened!", path);
overlay::notifications::add_throttled(
overlay::notifications::Severity::Error,
fmt::format("eamuse.card_file_error.p{}", index + 1),
NOTIFICATION_THROTTLE_SECONDS,
fmt::format("[P{}] can't open card file", index + 1));
return false;
}
@@ -160,6 +173,12 @@ bool eamuse_get_card_from_file(const std::filesystem::path &path, uint8_t *card,
// check size
if (length < 16) {
log_warning("eamuse", "{} is too small (must be at least 16 characters)", path);
overlay::notifications::add_throttled(
overlay::notifications::Severity::Error,
fmt::format("eamuse.card_file_error.p{}", index + 1),
NOTIFICATION_THROTTLE_SECONDS,
fmt::format("[P{}] card file error", index + 1));
return false;
}
@@ -179,6 +198,11 @@ bool eamuse_get_card_from_file(const std::filesystem::path &path, uint8_t *card,
"{} contains an invalid character sequence at byte {} (16 characters, 0-9/A-F only)",
path, n);
overlay::notifications::add_throttled(
overlay::notifications::Severity::Error,
fmt::format("eamuse.card_file_error.p{}", index + 1),
NOTIFICATION_THROTTLE_SECONDS,
fmt::format("[P{}] card file error", index + 1));
return false;
}
}
@@ -251,8 +275,16 @@ bool eamuse_card_insert_consume(int active_count, int unit_id) {
auto offset = unit_id * games::KeypadButtons::Size;
if ((CARD_INSERT[index] && fabs(get_performance_seconds() - CARD_INSERT_TIME[index]) < CARD_INSERT_TIMEOUT)
|| GameAPI::Buttons::getState(RI_MGR, keypad_buttons->at(games::KeypadButtons::InsertCard + offset))) {
log_info("eamuse", "[P{}] Card insert on reader (total active count: {})", unit_id+1, active_count);
CARD_INSERT[index] = false;
overlay::notifications::add_throttled(
overlay::notifications::Severity::Info,
fmt::format("eamuse.card_inserted.p{}", unit_id + 1),
NOTIFICATION_THROTTLE_SECONDS,
fmt::format("[P{}] card inserted", unit_id + 1));
return true;
}
@@ -394,6 +426,10 @@ void eamuse_pin_macro_start_thread() {
log_info("eamuse", "AUTO_PIN_MACRO_REQUEST detected for P{}", unit+1);
}
if (key_press || auto_request) {
overlay::notifications::add(
overlay::notifications::Severity::Info,
fmt::format("[P{}] PIN macro fired ({})",
unit + 1, auto_request ? "auto" : "manual"));
active_unit = unit;
// Reset key index
pin_index[unit] = 0;