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
+9 -1
View File
@@ -84,7 +84,15 @@ static void worker_thread_main(std::stop_token stop_token) {
spice.set_button(arrow.button, true, 1.f);
if (!arrow.previous_state) {
LOG_INFO(std::format("let me hear you say: {}", arrow.name).c_str());
if (spice.add_toast) {
spice.add_toast(
SPICE_SDK_TOAST_LEVEL_INFO,
std::format("let me hear you say: {}", arrow.name).c_str());
} else {
LOG_INFO(std::format("let me hear you say: {}", arrow.name).c_str());
}
arrow.previous_state = true;
}
} else {
+18 -18
View File
@@ -38,10 +38,10 @@ static unsigned __stdcall worker_thread(void *arg);
// this sample assumes that the game is IIDX, but it doesn't check for it.
SPICE_SDK_ENTRY_POINT
spice_sdk_entry_point(
spice_sdk_init_func *init
)
SPICE_SDK_ENTRY_POINT
spice_sdk_entry_point(
spice_sdk_init_func *init
)
{
SPICE_SDK_STATUS_CODE status;
@@ -108,59 +108,59 @@ static unsigned __stdcall worker_thread(void *arg) {
phase += 1;
switch (phase) {
case 1:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "get buttons...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_INFO, "get buttons...");
get_buttons();
break;
case 2:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "set buttons...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_WARNING, "set buttons...");
set_buttons();
break;
case 3:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "clear buttons...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_ERROR, "clear buttons...");
clear_buttons();
break;
case 4:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "get analogs...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_INFO, "get analogs...");
get_analogs();
break;
case 5:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "set analogs...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_WARNING, "set analogs...");
set_analogs();
break;
case 6:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "clear analogs...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_ERROR, "clear analogs...");
clear_analogs();
break;
case 7:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "get lights...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_INFO, "get lights...");
get_lights();
break;
case 8:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "set lights...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_WARNING, "set lights...");
set_lights();
break;
case 9:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "clear lights...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_ERROR, "clear lights...");
clear_lights();
break;
case 10:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "set touch...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_INFO, "set touch...");
set_touch();
break;
case 11:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "clear touch...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_ERROR, "clear touch...");
clear_touch();
break;
case 12:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "insert card...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_SUCCESS, "insert card...");
insert_card();
break;
case 13:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "set keypad...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_SUCCESS, "set keypad...");
set_keypad();
break;
case 14:
spice.log(SPICE_SDK_LOG_LEVEL_INFO, "sample_v0", "clear keypad...");
spice.add_toast(SPICE_SDK_TOAST_LEVEL_ERROR, "clear keypad...");
clear_keypad();
break;
default: