Merge pull request #1 from pcercuei/for_upstream

This commit is contained in:
notaz 2013-10-09 16:43:16 -07:00
commit 62e581e179
11 changed files with 145 additions and 125 deletions

View file

@ -20,6 +20,7 @@ typedef unsigned long keybits_t;
#define KEYBITS_WORD_BITS (sizeof(keybits_t) * 8) #define KEYBITS_WORD_BITS (sizeof(keybits_t) * 8)
struct in_sdl_state { struct in_sdl_state {
const in_drv_t *drv;
SDL_Joystick *joy; SDL_Joystick *joy;
int joy_id; int joy_id;
int axis_keydown[2]; int axis_keydown[2];
@ -162,21 +163,27 @@ static const char * const in_sdl_keys[SDLK_LAST] = {
[SDLK_COMPOSE] = "compose", [SDLK_COMPOSE] = "compose",
}; };
static void in_sdl_probe(void) static void in_sdl_probe(const in_drv_t *drv)
{ {
const struct in_pdata *pdata = drv->pdata;
const char * const * key_names = in_sdl_keys;
struct in_sdl_state *state; struct in_sdl_state *state;
SDL_Joystick *joy; SDL_Joystick *joy;
int i, joycount; int i, joycount;
char name[256]; char name[256];
if (pdata->key_names)
key_names = pdata->key_names;
state = calloc(1, sizeof(*state)); state = calloc(1, sizeof(*state));
if (state == NULL) { if (state == NULL) {
fprintf(stderr, "in_sdl: OOM\n"); fprintf(stderr, "in_sdl: OOM\n");
return; return;
} }
state->drv = drv;
in_register(IN_SDL_PREFIX "keys", -1, state, SDLK_LAST, in_register(IN_SDL_PREFIX "keys", -1, state, SDLK_LAST,
in_sdl_keys, 0); key_names, 0);
/* joysticks go here too */ /* joysticks go here too */
SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_InitSubSystem(SDL_INIT_JOYSTICK);
@ -194,9 +201,10 @@ static void in_sdl_probe(void)
} }
state->joy = joy; state->joy = joy;
state->joy_id = i; state->joy_id = i;
state->drv = drv;
snprintf(name, sizeof(name), IN_SDL_PREFIX "%s", SDL_JoystickName(i)); snprintf(name, sizeof(name), IN_SDL_PREFIX "%s", SDL_JoystickName(i));
in_register(name, -1, state, SDLK_LAST, in_sdl_keys, 0); in_register(name, -1, state, SDLK_LAST, key_names, 0);
} }
if (joycount > 0) if (joycount > 0)
@ -215,9 +223,13 @@ static void in_sdl_free(void *drv_data)
} }
static const char * const * static const char * const *
in_sdl_get_key_names(int *count) in_sdl_get_key_names(const in_drv_t *drv, int *count)
{ {
const struct in_pdata *pdata = drv->pdata;
*count = SDLK_LAST; *count = SDLK_LAST;
if (pdata->key_names)
return pdata->key_names;
return in_sdl_keys; return in_sdl_keys;
} }
@ -406,52 +418,26 @@ static int in_sdl_update_keycode(void *drv_data, int *is_down)
return ret_kc; return ret_kc;
} }
struct menu_keymap {
short key;
short pbtn;
};
static const struct menu_keymap key_pbtn_map[] =
{
{ SDLK_UP, PBTN_UP },
{ SDLK_DOWN, PBTN_DOWN },
{ SDLK_LEFT, PBTN_LEFT },
{ SDLK_RIGHT, PBTN_RIGHT },
/* XXX: maybe better set this from it's plat code somehow */
{ SDLK_RETURN, PBTN_MOK },
{ SDLK_ESCAPE, PBTN_MBACK },
{ SDLK_SEMICOLON, PBTN_MA2 },
{ SDLK_QUOTE, PBTN_MA3 },
{ SDLK_BACKSLASH, PBTN_MENU },
{ SDLK_LEFTBRACKET, PBTN_L },
{ SDLK_RIGHTBRACKET, PBTN_R },
};
#define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0]))
static const struct menu_keymap joybtn_pbtn_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 },
};
#define JOYBTN_PBTN_MAP_SIZE (sizeof(joybtn_pbtn_map) / sizeof(joybtn_pbtn_map[0]))
static int in_sdl_menu_translate(void *drv_data, int keycode, char *charcode) static int in_sdl_menu_translate(void *drv_data, int keycode, char *charcode)
{ {
struct in_sdl_state *state = drv_data; struct in_sdl_state *state = drv_data;
const struct in_pdata *pdata = state->drv->pdata;
const char * const * key_names = in_sdl_keys;
const struct menu_keymap *map; const struct menu_keymap *map;
int map_len; int map_len;
int ret = 0; int ret = 0;
int i; int i;
map = state->joy ? joybtn_pbtn_map : key_pbtn_map; if (pdata->key_names)
map_len = state->joy ? JOYBTN_PBTN_MAP_SIZE : KEY_PBTN_MAP_SIZE; key_names = pdata->key_names;
if (state->joy) {
map = pdata->joy_map;
map_len = pdata->jmap_size;
} else {
map = pdata->key_map;
map_len = pdata->kmap_size;
}
if (keycode < 0) if (keycode < 0)
{ {
@ -471,10 +457,10 @@ static int in_sdl_menu_translate(void *drv_data, int keycode, char *charcode)
} }
if (charcode != NULL && (unsigned int)keycode < SDLK_LAST && if (charcode != NULL && (unsigned int)keycode < SDLK_LAST &&
in_sdl_keys[keycode] != NULL && in_sdl_keys[keycode][1] == 0) key_names[keycode] != NULL && key_names[keycode][1] == 0)
{ {
ret |= PBTN_CHAR; ret |= PBTN_CHAR;
*charcode = in_sdl_keys[keycode][0]; *charcode = key_names[keycode][0];
} }
} }
@ -491,9 +477,14 @@ static const in_drv_t in_sdl_drv = {
.menu_translate = in_sdl_menu_translate, .menu_translate = in_sdl_menu_translate,
}; };
void in_sdl_init(const struct in_default_bind *defbinds, int in_sdl_init(const struct in_pdata *pdata, void (*handler)(void *event))
void (*handler)(void *event))
{ {
in_register_driver(&in_sdl_drv, defbinds); if (!pdata) {
fprintf(stderr, "in_sdl: Missing input platform data\n");
return -1;
}
in_register_driver(&in_sdl_drv, pdata->defbinds, pdata);
ext_event_handler = handler; ext_event_handler = handler;
return 0;
} }

