X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fplat_sdl.c;h=4e77dc35eec712f4c8031b2d0a65b603c8f6b21b;hp=e3d70f60929cb1b2a0463eb8adc1024c201ab469;hb=bcfc48e326fd502e77654330ce4b902e7db8c2dc;hpb=69e482e3def6669a4fa921d07f9ba04883d7de34 diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index e3d70f60..4e77dc35 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -1,5 +1,5 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2011,2012 + * (C) Gražvydas "notaz" Ignotas, 2011-2013 * * This work is licensed under the terms of any of these licenses * (at your option): @@ -17,8 +17,9 @@ #include "libpicofe/fonts.h" #include "libpicofe/plat_sdl.h" #include "libpicofe/gl.h" -#include "../plugins/gpulib/cspace.h" +#include "cspace.h" #include "plugin_lib.h" +#include "plugin.h" #include "main.h" #include "plat.h" #include "revision.h" @@ -52,11 +53,46 @@ static const struct in_default_bind in_sdl_defbinds[] = { { 0, 0, 0 } }; +const struct menu_keymap in_sdl_key_map[] = +{ + { SDLK_UP, PBTN_UP }, + { SDLK_DOWN, PBTN_DOWN }, + { SDLK_LEFT, PBTN_LEFT }, + { SDLK_RIGHT, PBTN_RIGHT }, + { SDLK_RETURN, PBTN_MOK }, + { SDLK_ESCAPE, PBTN_MBACK }, + { SDLK_SEMICOLON, PBTN_MA2 }, + { SDLK_QUOTE, PBTN_MA3 }, + { SDLK_LEFTBRACKET, PBTN_L }, + { SDLK_RIGHTBRACKET, PBTN_R }, +}; + +const struct menu_keymap in_sdl_joy_map[] = +{ + { SDLK_UP, PBTN_UP }, + { SDLK_DOWN, PBTN_DOWN }, + { SDLK_LEFT, PBTN_LEFT }, + { SDLK_RIGHT, PBTN_RIGHT }, + /* joystick */ + { SDLK_WORLD_0, PBTN_MOK }, + { SDLK_WORLD_1, PBTN_MBACK }, + { SDLK_WORLD_2, PBTN_MA2 }, + { SDLK_WORLD_3, PBTN_MA3 }, +}; + +static const struct in_pdata in_sdl_platform_data = { + .defbinds = in_sdl_defbinds, + .key_map = in_sdl_key_map, + .kmap_size = sizeof(in_sdl_key_map) / sizeof(in_sdl_key_map[0]), + .joy_map = in_sdl_joy_map, + .jmap_size = sizeof(in_sdl_joy_map) / sizeof(in_sdl_joy_map[0]), +}; + static int psx_w, psx_h; static void *shadow_fb, *menubg_img; static int in_menu; -static int change_video_mode(void) +static int change_video_mode(int force) { int w, h; @@ -69,7 +105,17 @@ static int change_video_mode(void) h = psx_h; } - return plat_sdl_change_video_mode(w, h, 0); + return plat_sdl_change_video_mode(w, h, force); +} + +static void resize_cb(int w, int h) +{ + // used by some plugins.. + pl_rearmed_cbs.screen_w = w; + pl_rearmed_cbs.screen_h = h; + pl_rearmed_cbs.gles_display = gl_es_display; + pl_rearmed_cbs.gles_surface = gl_es_surface; + plugin_call_rearmed_cbs(); } static void quit_cb(void) @@ -77,10 +123,22 @@ static void quit_cb(void) emu_core_ask_exit(); } +static void get_layer_pos(int *x, int *y, int *w, int *h) +{ + // always fill entire SDL window + *x = *y = 0; + *w = pl_rearmed_cbs.screen_w; + *h = pl_rearmed_cbs.screen_h; +} + void plat_init(void) { + int shadow_size; int ret; + plat_sdl_quit_cb = quit_cb; + plat_sdl_resize_cb = resize_cb; + ret = plat_sdl_init(); if (ret != 0) exit(1); @@ -88,19 +146,23 @@ void plat_init(void) in_menu = 1; SDL_WM_SetCaption("PCSX-ReARMed " REV, NULL); - shadow_fb = malloc(640 * 512 * 2); - menubg_img = malloc(640 * 512 * 2); + shadow_size = g_menuscreen_w * g_menuscreen_h * 2; + if (shadow_size < 640 * 512 * 2) + shadow_size = 640 * 512 * 2; + + shadow_fb = malloc(shadow_size); + menubg_img = malloc(shadow_size); if (shadow_fb == NULL || menubg_img == NULL) { fprintf(stderr, "OOM\n"); exit(1); } - in_sdl_init(in_sdl_defbinds, plat_sdl_event_handler); + in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler); in_probe(); pl_rearmed_cbs.only_16bpp = 1; + pl_rearmed_cbs.pl_get_layer_pos = get_layer_pos; bgr_to_uyvy_init(); - plat_sdl_quit_cb = quit_cb; } void plat_finish(void) @@ -168,7 +230,7 @@ void *plat_gvideo_set_mode(int *w, int *h, int *bpp) { psx_w = *w; psx_h = *h; - change_video_mode(); + change_video_mode(0); if (plat_sdl_overlay != NULL) { pl_plat_clear = plat_sdl_overlay_clear; pl_plat_blit = overlay_blit; @@ -210,6 +272,8 @@ void plat_gvideo_close(void) void plat_video_menu_enter(int is_rom_loaded) { + int force_mode_change = 0; + in_menu = 1; /* surface will be lost, must adjust pl_vout_buf for menu bg */ @@ -221,7 +285,11 @@ void plat_video_menu_enter(int is_rom_loaded) memcpy(menubg_img, plat_sdl_screen->pixels, psx_w * psx_h * 2); pl_vout_buf = menubg_img; - change_video_mode(); + /* gles plugin messes stuff up.. */ + if (pl_rearmed_cbs.gpu_caps & GPU_CAP_OWNS_DISPLAY) + force_mode_change = 1; + + change_video_mode(force_mode_change); } void plat_video_menu_begin(void)