mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-07-02 02:35:43 +02:00
add filter options
This commit is contained in:
parent
713b5f6bed
commit
d004c688c2
4 changed files with 40 additions and 45 deletions
|
|
@ -28,3 +28,4 @@ There are two main applications, an SDL-based app (`eden-cli`) and a Qt based ap
|
||||||
- `--version/-v`: Display version and quit.
|
- `--version/-v`: Display version and quit.
|
||||||
- `--input-profile/-i`: Specifies input profile name to use (for player #0 only).
|
- `--input-profile/-i`: Specifies input profile name to use (for player #0 only).
|
||||||
- `--null-render/-n`: Forces the usage of the "Null" render backend irrespective of settings.
|
- `--null-render/-n`: Forces the usage of the "Null" render backend irrespective of settings.
|
||||||
|
- `--filter/-F`: Sets the debug log filter irrespective of settings.
|
||||||
|
|
|
||||||
|
|
@ -167,69 +167,56 @@ void EmuWindow_SDL3::Fullscreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuWindow_SDL3::OnEvent(SDL_Event& event) {
|
void EmuWindow_SDL3::OnEvent(SDL_Event& event) {
|
||||||
// Called on main thread
|
// Notice how we skip the "update title" aspect on most events
|
||||||
|
// this is because some WMs do NOT like changing titles while resizing
|
||||||
|
// so let's just... not do that, thanks :)
|
||||||
|
// Afterall we don't really expect the user to pay attention to the titlebar
|
||||||
|
// while they're moving a lot of shit around...
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_EVENT_WINDOW_RESIZED:
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||||
case SDL_EVENT_WINDOW_MAXIMIZED:
|
case SDL_EVENT_WINDOW_MAXIMIZED:
|
||||||
case SDL_EVENT_WINDOW_RESTORED:
|
case SDL_EVENT_WINDOW_RESTORED:
|
||||||
OnResize();
|
return OnResize();
|
||||||
break;
|
|
||||||
case SDL_EVENT_WINDOW_MINIMIZED:
|
case SDL_EVENT_WINDOW_MINIMIZED:
|
||||||
is_shown = false;
|
is_shown = false;
|
||||||
OnResize();
|
return OnResize();
|
||||||
break;
|
|
||||||
case SDL_EVENT_WINDOW_EXPOSED:
|
case SDL_EVENT_WINDOW_EXPOSED:
|
||||||
is_shown = true;
|
is_shown = true;
|
||||||
OnResize();
|
return OnResize();
|
||||||
break;
|
|
||||||
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
|
||||||
is_open = false;
|
is_open = false;
|
||||||
break;
|
return;
|
||||||
case SDL_EVENT_KEY_DOWN:
|
case SDL_EVENT_KEY_DOWN:
|
||||||
case SDL_EVENT_KEY_UP:
|
case SDL_EVENT_KEY_UP:
|
||||||
OnKeyEvent(static_cast<int>(event.key.scancode), event.key.down ? 1 : 0);
|
return OnKeyEvent(int(event.key.scancode), event.key.down ? 1 : 0);
|
||||||
break;
|
|
||||||
case SDL_EVENT_MOUSE_MOTION:
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
// ignore if it came from touch
|
// ignore if it came from touch
|
||||||
if (event.button.which != SDL_TOUCH_MOUSEID)
|
if (event.button.which != SDL_TOUCH_MOUSEID)
|
||||||
OnMouseMotion(event.motion.x, event.motion.y);
|
OnMouseMotion(event.motion.x, event.motion.y);
|
||||||
break;
|
return;
|
||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||||
// ignore if it came from touch
|
// ignore if it came from touch
|
||||||
if (event.button.which != SDL_TOUCH_MOUSEID) {
|
if (event.button.which != SDL_TOUCH_MOUSEID) {
|
||||||
OnMouseButton(event.button.button, event.button.down ? 1 : 0,
|
OnMouseButton(event.button.button, event.button.down ? 1 : 0, s32(event.button.x), s3>(event.button.y));
|
||||||
static_cast<s32>(event.button.x), static_cast<s32>(event.button.y));
|
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
case SDL_EVENT_FINGER_DOWN:
|
case SDL_EVENT_FINGER_DOWN:
|
||||||
OnFingerDown(event.tfinger.x, event.tfinger.y,
|
return OnFingerDown(event.tfinger.x, event.tfinger.y, std::size_t(event.tfinger.touchID));
|
||||||
static_cast<std::size_t>(event.tfinger.touchID));
|
|
||||||
break;
|
|
||||||
case SDL_EVENT_FINGER_MOTION:
|
case SDL_EVENT_FINGER_MOTION:
|
||||||
OnFingerMotion(event.tfinger.x, event.tfinger.y,
|
return OnFingerMotion(event.tfinger.x, event.tfinger.y, std::size_t(event.tfinger.touchID));
|
||||||
static_cast<std::size_t>(event.tfinger.touchID));
|
|
||||||
break;
|
|
||||||
case SDL_EVENT_FINGER_UP:
|
case SDL_EVENT_FINGER_UP:
|
||||||
OnFingerUp();
|
return OnFingerUp();
|
||||||
break;
|
|
||||||
case SDL_EVENT_QUIT:
|
case SDL_EVENT_QUIT:
|
||||||
is_open = false;
|
is_open = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (auto const current_time = SDL_GetTicks(); current_time > last_time + 2000) {
|
||||||
const u32 current_time = SDL_GetTicks();
|
auto const results = system.GetAndResetPerfStats();
|
||||||
if (current_time > last_time + 2000) {
|
auto const title = fmt::format("{} | {}-{} | FPS: {:.0f} ({:.0f}%)", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc, results.average_game_fps, results.emulation_speed * 100.0);
|
||||||
const auto results = system.GetAndResetPerfStats();
|
|
||||||
const auto title = fmt::format("{} | {}-{} | FPS: {:.0f} ({:.0f}%)",
|
|
||||||
Common::g_build_fullname,
|
|
||||||
Common::g_scm_branch,
|
|
||||||
Common::g_scm_desc,
|
|
||||||
results.average_game_fps,
|
|
||||||
results.emulation_speed * 100.0);
|
|
||||||
SDL_SetWindowTitle(render_window, title.c_str());
|
SDL_SetWindowTitle(render_window, title.c_str());
|
||||||
last_time = current_time;
|
last_time = current_time;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,7 @@ extern "C" SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
std::string password{};
|
std::string password{};
|
||||||
std::string address{};
|
std::string address{};
|
||||||
std::string input_profile{};
|
std::string input_profile{};
|
||||||
|
std::optional<std::string> log_filter{};
|
||||||
u16 port = Network::DefaultRoomPort;
|
u16 port = Network::DefaultRoomPort;
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
|
@ -235,6 +236,7 @@ extern "C" SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"input-profile", no_argument, 0, 'i'},
|
{"input-profile", no_argument, 0, 'i'},
|
||||||
{"null-render", no_argument, 0, 'n'},
|
{"null-render", no_argument, 0, 'n'},
|
||||||
|
{"filter", no_argument, 0, 'F'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
@ -308,6 +310,10 @@ extern "C" SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
case 'n':
|
case 'n':
|
||||||
force_null_render = true;
|
force_null_render = true;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
log_filter = argv[optind];
|
||||||
|
++optind;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -324,7 +330,7 @@ extern "C" SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
||||||
// apply the log_filter setting
|
// apply the log_filter setting
|
||||||
// the logger was initialized before and doesn't pick up the filter on its own
|
// the logger was initialized before and doesn't pick up the filter on its own
|
||||||
Common::Log::Filter filter;
|
Common::Log::Filter filter;
|
||||||
filter.ParseFilterString(Settings::values.log_filter.GetValue());
|
filter.ParseFilterString(log_filter.value_or(Settings::values.log_filter.GetValue()));
|
||||||
Common::Log::SetGlobalFilter(filter);
|
Common::Log::SetGlobalFilter(filter);
|
||||||
|
|
||||||
if (!program_args.empty()) {
|
if (!program_args.empty()) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { join } from 'path';
|
||||||
|
|
||||||
// DO NOT RUN THIS IN ANY PRODUCTION ENVIRONMENT EVER
|
// DO NOT RUN THIS IN ANY PRODUCTION ENVIRONMENT EVER
|
||||||
const server = createServer((req, res) => {
|
const server = createServer((req, res) => {
|
||||||
console.log(`reuqest? ${req.url}`);
|
console.log(`get ${req.url}`);
|
||||||
if (req.url === '/') {
|
if (req.url === '/') {
|
||||||
// https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running
|
// https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Loading_and_running
|
||||||
// If your browser doesn't support fetch... HAHA GET FUCKED
|
// If your browser doesn't support fetch... HAHA GET FUCKED
|
||||||
|
|
@ -22,40 +22,41 @@ const server = createServer((req, res) => {
|
||||||
<head>
|
<head>
|
||||||
<title>eden-cli</title>
|
<title>eden-cli</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin:0;padding:0;background-color:black;font-family:Monospace,Tahoma,Arial;">
|
<body style="margin:0;padding:0;background-color:black;font-family:Monospace,Tahoma,Arial;width:100%;height:100%;">
|
||||||
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:2px;width:100%;height:100%;">
|
||||||
|
<canvas id="canvas" oncontextmenu="event.preventDefault()" style="width:100%;height:100%;background-color:gray;"></canvas>
|
||||||
|
<div id="tty-stdout"></div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var Module = { //do not prepend var
|
var Module = { //do not prepend var
|
||||||
mainScriptUrlOrBlob: 'eden-cli.js',
|
mainScriptUrlOrBlob: 'eden-cli.js',
|
||||||
|
arguments: ['--null-render', '-F', '*:Trace', 'game.nro'],
|
||||||
|
canvas: document.getElementById('canvas'),
|
||||||
print: (e) => {
|
print: (e) => {
|
||||||
e = e.replace('[1;31m', '<span style="color:red;font-weight:bold;">');
|
e = e.replace('[1;31m', '<span style="color:red;font-weight:bold;">');
|
||||||
e = e.replace('[0;37m', '<span style="color:white;font-weight:bold;">');
|
e = e.replace('[0;37m', '<span style="color:white;font-weight:bold;">');
|
||||||
e = e.replace('[1;35m', '<span style="color:pink;font-weight:bold;">');
|
e = e.replace('[1;35m', '<span style="color:pink;font-weight:bold;">');
|
||||||
e = e.replace('[1;33m', '<span style="color:yellow;font-weight:bold;">');
|
e = e.replace('[1;33m', '<span style="color:yellow;font-weight:bold;">');
|
||||||
e = e.replace('[0m', '</span>');
|
e = e.replace('[0m', '</span>');
|
||||||
tty_stdout.innerHTML += \`\${e}</br>\`;
|
document.getElementById('tty-stdout').innerHTML += \`\${e}</br>\`;
|
||||||
},
|
},
|
||||||
printErr: (e) => {
|
printErr: (e) => {
|
||||||
tty_stdout.innerHTML += \`<span style="color:red">\${e}</span></br>\`;
|
document.getElementById('tty-stdout').innerHTML += \`<span style="color:red">\${e}</span></br>\`;
|
||||||
},
|
},
|
||||||
// not a wasm func but idc
|
// not a wasm func but idc
|
||||||
printInternal: (e) => {
|
printInternal: (e) => {
|
||||||
tty_stdout.innerHTML += \`<span style="color:pink">Internal WASM: \${e}</span></br>\`;
|
document.getElementById('tty-stdout').innerHTML += \`<span style="color:white">Internal WASM: \${e}</span></br>\`;
|
||||||
},
|
},
|
||||||
onRuntimeInitialized: () => { Module.printInternal("runtime ok"); },
|
onRuntimeInitialized: () => { Module.printInternal("runtime ok"); },
|
||||||
setStatus: (e) => { Module.printInternal(e); },
|
setStatus: (e) => { Module.printInternal(e); },
|
||||||
monitorRunDependencies: (e) => { Module.printInternal("monitor deps: " + e); },
|
monitorRunDependencies: (e) => { Module.printInternal("monitor deps: " + e); },
|
||||||
__wasm_call_ctors: () => { Module.printInternal("ctors beep"); },
|
__wasm_call_ctors: () => { Module.printInternal("ctors beep"); },
|
||||||
};
|
};
|
||||||
var tty_stdout = document.createElement('div');
|
|
||||||
document.body.appendChild(tty_stdout);
|
|
||||||
Module.arguments = ['--null-render', 'game.nro'];
|
|
||||||
|
|
||||||
var gameNroFileBuffer = {};
|
var gameNroFileBuffer = {};
|
||||||
|
|
||||||
Module.printInternal("Atomics: " + window.Atomics);
|
Module.printInternal(\`Atomics: \${window.Atomics}, SharedArrayBuffer: \${window.SharedArrayBuffer}\`);
|
||||||
Module.printInternal("SharedArrayBuffer: " + window.SharedArrayBuffer);
|
|
||||||
Module.printInternal("trying to load script (if it hangs here check console)");
|
Module.printInternal("trying to load script (if it hangs here check console)");
|
||||||
|
|
||||||
fetch('game.nro').then((resp) => {
|
fetch('game.nro').then((resp) => {
|
||||||
if (!resp.ok)
|
if (!resp.ok)
|
||||||
throw Error(\`\${resp.status}\`);
|
throw Error(\`\${resp.status}\`);
|
||||||
|
|
@ -65,7 +66,7 @@ fetch('game.nro').then((resp) => {
|
||||||
Module.printInternal("buffer: " + gameNroFileBuffer);
|
Module.printInternal("buffer: " + gameNroFileBuffer);
|
||||||
|
|
||||||
// load the thingy AFTER loading the nro
|
// load the thingy AFTER loading the nro
|
||||||
Module.printInternal(\`loading from ${build_dir}\${Module.mainScriptUrlOrBlob}\`);
|
Module.printInternal(\`loading from ${build_dir}/\${Module.mainScriptUrlOrBlob}\`);
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = '/eden-cli.js';
|
script.src = '/eden-cli.js';
|
||||||
script.onload = () => {
|
script.onload = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue