Fixed reading settings

This commit is contained in:
CTurt 2014-12-07 15:48:08 +00:00
parent f57da08e96
commit 23bc5d5637
2 changed files with 4 additions and 3 deletions

View file

@ -42,7 +42,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
printf("Running on: %s\n\n", hostName); printf("Running on: %s\n\n", hostName);
if(!readSettings()) { if(!readSettings()) {
printf("Couldn't read settings file, using default key bindings\n"); printf("Couldn't read settings file, using default key bindings.\n");
} }
startListening(); startListening();

View file

@ -29,7 +29,7 @@ static bool getSetting(char *name, char *src, char *dest) {
if(start) { if(start) {
char *end = start + strlen(start); char *end = start + strlen(start);
if(strstr(start, "\n") < end) end = strstr(start, "\n") - 1; if(strstr(start, "\n") - 1 < end) end = strstr(start, "\n") - 1;
size_t size = (size_t)end - (size_t)start; size_t size = (size_t)end - (size_t)start;
strncpy(dest, start, size); strncpy(dest, start, size);
@ -49,7 +49,8 @@ static int getButton(char *string) {
else if(strcmp(string, "RIGHT") == 0) return VK_RIGHT; else if(strcmp(string, "RIGHT") == 0) return VK_RIGHT;
else if(strcmp(string, "UP") == 0) return VK_UP; else if(strcmp(string, "UP") == 0) return VK_UP;
else if(strcmp(string, "DOWN") == 0) return VK_DOWN; else if(strcmp(string, "DOWN") == 0) return VK_DOWN;
else return (int)*string;
return (int)string[0];
} }
bool readSettings(void) { bool readSettings(void) {