Implement device reassignment in input settings menu.
@@ -38306,6 +38306,20 @@ void keyboard_setup(int player)
printf("Done!\n");
}
+// Set device safely (with switching)
+static void safe_set_device(int player, int newdevice, int olddevice)
+{
+ int i;
+ for (i = 0; i < levelsets[current_set].maxplayers; i++)
+ {
+ if (playercontrolpointers[i]->deviceID == newdevice)
+ {
+ playercontrolpointers[i]->deviceID = olddevice;
+ }
+ }
+ playercontrolpointers[player]->deviceID = newdevice;
+}
+
void menu_options_input()
{
int quit = 0;
@@ -38463,9 +38477,10 @@ void menu_options_input()
}
} while (!control_isvaliddevice(selected_device));
}
- else
+ else // (bothnewkeys & FLAG_ANYBUTTON)
{
- // TODO: device reassignment
+ // assign selected device to player
+ safe_set_device(selector, selected_device, playercontrolpointers[selector]->deviceID);
}
break;
case 4:
