2 * (C) GraÅžvydas "notaz" Ignotas, 2010
4 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
5 * See the COPYING file in the top-level directory.
17 int gcfg_force_doublebuf;
19 static char *sskip(char *p)
21 while (*p && isspace(*p))
26 static char *nsskip(char *p)
28 while (*p && !isspace(*p))
33 static int check_token(char **p_, const char *token)
36 int tlen = strlen(token);
37 int ret = strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]);
39 *p_ = sskip(p + tlen + 1);
44 static int check_token_eq(char **p_, const char *token)
47 int ret = check_token(&p, token);
48 ret = ret && *p == '=';
55 void omapsdl_config(void)
60 f = fopen("omapsdl.cfg", "r");
65 char *p, *line = fgets(buff, sizeof(buff), f);
68 p = line = sskip(line);
69 if (*p == 0 || *p == '#')
72 if (check_token(&p, "bind")) {
73 char *key, *key_end, *sdlkey, *sdlkey_end;
75 key_end = nsskip(key);
79 sdlkey = sskip(p + 1);
80 sdlkey_end = nsskip(sdlkey);
81 p = sskip(sdlkey_end);
82 if (*key == 0 || *sdlkey == 0 || *p != 0)
84 *key_end = *sdlkey_end = 0;
86 omapsdl_input_bind(key, sdlkey);
89 else if (check_token_eq(&p, "force_vsync")) {
90 gcfg_force_vsync = strtol(p, NULL, 0);
93 else if (check_token_eq(&p, "force_doublebuf")) {
94 gcfg_force_doublebuf = strtol(p, NULL, 0);
99 err("config: failed to parse: %s", line);
104 void omapsdl_config_from_env(void)
108 tmp = getenv("SDL_OMAP_VSYNC");
110 gcfg_force_vsync = strtol(tmp, NULL, 0);
111 tmp = getenv("SDL_OMAP_FORCE_DOUBLEBUF");
113 gcfg_force_doublebuf = strtol(tmp, NULL, 0);