Changeable port
This commit is contained in:
parent
8f7d748606
commit
c70d18433f
3 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
Port: 8888
|
||||
Circle Pad: JOYSTICK
|
||||
Touch: MOUSE
|
||||
A: A
|
||||
|
|
|
@ -37,6 +37,10 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
vJoy = false;
|
||||
}
|
||||
|
||||
if(!readSettings()) {
|
||||
printf("Couldn't read settings file, using default key bindings.\n");
|
||||
}
|
||||
|
||||
initNetwork();
|
||||
|
||||
printf("Port: %d\n", port);
|
||||
|
@ -48,10 +52,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
|
||||
printf("\n");
|
||||
|
||||
if(!readSettings()) {
|
||||
printf("Couldn't read settings file, using default key bindings.\n");
|
||||
}
|
||||
|
||||
startListening();
|
||||
|
||||
while(1) {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "wireless.h"
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
struct settings settings;
|
||||
|
@ -25,9 +27,11 @@ struct settings defaultSettings = {
|
|||
};
|
||||
|
||||
static bool getSetting(char *name, char *src, char *dest) {
|
||||
char *start = strstr(src, name) + strlen(name);
|
||||
char *start = strstr(src, name);
|
||||
|
||||
if(start) {
|
||||
start += strlen(name);
|
||||
|
||||
char *end = start + strlen(start);
|
||||
if(strstr(start, "\n") - 1 < end) end = strstr(start, "\n") - 1;
|
||||
size_t size = (size_t)end - (size_t)start;
|
||||
|
@ -79,6 +83,10 @@ bool readSettings(void) {
|
|||
|
||||
char setting[64] = { '\0' };
|
||||
|
||||
if(getSetting("Port: ", buffer, setting)) {
|
||||
sscanf(setting, "%d", &port);
|
||||
}
|
||||
|
||||
if(getSetting("Circle Pad: ", buffer, setting)) {
|
||||
if(strcmp(setting, "MOUSE") == 0) settings.circlePad = mouse;
|
||||
else if(strcmp(setting, "JOYSTICK") == 0) settings.circlePad = joystick;
|
||||
|
|
Loading…
Add table
Reference in a new issue