aboutsummaryrefslogtreecommitdiff
path: root/frontend/plat_sdl.c
diff options
context:
space:
mode:
authornotaz2012-04-23 02:00:48 +0300
committernotaz2012-04-29 19:32:08 +0300
commit7badc9353b9570fd1c67827cfb477cef07974ddb (patch)
tree5d80351ae6edfae031c858a5be8170ff625fa888 /frontend/plat_sdl.c
parent6469a8c407ff23af8b7a6218f759b368eec7c339 (diff)
downloadpcsx_rearmed-7badc9353b9570fd1c67827cfb477cef07974ddb.tar.gz
pcsx_rearmed-7badc9353b9570fd1c67827cfb477cef07974ddb.tar.bz2
pcsx_rearmed-7badc9353b9570fd1c67827cfb477cef07974ddb.zip
frontend: generic: preliminary SDL support
Diffstat (limited to 'frontend/plat_sdl.c')
-rw-r--r--frontend/plat_sdl.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c
new file mode 100644
index 0000000..015450d
--- /dev/null
+++ b/frontend/plat_sdl.c
@@ -0,0 +1,154 @@
+/*
+ * (C) GraÅžvydas "notaz" Ignotas, 2011,2012
+ *
+ * This work is licensed under the terms of any of these licenses
+ * (at your option):
+ * - GNU GPL, version 2 or later.
+ * - GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <stdio.h>
+#include <SDL.h>
+#include "common/input.h"
+#include "common/in_sdl.h"
+#include "common/menu.h"
+#include "plat.h"
+#include "revision.h"
+
+// XXX
+struct in_default_bind in_evdev_defbinds[] = {
+ { 0, 0, 0 }
+};
+
+static SDL_Surface *screen;
+
+static int change_video_mode(int w, int h)
+{
+ screen = SDL_SetVideoMode(w, h, 16, 0);
+ if (screen == NULL) {
+ fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
+ return -1;
+ }
+
+ return 0;
+}
+
+void plat_init(void)
+{
+ int ret;
+
+ ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
+ if (ret != 0) {
+ fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
+ exit(1);
+ }
+
+ g_menuscreen_w = 640;
+ g_menuscreen_h = 480;
+ ret = change_video_mode(g_menuscreen_w, g_menuscreen_h);
+ if (ret != 0) {
+ ret = change_video_mode(0, 0);
+ if (ret != 0)
+ goto fail;
+
+ if (screen->w < 320 || screen->h < 240) {
+ fprintf(stderr, "resolution %dx%d is too small, sorry.\n",
+ screen->w, screen->h);
+ goto fail;
+ }
+ g_menuscreen_w = screen->w;
+ g_menuscreen_h = screen->h;
+ }
+ SDL_WM_SetCaption("PCSX-ReARMed " REV, NULL);
+
+ in_sdl_init();
+ in_probe();
+ return;
+
+fail:
+ SDL_Quit();
+ exit(1);
+}
+
+void plat_finish(void)
+{
+ SDL_Quit();
+}
+
+void plat_gvideo_open(void)
+{
+}
+
+void *plat_gvideo_set_mode(int *w, int *h, int *bpp)
+{
+ change_video_mode(*w, *h);
+ return screen->pixels;
+}
+
+void *plat_gvideo_flip(void)
+{
+ SDL_Flip(screen);
+ return screen->pixels;
+}
+
+void plat_gvideo_close(void)
+{
+}
+
+void plat_video_menu_enter(int is_rom_loaded)
+{
+ change_video_mode(g_menuscreen_w, g_menuscreen_h);
+}
+
+void plat_video_menu_begin(void)
+{
+ SDL_LockSurface(screen);
+ g_menuscreen_ptr = screen->pixels;
+}
+
+void plat_video_menu_end(void)
+{
+ SDL_UnlockSurface(screen);
+ SDL_Flip(screen);
+ g_menuscreen_ptr = NULL;
+}
+
+void plat_video_menu_leave(void)
+{
+}
+
+/* unused stuff */
+void *plat_prepare_screenshot(int *w, int *h, int *bpp)
+{
+ return 0;
+}
+
+int plat_cpu_clock_get(void)
+{
+ return -1;
+}
+
+int plat_cpu_clock_apply(int cpu_clock)
+{
+ return -1;
+}
+
+int plat_get_bat_capacity(void)
+{
+ return -1;
+}
+
+void plat_step_volume(int is_up)
+{
+}
+
+void plat_trigger_vibrate(int is_strong)
+{
+}
+
+void plat_minimize(void)
+{
+}
+
+// vim:shiftwidth=2:expandtab