X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fplat_sdl.c;h=5e11cf8434aaeaf10a34bb8aafe96cce4f275e3e;hp=2aa199fb3126e12c667dd106ab46eef076a2dccc;hb=215ff9e69c0b845f24e7a3aa9faeef06d9276145;hpb=418caf437ed1af2880b013462b603e1ca1f28fb5 diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index 2aa199fb..5e11cf84 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -17,7 +17,7 @@ #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" @@ -53,6 +53,41 @@ 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; @@ -98,6 +133,7 @@ static void get_layer_pos(int *x, int *y, int *w, int *h) void plat_init(void) { + int shadow_size; int ret; plat_sdl_quit_cb = quit_cb; @@ -110,14 +146,18 @@ 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; @@ -296,7 +336,7 @@ void *plat_prepare_screenshot(int *w, int *h, int *bpp) return 0; } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { }