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.
18 static char *sskip(char *p)
20 while (*p && isspace(*p))
25 static char *nsskip(char *p)
27 while (*p && !isspace(*p))
32 static int check_token(char **p_, const char *token)
35 int tlen = strlen(token);
36 int ret = strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]);
38 *p_ = sskip(p + tlen + 1);
43 static int check_token_eq(char **p_, const char *token)
46 int ret = check_token(&p, token);
47 ret = ret && *p == '=';
54 void omapsdl_config(void)
59 f = fopen("omapsdl.cfg", "r");
64 char *p, *line = fgets(buff, sizeof(buff), f);
67 p = line = sskip(line);
68 if (*p == 0 || *p == '#')
71 if (check_token(&p, "bind")) {
72 char *key, *key_end, *sdlkey, *sdlkey_end;
74 key_end = nsskip(key);
78 sdlkey = sskip(p + 1);
79 sdlkey_end = nsskip(sdlkey);
80 p = sskip(sdlkey_end);
81 if (*key == 0 || *sdlkey == 0 || *p != 0)
83 *key_end = *sdlkey_end = 0;
85 omapsdl_input_bind(key, sdlkey);
88 else if (check_token_eq(&p, "force_vsync")) {
89 gcfg_force_vsync = strtol(p, NULL, 0);
94 err("config: failed to parse: %s", line);
99 void omapsdl_config_from_env(void)
103 tmp = getenv("SDL_OMAP_VSYNC");
105 gcfg_force_vsync = atoi(tmp);