frontend: generic: preliminary SDL support
[pcsx_rearmed.git] / frontend / plat_sdl.c
... / ...
CommitLineData
1/*
2 * (C) GraÅžvydas "notaz" Ignotas, 2011,2012
3 *
4 * This work is licensed under the terms of any of these licenses
5 * (at your option):
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.
9 */
10
11#include <stdio.h>
12#include <SDL.h>
13#include "common/input.h"
14#include "common/in_sdl.h"
15#include "common/menu.h"
16#include "plat.h"
17#include "revision.h"
18
19// XXX
20struct in_default_bind in_evdev_defbinds[] = {
21 { 0, 0, 0 }
22};
23
24static SDL_Surface *screen;
25
26static int change_video_mode(int w, int h)
27{
28 screen = SDL_SetVideoMode(w, h, 16, 0);
29 if (screen == NULL) {
30 fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
31 return -1;
32 }
33
34 return 0;
35}
36
37void plat_init(void)
38{
39 int ret;
40
41 ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
42 if (ret != 0) {
43 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
44 exit(1);
45 }
46
47 g_menuscreen_w = 640;
48 g_menuscreen_h = 480;
49 ret = change_video_mode(g_menuscreen_w, g_menuscreen_h);
50 if (ret != 0) {
51 ret = change_video_mode(0, 0);
52 if (ret != 0)
53 goto fail;
54
55 if (screen->w < 320 || screen->h < 240) {
56 fprintf(stderr, "resolution %dx%d is too small, sorry.\n",
57 screen->w, screen->h);
58 goto fail;
59 }
60 g_menuscreen_w = screen->w;
61 g_menuscreen_h = screen->h;
62 }
63 SDL_WM_SetCaption("PCSX-ReARMed " REV, NULL);
64
65 in_sdl_init();
66 in_probe();
67 return;
68
69fail:
70 SDL_Quit();
71 exit(1);
72}
73
74void plat_finish(void)
75{
76 SDL_Quit();
77}
78
79void plat_gvideo_open(void)
80{
81}
82
83void *plat_gvideo_set_mode(int *w, int *h, int *bpp)
84{
85 change_video_mode(*w, *h);
86 return screen->pixels;
87}
88
89void *plat_gvideo_flip(void)
90{
91 SDL_Flip(screen);
92 return screen->pixels;
93}
94
95void plat_gvideo_close(void)
96{
97}
98
99void plat_video_menu_enter(int is_rom_loaded)
100{
101 change_video_mode(g_menuscreen_w, g_menuscreen_h);
102}
103
104void plat_video_menu_begin(void)
105{
106 SDL_LockSurface(screen);
107 g_menuscreen_ptr = screen->pixels;
108}
109
110void plat_video_menu_end(void)
111{
112 SDL_UnlockSurface(screen);
113 SDL_Flip(screen);
114 g_menuscreen_ptr = NULL;
115}
116
117void plat_video_menu_leave(void)
118{
119}
120
121/* unused stuff */
122void *plat_prepare_screenshot(int *w, int *h, int *bpp)
123{
124 return 0;
125}
126
127int plat_cpu_clock_get(void)
128{
129 return -1;
130}
131
132int plat_cpu_clock_apply(int cpu_clock)
133{
134 return -1;
135}
136
137int plat_get_bat_capacity(void)
138{
139 return -1;
140}
141
142void plat_step_volume(int is_up)
143{
144}
145
146void plat_trigger_vibrate(int is_strong)
147{
148}
149
150void plat_minimize(void)
151{
152}
153
154// vim:shiftwidth=2:expandtab