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.
13 #include "common/input.h"
14 #include "common/in_sdl.h"
15 #include "common/menu.h"
16 #include "plugin_lib.h"
21 static const struct in_default_bind in_sdl_defbinds[] = {
22 { SDLK_UP, IN_BINDTYPE_PLAYER12, DKEY_UP },
23 { SDLK_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN },
24 { SDLK_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT },
25 { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT },
26 { SDLK_d, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE },
27 { SDLK_z, IN_BINDTYPE_PLAYER12, DKEY_CROSS },
28 { SDLK_x, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE },
29 { SDLK_s, IN_BINDTYPE_PLAYER12, DKEY_SQUARE },
30 { SDLK_v, IN_BINDTYPE_PLAYER12, DKEY_START },
31 { SDLK_c, IN_BINDTYPE_PLAYER12, DKEY_SELECT },
32 { SDLK_w, IN_BINDTYPE_PLAYER12, DKEY_L1 },
33 { SDLK_r, IN_BINDTYPE_PLAYER12, DKEY_R1 },
34 { SDLK_e, IN_BINDTYPE_PLAYER12, DKEY_L2 },
35 { SDLK_t, IN_BINDTYPE_PLAYER12, DKEY_R2 },
36 { SDLK_ESCAPE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU },
40 static SDL_Surface *screen;
41 static void *menubg_img;
43 static int change_video_mode(int w, int h)
45 screen = SDL_SetVideoMode(w, h, 16, 0);
47 fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
58 ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
60 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
66 ret = change_video_mode(g_menuscreen_w, g_menuscreen_h);
68 ret = change_video_mode(0, 0);
72 if (screen->w < 320 || screen->h < 240) {
73 fprintf(stderr, "resolution %dx%d is too small, sorry.\n",
74 screen->w, screen->h);
77 g_menuscreen_w = screen->w;
78 g_menuscreen_h = screen->h;
80 SDL_WM_SetCaption("PCSX-ReARMed " REV, NULL);
82 menubg_img = malloc(640 * 512 * 2);
83 if (menubg_img == NULL)
86 in_sdl_init(in_sdl_defbinds);
88 pl_rearmed_cbs.only_16bpp = 1;
96 void plat_finish(void)
103 void plat_gvideo_open(int is_pal)
107 void *plat_gvideo_set_mode(int *w, int *h, int *bpp)
109 change_video_mode(*w, *h);
110 return screen->pixels;
113 /* XXX: missing SDL_LockSurface() */
114 void *plat_gvideo_flip(void)
117 return screen->pixels;
120 void plat_gvideo_close(void)
124 void plat_video_menu_enter(int is_rom_loaded)
126 /* surface will be lost, must adjust pl_vout_buf for menu bg */
127 memcpy(menubg_img, screen->pixels, screen->w * screen->h * 2);
128 pl_vout_buf = menubg_img;
130 change_video_mode(g_menuscreen_w, g_menuscreen_h);
133 void plat_video_menu_begin(void)
135 SDL_LockSurface(screen);
136 g_menuscreen_ptr = screen->pixels;
139 void plat_video_menu_end(void)
141 SDL_UnlockSurface(screen);
143 g_menuscreen_ptr = NULL;
146 void plat_video_menu_leave(void)
151 void *plat_prepare_screenshot(int *w, int *h, int *bpp)
156 int plat_cpu_clock_get(void)
161 int plat_cpu_clock_apply(int cpu_clock)
166 int plat_get_bat_capacity(void)
171 void plat_step_volume(int is_up)
175 void plat_trigger_vibrate(int is_strong)
179 void plat_minimize(void)
183 // vim:shiftwidth=2:expandtab