diff --git a/Makefile b/Makefile index 6f150830f..9956d44c0 100644 --- a/Makefile +++ b/Makefile @@ -124,6 +124,9 @@ build_unix: res ## build unix port build_unix_noui: res ## build unix port without UI support $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_NOUI=1 +build_unix_raspi: res ## build unix port for Raspberry Pi + $(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_RASPI=1 + build_cross: ## build mpy-cross port $(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS) diff --git a/SConscript.unix b/SConscript.unix index 1b7199749..9503aa2e4 100644 --- a/SConscript.unix +++ b/SConscript.unix @@ -104,6 +104,8 @@ SOURCE_MOD += [ ] if ARGUMENTS.get('TREZOR_EMULATOR_NOUI', 0): CPPDEFINES_MOD += ['TREZOR_EMULATOR_NOUI'] +if ARGUMENTS.get('TREZOR_EMULATOR_RASPI', 0): + CPPDEFINES_MOD += ['TREZOR_EMULATOR_RASPI'] # modtrezorutils SOURCE_MOD += [ diff --git a/embed/extmod/modtrezorui/display-unix.h b/embed/extmod/modtrezorui/display-unix.h index d3f135331..5d5983199 100644 --- a/embed/extmod/modtrezorui/display-unix.h +++ b/embed/extmod/modtrezorui/display-unix.h @@ -26,10 +26,17 @@ #if TREZOR_MODEL == T +#ifdef TREZOR_EMULATOR_RASPI +#define WINDOW_WIDTH 480 +#define WINDOW_HEIGHT 320 +#define TOUCH_OFFSET_X 110 +#define TOUCH_OFFSET_Y 40 +#else #define WINDOW_WIDTH 400 #define WINDOW_HEIGHT 600 #define TOUCH_OFFSET_X 80 #define TOUCH_OFFSET_Y 110 +#endif #elif TREZOR_MODEL == 1 @@ -92,7 +99,13 @@ void display_init(void) ensure(secfalse, "SDL_Init error"); } atexit(SDL_Quit); - SDL_Window *win = SDL_CreateWindow("TREZOR Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN); + SDL_Window *win = SDL_CreateWindow("TREZOR Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, +#ifdef TREZOR_EMULATOR_RASPI + SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN +#else + SDL_WINDOW_SHOWN +#endif + ); if (!win) { printf("%s\n", SDL_GetError()); ensure(secfalse, "SDL_CreateWindow error"); @@ -109,7 +122,11 @@ void display_init(void) TEXTURE = SDL_CreateTexture(RENDERER, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, DISPLAY_RESX, DISPLAY_RESY); SDL_SetTextureBlendMode(TEXTURE, SDL_BLENDMODE_BLEND); // TODO: find better way how to embed/distribute background image +#ifdef TREZOR_EMULATOR_RASPI + BACKGROUND = IMG_LoadTexture(RENDERER, "../embed/unix/background_raspi.jpg"); +#else BACKGROUND = IMG_LoadTexture(RENDERER, "../embed/unix/background_" XSTR(TREZOR_MODEL) ".jpg"); +#endif if (BACKGROUND) { SDL_SetTextureBlendMode(BACKGROUND, SDL_BLENDMODE_NONE); sdl_touch_offset_x = TOUCH_OFFSET_X; @@ -120,8 +137,13 @@ void display_init(void) sdl_touch_offset_y = EMULATOR_BORDER; } DISPLAY_BACKLIGHT = 0; +#ifdef TREZOR_EMULATOR_RASPI + DISPLAY_ORIENTATION = 270; + SDL_ShowCursor(SDL_DISABLE); +#else DISPLAY_ORIENTATION = 0; #endif +#endif } static void display_set_window(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) diff --git a/embed/unix/background_raspi.jpg b/embed/unix/background_raspi.jpg new file mode 100644 index 000000000..19491ed93 Binary files /dev/null and b/embed/unix/background_raspi.jpg differ