ARCH ?= arm
TARGET = libSDL-1.2.so.0
-OBJS += standalone.o input.o config.o \
+OBJS += standalone.o osdl_input.o config.o \
common/input.o linux/fbdev.o linux/in_evdev.o linux/oshide.o linux/plat.o
ifeq ($(ARCH),arm)
OBJS += arm_utils.o
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include "omapsdl.h"
+int gcfg_force_vsync;
+
static char *sskip(char *p)
{
while (*p && isspace(*p))
return p;
}
-static int check_token(const char *p, const char *token)
+static int check_token(char **p_, const char *token)
{
+ char *p = *p_;
int tlen = strlen(token);
- return strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]);
+ int ret = strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]);
+ if (ret)
+ *p_ = sskip(p + tlen + 1);
+
+ return ret;
+}
+
+static int check_token_eq(char **p_, const char *token)
+{
+ char *p = *p_;
+ int ret = check_token(&p, token);
+ ret = ret && *p == '=';
+ if (ret)
+ *p_ = sskip(p + 1);
+
+ return ret;
}
void omapsdl_config(void)
if (*p == '#')
continue;
- if (check_token(p, "bind")) {
+ if (check_token(&p, "bind")) {
char *key, *key_end, *sdlkey, *sdlkey_end;
- key = sskip(p + 5);
+ key = p;
key_end = nsskip(key);
p = sskip(key_end);
if (*p != '=')
omapsdl_input_bind(key, sdlkey);
continue;
}
+ else if (check_token_eq(&p, "force_vsync")) {
+ gcfg_force_vsync = strtol(p, NULL, 0);
+ continue;
+ }
bad:
err("config: failed to parse: %s", line);
#define err(fmt, ...) fprintf(stderr, "omapsdl: " fmt "\n", ##__VA_ARGS__)
#define not_supported() fprintf(stderr, "omapsdl: %s not supported\n", __FUNCTION__)
-#if 1
+#if 0
#define trace(fmt, ...) printf(" %s(" fmt ")\n", __FUNCTION__, ##__VA_ARGS__)
#define dbg err
#else
void omapsdl_input_init(void);
void omapsdl_input_bind(const char *kname, const char *sdlname);
-int omapsdl_input_get_event(void *event_, int timeout);
+int omapsdl_input_get_event(int *is_down, int timeout);
void omapsdl_config(void);
/* functions for standalone */
void do_clut(void *dest, void *src, unsigned short *pal, int count);
+
+/* config */
+extern int gcfg_force_vsync;
#include "omapsdl.h"
#include "common/input.h"
-static unsigned char g_keystate[SDLK_LAST];
-
static short pmsdl_map[KEY_CNT] = {
[KEY_0] = SDLK_0,
[KEY_1] = SDLK_1,
in_probe();
}
-int omapsdl_input_get_event(void *event_, int timeout)
+int omapsdl_input_get_event(int *is_down, int timeout)
{
- SDL_Event *event = event_;
- int key, is_down;
+ int key;
while (1) {
int kc;
- is_down = 0;
- kc = in_update_keycode(NULL, &is_down, timeout);
+ *is_down = 0;
+ kc = in_update_keycode(NULL, is_down, timeout);
if (kc < 0 || kc > KEY_MAX)
- return 0;
+ return -1;
key = pmsdl_map[kc];
if (key != 0)
break;
}
+ return key;
+}
+
+/* SDL */
+#ifdef STANDALONE
+
+static unsigned char g_keystate[SDLK_LAST];
+
+static int do_event(SDL_Event *event, int timeout)
+{
+ int key, is_down;
+
+ key = omapsdl_input_get_event(&is_down, timeout);
+ if (key < 0)
+ return 0;
+
g_keystate[key] = is_down;
if (event == NULL)
return 1;
}
-/* SDL */
-#ifdef STANDALONE
-
DECLSPEC int SDLCALL
SDL_WaitEvent(SDL_Event *event)
{
trace("%p", event);
- return omapsdl_input_get_event(event, -1);
+ return do_event(event, -1);
}
DECLSPEC int SDLCALL
{
trace("%p", event);
- return omapsdl_input_get_event(event, 0);
+ return do_event(event, 0);
}
DECLSPEC Uint8 * SDLCALL