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.
16 static char *sskip(char *p)
18 while (*p && isspace(*p))
23 static char *nsskip(char *p)
25 while (*p && !isspace(*p))
30 static int check_token(char **p_, const char *token)
33 int tlen = strlen(token);
34 int ret = strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]);
36 *p_ = sskip(p + tlen + 1);
41 static int check_token_eq(char **p_, const char *token)
44 int ret = check_token(&p, token);
45 ret = ret && *p == '=';
52 void omapsdl_config(struct SDL_PrivateVideoData *pdata)
57 f = fopen("omapsdl.cfg", "r");
62 char *p, *line = fgets(buff, sizeof(buff), f);
65 p = line = sskip(line);
66 if (*p == 0 || *p == '#')
69 if (check_token(&p, "bind")) {
70 char *key, *key_end, *sdlkey, *sdlkey_end;
72 key_end = nsskip(key);
76 sdlkey = sskip(p + 1);
77 sdlkey_end = nsskip(sdlkey);
78 p = sskip(sdlkey_end);
79 if (*key == 0 || *sdlkey == 0 || *p != 0)
81 *key_end = *sdlkey_end = 0;
83 omapsdl_input_bind(key, sdlkey);
86 else if (check_token_eq(&p, "force_vsync")) {
87 pdata->cfg_force_vsync = !!strtol(p, NULL, 0);
90 else if (check_token_eq(&p, "force_doublebuf")) {
91 pdata->cfg_force_doublebuf = !!strtol(p, NULL, 0);
94 else if (check_token_eq(&p, "no_ts_translate")) {
95 pdata->cfg_no_ts_translate = !!strtol(p, NULL, 0);
100 err("config: failed to parse: %s", line);
105 void omapsdl_config_from_env(struct SDL_PrivateVideoData *pdata)
109 tmp = getenv("SDL_OMAP_VSYNC");
111 pdata->cfg_force_vsync = !!strtol(tmp, NULL, 0);
112 tmp = getenv("SDL_OMAP_FORCE_DOUBLEBUF");
114 pdata->cfg_force_doublebuf = !!strtol(tmp, NULL, 0);
115 tmp = getenv("SDL_OMAP_NO_TS_TRANSLATE");
117 pdata->cfg_no_ts_translate = !!strtol(tmp, NULL, 0);
118 tmp = getenv("SDL_OMAP_BORDER_CUT");
121 if (sscanf(tmp, "%d,%d,%d,%d", &l, &r, &t, &b) == 4
122 && l >= 0 && r >= 0 && t >= 0 && b >= 0) {
123 pdata->border_l = l, pdata->border_r = r;
124 pdata->border_t = t, pdata->border_b = b;
127 err("border incorrectly specified, ignored");