Fix controller add linux

This commit is contained in:
Nemirtingas 2020-01-19 11:53:31 +01:00
parent 835b2dd3ed
commit 6d486e6ea5

View File

@ -704,7 +704,7 @@ static void GamepadAddDevice(const char* devPath) {
} }
} }
if (i == GAMEPAD_COUNT) { if (controller == GAMEPAD_COUNT) {
return; return;
} }
@ -718,19 +718,18 @@ static void GamepadAddDevice(const char* devPath) {
} }
/* copy the device path */ /* copy the device path */
STATE[i].device = strdup(devPath); STATE[controller].device = strdup(devPath);
if (STATE[i].device == NULL) { if (STATE[controller].device == NULL) {
return; return;
} }
/* reset device state */ /* reset device state */
GamepadResetState((GAMEPAD_DEVICE)i); GamepadResetState((GAMEPAD_DEVICE)controller);
fcntl(fd, F_SETFL, O_NONBLOCK); fcntl(fd, F_SETFL, O_NONBLOCK);
STATE[i].fd = fd; STATE[controller].fd = fd;
STATE[i].flags |= FLAG_CONNECTED; STATE[controller].flags |= FLAG_CONNECTED;
int controller = i;
{ {
int i, t; int i, t;
unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; unsigned long keybit[NBITS(KEY_MAX)] = { 0 };