RedDucks edited this page Nov 3, 2017 · 3 revisions

Events

To fully utilize themes you will need to hook into the many events emitted (not all possible events are documented. All missing events were deemed useless to themes and thus have not been documented)

ipcRenderer

CemUI wraps themes into an iframe for quick, live switching. The iframe is given a custom window property for the ipcRenderer, removing the step of requiring it in manually.

init

Start wrapper and theme loading

Sent from: ipcRenderer

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.send('init');

open_dev

Opens the developer console

Sent from: ipcRenderer

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.send('open_dev');

theme_finished_loading

Tells backend (ipcMain) the theme is finished loading

Sent from: ipcRenderer

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

// Things to do before theme is finished
ipcRenderer.send('theme_finished_loading');

open_menu

Opens the settings menu sidebar

Sent from: ipcRenderer

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#open-menu-btn').onclick = () => {
    ipcRenderer.send('open_menu');
}

check_for_update

Manually checks for CemUI update

Sent from: ipcRenderer

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#update-check-btn').onclick = () => {
    ipcRenderer.send('check_for_update');
}

play_rom

Plays a rom

Sent from: ipcRenderer

Type: String

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#00050000-1010ED00').onclick = () => {
    // 00050000-1010ED00 is the full qualified TID (title ID)
    // for Mario Kart 8, EUR
    ipcRenderer.send('play_rom', '00050000-1010ED00');
}

open_rom

Opens a rom folder

Sent from: ipcRenderer

Type: String

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#00050000-1010ED00').onclick = () => {
    // 00050000-1010ED00 is the full qualified TID (title ID)
    // for Mario Kart 8, EUR
    ipcRenderer.send('open_rom', '00050000-1010ED00');
}

make_shortcut

Makes a desktop shortcut for a specific game for a specific emulator

Sent from: ipcRenderer

Type: Object

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#00050000-1010ED00').onclick = () => {
    // 00050000-1010ED00 is the full qualified TID (title ID)
    // for Mario Kart 8, EUR
    ipcRenderer.send('make_shortcut', {
        emu: 'Default', // name of the Cemu instance. 'Default' is instance made during setup
        rom: '00050000-1010ED00' // The fully qualified TID of the rom
    });
}

set_favorite

Sets game as favorite

Sent from: ipcRenderer

Type: String

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#00050000-1010ED00').onclick = () => {
    // 00050000-1010ED00 is the full qualified TID (title ID)
    // for Mario Kart 8, EUR
    ipcRenderer.send('set_favorite', '00050000-1010ED00');
}

remove_favorite

Unsets game as favorite

Sent from: ipcRenderer

Type: String

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#00050000-1010ED00').onclick = () => {
    // 00050000-1010ED00 is the full qualified TID (title ID)
    // for Mario Kart 8, EUR
    ipcRenderer.send('remove_favorite', '00050000-1010ED00');
}

update_game_settings

Sets game profile settings

Sent from: ipcRenderer

Type: Object

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

document.querySelector('#00050000-1010ED00').onclick = () => {
    // 00050000-1010ED00 is the full qualified TID (title ID)
    // for Mario Kart 8, EUR
    ipcRenderer.send('make_shortcut', {
        emu: 'Default', // name of the Cemu instance. 'Default' is instance made during setup
        rom: '00050000-1010ED00', // The fully qualified TID of the rom
        settings: {
            // JSON-ified ini settings
        }
    });
}

ask_for_emulator_list

Tells ipcMain to send back emulator_list

Sent from: ipcRenderer

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.send('ask_for_emulator_list');

init_complete

Initialization complete. See Game Objects for information on game object structure

Sent from: ipcMain

Type: Object

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.on('init_complete', (event, data) => {
    console.log(data.library); // You game library. Array of Game Objects
    console.log(data.suggested); // Suggested games. Array of Game Objects
    console.log(data.most_played); // You game library organized by plays. Array of Game Objects
});

controller_event

Generic controller event. CemUI uses See Controller.js for controller events. All controller events passed by CemUI are Controller.js events, but only the detail property

Sent from: ipcMain

Type: Object

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.on('controller_event', (event, data) => {
    console.log('controller event');
});

controller_found

A controller was found. CemUI uses See Controller.js for controller events. All controller events passed by CemUI are Controller.js events, but only the detail property

Sent from: ipcMain

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.on('controller_found', (event, data) => {
    console.log('controller found, do something');
});

controller_button_press

A button was pressed. CemUI uses See Controller.js for controller events. All controller events passed by CemUI are Controller.js events, but only the detail property

Sent from: ipcMain

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.on('controller_button_press', (event, data) => {
    switch (data.name) {
        case 'DPAD_UP': // ANALOG STICKS SEND DPAD EVENTS
            // Move up?
            break;
        case 'DPAD_DOWN': // ANALOG STICKS SEND DPAD EVENTS
            // Move down?
            break;
        case 'DPAD_LEFT': // ANALOG STICKS SEND DPAD EVENTS
            // Move left?
            break;
        case 'DPAD_RIGHT': // ANALOG STICKS SEND DPAD EVENTS
            // Move right?
            break;
        case 'START':
            // Handle 'Start' button event
            break;
        case 'FACE_1': // A button XBox
            // Handle button event
            break;
        case 'FACE_2': // B button XBox
            // Handle button event
            break;
    }
});

emulator_list

Sends a list of all stored Cemu instances. See Cemu Instances for information on instance structure

Sent from: ipcMain

Type: Array

let ipcRenderer = window.ipcRenderer; // Grab ipcRenderer from `window`

ipcRenderer.on('emulator_list', (event, data) => {
    // Do something like make dropdowns and such with the emulator list
});
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.