From 6d486e6ea5d2247ff2f2bce74577a1612fac84d4 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Sun, 19 Jan 2020 11:53:31 +0100 Subject: [PATCH] Fix controller add linux --- controller/gamepad.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/controller/gamepad.c b/controller/gamepad.c index c317e48..53a830d 100644 --- a/controller/gamepad.c +++ b/controller/gamepad.c @@ -704,7 +704,7 @@ static void GamepadAddDevice(const char* devPath) { } } - if (i == GAMEPAD_COUNT) { + if (controller == GAMEPAD_COUNT) { return; } @@ -718,19 +718,18 @@ static void GamepadAddDevice(const char* devPath) { } /* copy the device path */ - STATE[i].device = strdup(devPath); - if (STATE[i].device == NULL) { + STATE[controller].device = strdup(devPath); + if (STATE[controller].device == NULL) { return; } /* reset device state */ - GamepadResetState((GAMEPAD_DEVICE)i); + GamepadResetState((GAMEPAD_DEVICE)controller); fcntl(fd, F_SETFL, O_NONBLOCK); - STATE[i].fd = fd; - STATE[i].flags |= FLAG_CONNECTED; + STATE[controller].fd = fd; + STATE[controller].flags |= FLAG_CONNECTED; - int controller = i; { int i, t; unsigned long keybit[NBITS(KEY_MAX)] = { 0 };