View file

@ -1,4 +1 @@
struct in_default_bind; int in_sdl_init(const struct in_pdata *pdata, void (*handler)(void *event));
void in_sdl_init(const struct in_default_bind *defbinds,
void (*handler)(void *event));

14
input.c
View file

@ -63,7 +63,7 @@ static int *in_alloc_binds(int drv_id, int key_count)
if (defbinds[i].bit == 0 && defbinds[i].btype == 0 if (defbinds[i].bit == 0 && defbinds[i].btype == 0
&& defbinds[i].bit == 0) && defbinds[i].bit == 0)
break; break;
binds[IN_BIND_OFFS(defbinds[i].code, defbinds[i].btype)] = binds[IN_BIND_OFFS(defbinds[i].code, defbinds[i].btype)] |=
1 << defbinds[i].bit; 1 << defbinds[i].bit;
} }
@ -247,7 +247,7 @@ void in_probe(void)
for (i = 0; i < in_driver_count; i++) { for (i = 0; i < in_driver_count; i++) {
in_probe_dev_id = i; in_probe_dev_id = i;
in_drivers[i].probe(); in_drivers[i].probe(&DRV(i));
} }
/* get rid of devs without binds and probes */ /* get rid of devs without binds and probes */
@ -808,7 +808,8 @@ int in_config_parse_dev(const char *name)
if (in_devices[i].name == NULL) if (in_devices[i].name == NULL)
return -1; return -1;
in_devices[i].key_names = DRV(drv_id).get_key_names(&in_devices[i].key_count); in_devices[i].key_names = DRV(drv_id).get_key_names(&DRV(drv_id),
&in_devices[i].key_count);
in_devices[i].drv_id = drv_id; in_devices[i].drv_id = drv_id;
if (i + 1 > in_dev_count) if (i + 1 > in_dev_count)
@ -932,7 +933,8 @@ static const char *in_def_get_key_name(int keycode) { return NULL; }
if (d.f == NULL) d.f = in_def_##f if (d.f == NULL) d.f = in_def_##f
/* to be called by drivers */ /* to be called by drivers */
int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbinds) int in_register_driver(const in_drv_t *drv,
const struct in_default_bind *defbinds, const void *pdata)
{ {
int count_new = in_driver_count + 1; int count_new = in_driver_count + 1;
in_drv_t *new_drivers; in_drv_t *new_drivers;
@ -954,7 +956,9 @@ int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbin
CHECK_ADD_STUB(new_drivers[in_driver_count], menu_translate); CHECK_ADD_STUB(new_drivers[in_driver_count], menu_translate);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_code); CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_code);
CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_name); CHECK_ADD_STUB(new_drivers[in_driver_count], get_key_name);
if (defbinds != NULL) if (pdata)
new_drivers[in_driver_count].pdata = pdata;
if (defbinds)
new_drivers[in_driver_count].defbinds = defbinds; new_drivers[in_driver_count].defbinds = defbinds;
in_drivers = new_drivers; in_drivers = new_drivers;
in_driver_count = count_new; in_driver_count = count_new;

