Fix controller add linux

This commit is contained in:
Nemirtingas 2020-01-19 11:53:31 +01:00
parent 835b2dd3ed
commit 6d486e6ea5
1 changed files with 6 additions and 7 deletions

View File

@ -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 };