2 * (C) GraÅžvydas "notaz" Ignotas, 2011,2012
4 * This work is licensed under the terms of any of these licenses
6 * - GNU GPL, version 2 or later.
7 * - GNU LGPL, version 2.1 or later.
8 * See the COPYING file in the top-level directory.
14 #include "libpicofe/input.h"
15 #include "libpicofe/in_sdl.h"
16 #include "libpicofe/menu.h"
17 #include "plugin_lib.h"
22 static const struct in_default_bind in_sdl_defbinds[] = {
23 { SDLK_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
24 { SDLK_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
25 { SDLK_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
26 { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
27 { SDLK_d, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
28 { SDLK_z, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
29 { SDLK_x, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
30 { SDLK_s, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
31 { SDLK_v, IN_BINDTYPE_PLAYER12, DKEY_START },
32 { SDLK_c, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
33 { SDLK_w, IN_BINDTYPE_PLAYER12, DKEY_L1 },
34 { SDLK_r, IN_BINDTYPE_PLAYER12, DKEY_R1 },
35 { SDLK_e, IN_BINDTYPE_PLAYER12, DKEY_L2 },
36 { SDLK_t, IN_BINDTYPE_PLAYER12, DKEY_R2 },
37 { SDLK_ESCAPE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
41 static SDL_Surface *screen;
42 static void *menubg_img;
44 static int change_video_mode(int w, int h)
46 screen = SDL_SetVideoMode(w, h, 16, 0);
48 fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
59 ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
61 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
67 ret = change_video_mode(g_menuscreen_w, g_menuscreen_h);
69 ret = change_video_mode(0, 0);
73 if (screen->w < 320 || screen->h < 240) {
74 fprintf(stderr, "resolution %dx%d is too small, sorry.\n",
75 screen->w, screen->h);
78 g_menuscreen_w = screen->w;
79 g_menuscreen_h = screen->h;
81 SDL_WM_SetCaption("PCSX-ReARMed " REV, NULL);
83 menubg_img = malloc(640 * 512 * 2);
84 if (menubg_img == NULL)
87 in_sdl_init(in_sdl_defbinds);
89 pl_rearmed_cbs.only_16bpp = 1;
97 void plat_finish(void)
104 void plat_gvideo_open(int is_pal)
108 void *plat_gvideo_set_mode(int *w, int *h, int *bpp)
110 change_video_mode(*w, *h);
111 return screen->pixels;
114 /* XXX: missing SDL_LockSurface() */
115 void *plat_gvideo_flip(void)
118 return screen->pixels;
121 void plat_gvideo_close(void)
125 void plat_video_menu_enter(int is_rom_loaded)
127 /* surface will be lost, must adjust pl_vout_buf for menu bg */
128 memcpy(menubg_img, screen->pixels, screen->w * screen->h * 2);
129 pl_vout_buf = menubg_img;
131 change_video_mode(g_menuscreen_w, g_menuscreen_h);
134 void plat_video_menu_begin(void)
136 SDL_LockSurface(screen);
137 g_menuscreen_ptr = screen->pixels;
140 void plat_video_menu_end(void)
142 SDL_UnlockSurface(screen);
144 g_menuscreen_ptr = NULL;
147 void plat_video_menu_leave(void)
152 void *plat_prepare_screenshot(int *w, int *h, int *bpp)
157 int plat_cpu_clock_get(void)
162 int plat_cpu_clock_apply(int cpu_clock)
167 int plat_get_bat_capacity(void)
172 void plat_step_volume(int is_up)
176 void plat_trigger_vibrate(int is_strong)
180 void plat_minimize(void)
184 // vim:shiftwidth=2:expandtab