28
input.h
View file

@ -76,12 +76,14 @@ enum {
#define IN_BIND_OFFS(key, btype) \ #define IN_BIND_OFFS(key, btype) \
((key) * IN_BINDTYPE_COUNT + (btype)) ((key) * IN_BINDTYPE_COUNT + (btype))
typedef struct { typedef struct InputDriver in_drv_t;
struct InputDriver {
const char *prefix; const char *prefix;
void (*probe)(void); void (*probe)(const in_drv_t *drv);
void (*free)(void *drv_data); void (*free)(void *drv_data);
const char * const * const char * const *
(*get_key_names)(int *count); (*get_key_names)(const in_drv_t *drv, int *count);
int (*clean_binds)(void *drv_data, int *binds, int *def_finds); int (*clean_binds)(void *drv_data, int *binds, int *def_finds);
int (*get_config)(void *drv_data, int what, int *val); int (*get_config)(void *drv_data, int what, int *val);
int (*set_config)(void *drv_data, int what, int val); int (*set_config)(void *drv_data, int what, int val);
@ -94,7 +96,8 @@ typedef struct {
const char * (*get_key_name)(int keycode); const char * (*get_key_name)(int keycode);
const struct in_default_bind *defbinds; const struct in_default_bind *defbinds;
} in_drv_t; const void *pdata;
};
struct in_default_bind { struct in_default_bind {
unsigned short code; unsigned short code;
@ -102,8 +105,23 @@ struct in_default_bind {
unsigned char bit; unsigned char bit;
}; };
struct menu_keymap {
short key;
short pbtn;
};
struct in_pdata {
const struct in_default_bind *defbinds;
const struct menu_keymap *key_map;
size_t kmap_size;
const struct menu_keymap *joy_map;
size_t jmap_size;
const char * const *key_names;
};
/* to be called by drivers */ /* to be called by drivers */
int in_register_driver(const in_drv_t *drv, const struct in_default_bind *defbinds); int in_register_driver(const in_drv_t *drv,
const struct in_default_bind *defbinds, const void *pdata);
void in_register(const char *nname, int drv_fd_hnd, void *drv_data, void in_register(const char *nname, int drv_fd_hnd, void *drv_data,
int key_count, const char * const *key_names, int combos); int key_count, const char * const *key_names, int combos);
void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts); void in_combos_find(const int *binds, int last_key, int *combo_keys, int *combo_acts);

View file

@ -41,6 +41,8 @@ typedef struct {
int abs_mult[MAX_ABS_DEVS]; /* 16.16 multiplier to IN_ABS_RANGE */ int abs_mult[MAX_ABS_DEVS]; /* 16.16 multiplier to IN_ABS_RANGE */
int abs_adj[MAX_ABS_DEVS]; /* adjust for centering */ int abs_adj[MAX_ABS_DEVS]; /* adjust for centering */
unsigned int abs_to_digital:1; unsigned int abs_to_digital:1;
const in_drv_t *drv;
} in_evdev_t; } in_evdev_t;
#ifndef KEY_CNT #ifndef KEY_CNT
@ -147,7 +149,7 @@ static const char * const in_evdev_keys[KEY_CNT] = {
}; };
static void in_evdev_probe(void) static void in_evdev_probe(const in_drv_t *drv)
{ {
long keybits[KEY_CNT / sizeof(long) / 8]; long keybits[KEY_CNT / sizeof(long) / 8];
long absbits[(ABS_MAX+1) / sizeof(long) / 8]; long absbits[(ABS_MAX+1) / sizeof(long) / 8];
@ -206,6 +208,8 @@ static void in_evdev_probe(void)
if (dev == NULL) if (dev == NULL)
goto skip; goto skip;
dev->drv = drv;
ret = ioctl(fd, EVIOCGKEY(sizeof(keybits)), keybits); ret = ioctl(fd, EVIOCGKEY(sizeof(keybits)), keybits);
if (ret == -1) { if (ret == -1) {
printf("Warning: EVIOCGKEY not supported, will have to track state\n"); printf("Warning: EVIOCGKEY not supported, will have to track state\n");
@ -286,9 +290,13 @@ static void in_evdev_free(void *drv_data)
} }
static const char * const * static const char * const *
in_evdev_get_key_names(int *count) in_evdev_get_key_names(const in_drv_t *drv, int *count)
{ {
const struct in_pdata *pdata = drv->pdata;
*count = KEY_CNT; *count = KEY_CNT;
if (pdata->key_names)
return pdata->key_names;
return in_evdev_keys; return in_evdev_keys;
} }
@ -522,47 +530,10 @@ out:
return ret_kc; return ret_kc;
} }
static const struct {
short key;
short pbtn;
} key_pbtn_map[] =
{
{ KEY_UP, PBTN_UP },
{ KEY_DOWN, PBTN_DOWN },
{ KEY_LEFT, PBTN_LEFT },
{ KEY_RIGHT, PBTN_RIGHT },
/* XXX: maybe better set this from it's plat code somehow */
/* Pandora */
{ KEY_END, PBTN_MOK },
{ KEY_PAGEDOWN, PBTN_MBACK },
{ KEY_HOME, PBTN_MA2 },
{ KEY_PAGEUP, PBTN_MA3 },
{ KEY_LEFTCTRL, PBTN_MENU },
{ KEY_RIGHTSHIFT, PBTN_L },
{ KEY_RIGHTCTRL, PBTN_R },
/* Caanoo */
{ BTN_THUMB2, PBTN_MOK },
{ BTN_THUMB, PBTN_MBACK },
{ BTN_TRIGGER, PBTN_MA2 },
{ BTN_TOP, PBTN_MA3 },
{ BTN_BASE, PBTN_MENU },
{ BTN_TOP2, PBTN_L },
{ BTN_PINKIE, PBTN_R },
/* "normal" keyboards */
{ KEY_ENTER, PBTN_MOK },
{ KEY_ESC, PBTN_MBACK },
{ KEY_SEMICOLON, PBTN_MA2 },
{ KEY_APOSTROPHE, PBTN_MA3 },
{ KEY_BACKSLASH, PBTN_MENU },
{ KEY_LEFTBRACE, PBTN_L },
{ KEY_RIGHTBRACE, PBTN_R },
};
#define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0]))
static int in_evdev_menu_translate(void *drv_data, int keycode, char *charcode) static int in_evdev_menu_translate(void *drv_data, int keycode, char *charcode)
{ {
in_evdev_t *dev = drv_data; in_evdev_t *dev = drv_data;
const struct in_pdata *pdata = dev->drv->pdata;
int ret = 0; int ret = 0;
int i; int i;
@ -570,9 +541,9 @@ static int in_evdev_menu_translate(void *drv_data, int keycode, char *charcode)
{ {
/* menu -> kc */ /* menu -> kc */
keycode = -keycode; keycode = -keycode;
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++) for (i = 0; i < pdata->kmap_size; i++)
if (key_pbtn_map[i].pbtn == keycode) { if (pdata->key_map[i].pbtn == keycode) {
int k = key_pbtn_map[i].key; int k = pdata->key_map[i].key;
/* should really check EVIOCGBIT, but this is enough for now */ /* should really check EVIOCGBIT, but this is enough for now */
if (dev->kc_first <= k && k <= dev->kc_last) if (dev->kc_first <= k && k <= dev->kc_last)
return k; return k;
@ -580,9 +551,9 @@ static int in_evdev_menu_translate(void *drv_data, int keycode, char *charcode)
} }
else else
{ {
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++) { for (i = 0; i < pdata->kmap_size; i++) {
if (key_pbtn_map[i].key == keycode) { if (pdata->key_map[i].key == keycode) {
ret = key_pbtn_map[i].pbtn; ret = pdata->key_map[i].pbtn;
break; break;
} }
} }
@ -649,8 +620,14 @@ static const in_drv_t in_evdev_drv = {
.menu_translate = in_evdev_menu_translate, .menu_translate = in_evdev_menu_translate,
}; };
void in_evdev_init(const struct in_default_bind *defbinds) int in_evdev_init(const struct in_pdata *pdata)
{ {
in_register_driver(&in_evdev_drv, defbinds); if (!pdata) {
fprintf(stderr, "in_sdl: Missing input platform data\n");
return -1;
}
in_register_driver(&in_evdev_drv, pdata->defbinds, pdata);
return 0;
} }

View file

@ -1,5 +1,3 @@
struct in_default_bind;
extern int in_evdev_allow_abs_only; extern int in_evdev_allow_abs_only;
void in_evdev_init(const struct in_default_bind *defbinds); int in_evdev_init(const struct in_pdata *pdata);

View file

@ -19,6 +19,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h>
#include "../plat.h" #include "../plat.h"
@ -40,24 +41,54 @@ int plat_is_dir(const char *path)
return 0; return 0;
} }
int plat_get_root_dir(char *dst, int len) static int plat_get_data_dir(char *dst, int len)
{ {
int j, ret; #ifdef PICO_DATA_DIR
memcpy(dst, PICO_DATA_DIR, sizeof PICO_DATA_DIR);
ret = readlink("/proc/self/exe", dst, len - 1); return sizeof(PICO_DATA_DIR) - 1;
#else
int j, ret = readlink("/proc/self/exe", dst, len - 1);
if (ret < 0) { if (ret < 0) {
perror("readlink"); perror("readlink");
ret = 0; ret = 0;
} }
dst[ret] = 0; dst[ret] = 0;
for (j = strlen(dst); j > 0; j--) for (j = ret - 1; j > 0; j--)
if (dst[j] == '/') { if (dst[j] == '/') {
dst[++j] = 0; dst[++j] = 0;
break; break;
} }
return j; return j;
#endif
}
int plat_get_skin_dir(char *dst, int len)
{
int ret = plat_get_data_dir(dst, len);
if (ret < 0)
return ret;
memcpy(dst + ret, "skin/", sizeof "skin/");
return ret + sizeof("skin/") - 1;
}
#ifndef PICO_HOME_DIR
#define PICO_HOME_DIR "/.picodrive/"
#endif
int plat_get_root_dir(char *dst, int len)
{
#if defined(__GP2X__) || defined(PANDORA)
return plat_get_data_dir(dst, len);
#else
char *home = getenv("HOME");
size_t nb = strlen(home);
memcpy(dst, home, nb);
memcpy(dst + nb, PICO_HOME_DIR, sizeof PICO_HOME_DIR);
mkdir(dst, 0755);
return nb + sizeof(PICO_HOME_DIR) - 1;
#endif
} }
#ifdef __GP2X__ #ifdef __GP2X__

9
menu.c
View file

@ -239,7 +239,7 @@ static char tolower_simple(char c)
void menu_init_base(void) void menu_init_base(void)
{ {
int i, c, l; int i, c, l, pos;
unsigned char *fd, *fds; unsigned char *fd, *fds;
char buff[256]; char buff[256];
FILE *f; FILE *f;
@ -294,17 +294,18 @@ void menu_init_base(void)
} }
// load custom font and selector (stored as 1st symbol in font table) // load custom font and selector (stored as 1st symbol in font table)
emu_make_path(buff, "skin/font.png", sizeof(buff)); pos = plat_get_skin_dir(buff, sizeof(buff));
strcpy(buff + pos, "font.png");
readpng(menu_font_data, buff, READPNG_FONT, readpng(menu_font_data, buff, READPNG_FONT,
MENU_X2 ? 256 : 128, MENU_X2 ? 320 : 160); MENU_X2 ? 256 : 128, MENU_X2 ? 320 : 160);
// default selector symbol is '>' // default selector symbol is '>'
memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2, memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2,
me_mfont_w * me_mfont_h / 2); me_mfont_w * me_mfont_h / 2);
emu_make_path(buff, "skin/selector.png", sizeof(buff)); strcpy(buff + pos, "selector.png");
readpng(menu_font_data, buff, READPNG_SELECTOR, me_mfont_w, me_mfont_h); readpng(menu_font_data, buff, READPNG_SELECTOR, me_mfont_w, me_mfont_h);
// load custom colors // load custom colors
emu_make_path(buff, "skin/skin.txt", sizeof(buff)); strcpy(buff + pos, "skin.txt");
f = fopen(buff, "r"); f = fopen(buff, "r");
if (f != NULL) if (f != NULL)
{ {

3
plat.h
View file

@ -104,6 +104,9 @@ void plat_video_wait_vsync(void);
/* return the dir/ where configs, saves, bios, etc. are found */ /* return the dir/ where configs, saves, bios, etc. are found */
int plat_get_root_dir(char *dst, int len); int plat_get_root_dir(char *dst, int len);
/* return the dir/ where skin files are found */
int plat_get_skin_dir(char *dst, int len);
int plat_is_dir(const char *path); int plat_is_dir(const char *path);
int plat_wait_event(int *fds_hnds, int count, int timeout_ms); int plat_wait_event(int *fds_hnds, int count, int timeout_ms);
void plat_sleep_ms(int ms); void plat_sleep_ms(int ms);

View file

@ -120,7 +120,7 @@ int plat_sdl_change_video_mode(int w, int h, int force)
if (plat_target.vout_method == 0) { if (plat_target.vout_method == 0) {
SDL_PumpEvents(); SDL_PumpEvents();
plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_SWSURFACE); plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (plat_sdl_screen == NULL) { if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
return -1; return -1;
@ -227,7 +227,7 @@ int plat_sdl_init(void)
// overlay/gl require native bpp in some cases.. // overlay/gl require native bpp in some cases..
plat_sdl_screen = SDL_SetVideoMode(g_menuscreen_w, g_menuscreen_h, plat_sdl_screen = SDL_SetVideoMode(g_menuscreen_w, g_menuscreen_h,
0, SDL_SWSURFACE); 0, plat_sdl_screen->flags);
if (plat_sdl_screen == NULL) { if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
goto fail; goto fail;

View file

@ -75,7 +75,7 @@ int sndout_sdl_start(int rate, int stereo)
desired.callback = callback; desired.callback = callback;
desired.userdata = NULL; desired.userdata = NULL;
samples = rate * 4 * 16 / 1000; samples = rate >> 6;
for (shift = 8; (1 << shift) < samples; shift++) for (shift = 8; (1 << shift) < samples; shift++)
; ;
desired.samples = 1 << shift; desired.samples = 1 << shift;