Skip to main content
Message dialogs provide a system-level UI for displaying messages, errors, and progress to users. The PS3 handles rendering and input automatically.

Overview

The message dialog system (sysutil/msg.h) allows you to:
  • Display informational messages
  • Show Yes/No confirmation dialogs
  • Present error codes to users
  • Display progress bars for long operations

Dialog Types

Dialog appearance is controlled by combining msgType flags:
msgType type = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_OK);
msgDialogOpen2(type, "Operation complete!", callback, NULL, NULL);

Available Dialog Flags

FlagDescription
MSG_DIALOG_NORMALStandard dialog appearance
MSG_DIALOG_ERRORError dialog style
MSG_DIALOG_MUTE_ONDisable dialog sound effects
MSG_DIALOG_BKG_INVISIBLEMake background transparent
MSG_DIALOG_BTN_TYPE_OKShow OK button
MSG_DIALOG_BTN_TYPE_YESNOShow Yes/No buttons
MSG_DIALOG_DISABLE_CANCEL_ONPrevent canceling with PS button
MSG_DIALOG_DEFAULT_CURSOR_NODefault cursor on No button
MSG_DIALOG_SINGLE_PROGRESSBARShow single progress bar
MSG_DIALOG_DOUBLE_PROGRESSBARShow two progress bars

Basic Usage

1

Register System Callback

Before using dialogs, register a system utility callback:
void sysutil_callback(u64 status, u64 param, void *usrdata) {
    switch(status) {
        case SYSUTIL_EXIT_GAME:
            // Handle exit request
            break;
        case SYSUTIL_DRAW_BEGIN:
        case SYSUTIL_DRAW_END:
            // Handle draw events
            break;
    }
}

sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, sysutil_callback, NULL);
2

Create Dialog Callback

Define a callback to handle button presses:
static vs32 dialog_result = 0;

void dialog_handler(msgButton button, void *usrData) {
    switch(button) {
        case MSG_DIALOG_BTN_OK:
            dialog_result = 1;
            break;
        case MSG_DIALOG_BTN_YES:
            dialog_result = 1;
            break;
        case MSG_DIALOG_BTN_NO:
            dialog_result = 2;
            break;
        case MSG_DIALOG_BTN_ESCAPE:
            dialog_result = -1;
            break;
        case MSG_DIALOG_BTN_NONE:
            dialog_result = -1;
            break;
    }
}
3

Open the Dialog

Display the dialog and wait for user input:
msgType type = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_OK);
dialog_result = 0;

msgDialogOpen2(type, "Hello from PSL1GHT!", dialog_handler, NULL, NULL);

// Keep rendering and checking callbacks
while(!dialog_result) {
    sysUtilCheckCallback();
    flip(); // Your flip/render function
}

msgDialogAbort();

Error Code Dialogs

Display system error codes with formatted messages:
u32 errorCode = 0x80010001; // Any error code

msgDialogOpenErrorCode(errorCode, dialog_handler, NULL, NULL);

dialog_result = 0;
while(dialog_result != -1) {
    sysUtilCheckCallback();
    flip();
}

msgDialogAbort();
Error code dialogs automatically format the error code and display it to the user in a system-standard format.

Progress Bars

Show operation progress with single or double progress bars:
msgType type = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_SINGLE_PROGRESSBAR);
msgDialogOpen2(type, "Processing files...", NULL, NULL, NULL);

// Update progress
for(int i = 0; i <= 100; i += 10) {
    msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0, i);
    sysUtilCheckCallback();
    usleep(100000);
}

msgDialogClose(1000.0f); // Close after 1 second

Complete Example

Here’s a complete example from samples/sys/msgdialog/source/main.cpp:
#include <sysutil/msg.h>
#include <sysutil/sysutil.h>

static vs32 dialog_action = 0;

void dialog_handler(msgButton button, void *usrData) {
    switch(button) {
        case MSG_DIALOG_BTN_OK:
            dialog_action = 1;
            break;
        case MSG_DIALOG_BTN_NO:
        case MSG_DIALOG_BTN_ESCAPE:
            dialog_action = 2;
            break;
        case MSG_DIALOG_BTN_NONE:
            dialog_action = -1;
            break;
    }
}

void sysutil_exit_callback(u64 status, u64 param, void *usrdata) {
    switch(status) {
        case SYSUTIL_EXIT_GAME:
            break;
        case SYSUTIL_DRAW_BEGIN:
        case SYSUTIL_DRAW_END:
            break;
    }
}

int main() {
    msgType dialogType;
    
    sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, sysutil_exit_callback, NULL);
    
    // Show error code
    msgDialogOpenErrorCode(0xBADC0FFE, dialog_handler, NULL, NULL);
    msgDialogClose(3000.0f);
    
    dialog_action = 0;
    while(dialog_action != -1) {
        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();
    
    // Yes/No dialog
    dialogType = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_YESNO | 
                          MSG_DIALOG_DISABLE_CANCEL_ON | MSG_DIALOG_DEFAULT_CURSOR_NO);
    msgDialogOpen2(dialogType, "Do you want to continue?", dialog_handler, NULL, NULL);
    
    dialog_action = 0;
    while(!dialog_action) {
        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();
    
    // Show result
    dialogType = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_OK);
    if(dialog_action == 1)
        msgDialogOpen2(dialogType, "Your answer was YES", dialog_handler, NULL, NULL);
    else
        msgDialogOpen2(dialogType, "Your answer was NO", dialog_handler, NULL, NULL);
    
    dialog_action = 0;
    while(!dialog_action) {
        sysUtilCheckCallback();
        flip();
    }
    msgDialogAbort();
    
    return 0;
}

API Reference

Opening Dialogs

s32 msgDialogOpen2(
    msgType type,
    const char *msg,
    msgDialogCallback cb,
    void *usrData,
    void *unused
);

Closing Dialogs

// Close after specified milliseconds
s32 msgDialogClose(f32 waitMs);

Progress Bar Functions

// Set progress percentage (0-100)
s32 msgDialogProgressBarInc(u32 index, u32 percent);
Always call sysUtilCheckCallback() in your main loop to process dialog events. Without this, dialogs will not respond to user input.

Button Results

The callback receives one of these msgButton values:
ButtonValueDescription
MSG_DIALOG_BTN_NONE-1No button pressed yet
MSG_DIALOG_BTN_INVALID0Invalid button
MSG_DIALOG_BTN_OK1OK button pressed
MSG_DIALOG_BTN_YES1Yes button pressed
MSG_DIALOG_BTN_NO2No button pressed
MSG_DIALOG_BTN_ESCAPE3Dialog canceled

Best Practices

  • Always register a system utility callback before opening dialogs
  • Store dialog results in a static or global variable accessible from your callback
  • Call sysUtilCheckCallback() every frame to process events
  • Use msgDialogAbort() to ensure cleanup when exiting
  • Avoid opening multiple dialogs simultaneously

Build docs developers (and LLMs) love