feat(sim): web viewer /sim, touch injection, fast screenshot, SIM_DISPLAY_W/H
This commit is contained in:
@@ -29,7 +29,28 @@ static Driver* const simulator_drivers[] = {
|
||||
// These devices have no real bus to attach to (SDL has no notion of one), but every non-root
|
||||
// device is still expected to have a parent (see Device::parent) - they're parented to root once
|
||||
// it's available below.
|
||||
static const SdlDisplayConfig sdl_display_config = { 640, 480 };
|
||||
// Display resolution is overridable at runtime via SIM_DISPLAY_W/H env vars
|
||||
// so the sim can match real hardware (e.g. ES3C35P 3.5" = 320x480 portrait,
|
||||
// ES3C28P 2.8" = 320x240 landscape). Defaults to 640x480.
|
||||
static uint16_t sim_display_width(void) {
|
||||
const char* w = getenv("SIM_DISPLAY_W");
|
||||
if (w != nullptr) {
|
||||
long v = atol(w);
|
||||
if (v >= 120 && v <= 2048) return (uint16_t)v;
|
||||
}
|
||||
return 480;
|
||||
}
|
||||
|
||||
static uint16_t sim_display_height(void) {
|
||||
const char* h = getenv("SIM_DISPLAY_H");
|
||||
if (h != nullptr) {
|
||||
long v = atol(h);
|
||||
if (v >= 120 && v <= 2048) return (uint16_t)v;
|
||||
}
|
||||
return 320;
|
||||
}
|
||||
|
||||
static SdlDisplayConfig sdl_display_config = { 480, 320 };
|
||||
static Device sdl_display_device {};
|
||||
static Device sdl_pointer_device {};
|
||||
static Device sdl_keyboard_device {};
|
||||
@@ -81,6 +102,10 @@ static void on_root_started(Device* device, DeviceEvent event, void* context) {
|
||||
return;
|
||||
}
|
||||
|
||||
sdl_display_config.horizontal_resolution = sim_display_width();
|
||||
sdl_display_config.vertical_resolution = sim_display_height();
|
||||
LOG_I(TAG, "Sim display %dx%d (SIM_DISPLAY_W/H override, default 480x320 landscape)",
|
||||
sdl_display_config.horizontal_resolution, sdl_display_config.vertical_resolution);
|
||||
construct_add_start(&sdl_display_device, device, "display0", &sdl_display_config, "tactility,sdl-display");
|
||||
construct_add_start(&sdl_pointer_device, device, "pointer0", nullptr, "tactility,sdl-pointer");
|
||||
construct_add_start(&sdl_keyboard_device, device, "keyboard0", nullptr, "tactility,sdl-keyboard");
|
||||
|
||||
Reference in New Issue
Block a user