Allow up to 16 gamepads with Sunshine hosts

This commit is contained in:
Cameron Gutman
2023-06-30 20:55:20 -05:00
parent 5bb47ce8b6
commit 0169cedb27
2 changed files with 12 additions and 6 deletions

View File

@@ -105,6 +105,9 @@ static const int hat_constants[3][3] = {{HAT_UP | HAT_LEFT, HAT_UP, HAT_UP | HAT
// Determines the maximum motion amount before allowing movement
#define MOUSE_EMULATION_DEADZONE 2
// Limited by number of bits in activeGamepadMask
#define MAX_GAMEPADS 16
static struct input_device* devices = NULL;
static int numDevices = 0;
static int assignedControllerIds = 0;
@@ -283,7 +286,7 @@ static bool evdev_handle_event(struct input_event *ev, struct input_device *dev)
}
if (dev->gamepadModified) {
if (dev->controllerId < 0) {
for (int i = 0; i < 4; i++) {
for (int i = 0; i < MAX_GAMEPADS; i++) {
if ((assignedControllerIds & (1 << i)) == 0) {
assignedControllerIds |= (1 << i);
dev->controllerId = i;